Skip to content

Commit 4c9ad08

Browse files
authored
Add fix for webpack history merge bug (microsoft#29339)
* Add fix for webpack history merge bug * Add test case
1 parent 3f7357d commit 4c9ad08

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8790,7 +8790,7 @@ namespace ts {
87908790

87918791
function getTypeReferenceTypeWorker(node: NodeWithTypeArguments, symbol: Symbol, typeArguments: Type[] | undefined): Type | undefined {
87928792
if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
8793-
if (symbol.valueDeclaration && isBinaryExpression(symbol.valueDeclaration.parent)) {
8793+
if (symbol.valueDeclaration && symbol.valueDeclaration.parent && isBinaryExpression(symbol.valueDeclaration.parent)) {
87948794
const jsdocType = getJSDocTypeReference(node, symbol, typeArguments);
87958795
if (jsdocType) {
87968796
return jsdocType;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//// [tests/cases/compiler/noCrashUMDMergedWithGlobalValue.ts] ////
2+
3+
//// [other.d.ts]
4+
export as namespace SomeInterface;
5+
export type Action = "PUSH" | "POP" | "REPLACE";
6+
7+
//// [main.ts]
8+
interface SomeInterface {
9+
readonly length: number;
10+
}
11+
declare const value: SomeInterface;
12+
13+
14+
//// [main.js]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== /other.d.ts ===
2+
export as namespace SomeInterface;
3+
>SomeInterface : Symbol(SomeInterface, Decl(other.d.ts, 0, 0))
4+
5+
export type Action = "PUSH" | "POP" | "REPLACE";
6+
>Action : Symbol(Action, Decl(other.d.ts, 0, 34))
7+
8+
=== /main.ts ===
9+
interface SomeInterface {
10+
>SomeInterface : Symbol("/other", Decl(other.d.ts, 0, 0), Decl(main.ts, 0, 0))
11+
12+
readonly length: number;
13+
>length : Symbol(length, Decl(main.ts, 0, 25))
14+
}
15+
declare const value: SomeInterface;
16+
>value : Symbol(value, Decl(main.ts, 3, 13))
17+
>SomeInterface : Symbol("/other", Decl(other.d.ts, 0, 0), Decl(main.ts, 0, 0))
18+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== /other.d.ts ===
2+
export as namespace SomeInterface;
3+
>SomeInterface : typeof import("/other")
4+
5+
export type Action = "PUSH" | "POP" | "REPLACE";
6+
>Action : Action
7+
8+
=== /main.ts ===
9+
interface SomeInterface {
10+
readonly length: number;
11+
>length : number
12+
}
13+
declare const value: SomeInterface;
14+
>value : import("/other")
15+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@filename: /other.d.ts
2+
export as namespace SomeInterface;
3+
export type Action = "PUSH" | "POP" | "REPLACE";
4+
5+
//@filename: /main.ts
6+
interface SomeInterface {
7+
readonly length: number;
8+
}
9+
declare const value: SomeInterface;

0 commit comments

Comments
 (0)