diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 179e5fb04d08e..74545e366fdb8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8790,7 +8790,7 @@ namespace ts { function getTypeReferenceTypeWorker(node: NodeWithTypeArguments, symbol: Symbol, typeArguments: Type[] | undefined): Type | undefined { if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - if (symbol.valueDeclaration && isBinaryExpression(symbol.valueDeclaration.parent)) { + if (symbol.valueDeclaration && symbol.valueDeclaration.parent && isBinaryExpression(symbol.valueDeclaration.parent)) { const jsdocType = getJSDocTypeReference(node, symbol, typeArguments); if (jsdocType) { return jsdocType; diff --git a/tests/baselines/reference/noCrashUMDMergedWithGlobalValue.js b/tests/baselines/reference/noCrashUMDMergedWithGlobalValue.js new file mode 100644 index 0000000000000..7f8edd9c38703 --- /dev/null +++ b/tests/baselines/reference/noCrashUMDMergedWithGlobalValue.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/noCrashUMDMergedWithGlobalValue.ts] //// + +//// [other.d.ts] +export as namespace SomeInterface; +export type Action = "PUSH" | "POP" | "REPLACE"; + +//// [main.ts] +interface SomeInterface { + readonly length: number; +} +declare const value: SomeInterface; + + +//// [main.js] diff --git a/tests/baselines/reference/noCrashUMDMergedWithGlobalValue.symbols b/tests/baselines/reference/noCrashUMDMergedWithGlobalValue.symbols new file mode 100644 index 0000000000000..c2249abe1d419 --- /dev/null +++ b/tests/baselines/reference/noCrashUMDMergedWithGlobalValue.symbols @@ -0,0 +1,18 @@ +=== /other.d.ts === +export as namespace SomeInterface; +>SomeInterface : Symbol(SomeInterface, Decl(other.d.ts, 0, 0)) + +export type Action = "PUSH" | "POP" | "REPLACE"; +>Action : Symbol(Action, Decl(other.d.ts, 0, 34)) + +=== /main.ts === +interface SomeInterface { +>SomeInterface : Symbol("/other", Decl(other.d.ts, 0, 0), Decl(main.ts, 0, 0)) + + readonly length: number; +>length : Symbol(length, Decl(main.ts, 0, 25)) +} +declare const value: SomeInterface; +>value : Symbol(value, Decl(main.ts, 3, 13)) +>SomeInterface : Symbol("/other", Decl(other.d.ts, 0, 0), Decl(main.ts, 0, 0)) + diff --git a/tests/baselines/reference/noCrashUMDMergedWithGlobalValue.types b/tests/baselines/reference/noCrashUMDMergedWithGlobalValue.types new file mode 100644 index 0000000000000..f01fad2560eee --- /dev/null +++ b/tests/baselines/reference/noCrashUMDMergedWithGlobalValue.types @@ -0,0 +1,15 @@ +=== /other.d.ts === +export as namespace SomeInterface; +>SomeInterface : typeof import("/other") + +export type Action = "PUSH" | "POP" | "REPLACE"; +>Action : Action + +=== /main.ts === +interface SomeInterface { + readonly length: number; +>length : number +} +declare const value: SomeInterface; +>value : import("/other") + diff --git a/tests/cases/compiler/noCrashUMDMergedWithGlobalValue.ts b/tests/cases/compiler/noCrashUMDMergedWithGlobalValue.ts new file mode 100644 index 0000000000000..0e37eecf91d98 --- /dev/null +++ b/tests/cases/compiler/noCrashUMDMergedWithGlobalValue.ts @@ -0,0 +1,9 @@ +//@filename: /other.d.ts +export as namespace SomeInterface; +export type Action = "PUSH" | "POP" | "REPLACE"; + +//@filename: /main.ts +interface SomeInterface { + readonly length: number; +} +declare const value: SomeInterface;