Skip to content

Commit d52b9d3

Browse files
committed
Fix checker initialization crash with esModuleInterop global merges resolving to ImportEquals aliases
1 parent 755e1cb commit d52b9d3

File tree

4 files changed

+191
-1
lines changed

4 files changed

+191
-1
lines changed

Diff for: src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3675,7 +3675,7 @@ namespace ts {
36753675
if (!sigs || !sigs.length) {
36763676
sigs = getSignaturesOfStructuredType(type, SignatureKind.Construct);
36773677
}
3678-
if ((sigs && sigs.length) || getPropertyOfType(type, InternalSymbolName.Default)) {
3678+
if ((sigs && sigs.length) || getPropertyOfType(type, InternalSymbolName.Default, /*skipObjectFunctionPropertyAugment*/ true)) {
36793679
const moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol!, reference);
36803680
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
36813681
}
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//// [tests/cases/compiler/checkerInitializationCrash.ts] ////
2+
3+
//// [index.d.ts]
4+
import * as react from 'react';
5+
declare global {
6+
namespace FullCalendarVDom {
7+
export import VNode = react.ReactNode;
8+
}
9+
}
10+
11+
export default class FullCalendar {
12+
}
13+
14+
//// [index.d.ts]
15+
import * as preact from 'preact';
16+
declare global {
17+
namespace FullCalendarVDom {
18+
type VNode = preact.VNode<any>;
19+
}
20+
}
21+
22+
export type EventInput = any;
23+
24+
//// [index.d.ts]
25+
export = React;
26+
export as namespace React;
27+
declare namespace React {
28+
type ReactNode = any;
29+
function useMemo<T>(factory: () => T, deps: undefined): T;
30+
}
31+
32+
//// [index.d.ts]
33+
export as namespace preact;
34+
export interface VNode<P = {}> {}
35+
36+
//// [index.tsx]
37+
import FullCalendar from "@fullcalendar/react";
38+
import { EventInput } from "@fullcalendar/core";
39+
40+
41+
//// [index.js]
42+
export {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
=== /node_modules/@fullcalendar/react/index.d.ts ===
2+
import * as react from 'react';
3+
>react : Symbol(react, Decl(index.d.ts, 0, 6))
4+
5+
declare global {
6+
>global : Symbol(global, Decl(index.d.ts, 0, 31))
7+
8+
namespace FullCalendarVDom {
9+
>FullCalendarVDom : Symbol(FullCalendarVDom, Decl(index.d.ts, 1, 16), Decl(index.d.ts, 1, 16))
10+
11+
export import VNode = react.ReactNode;
12+
>VNode : Symbol(FullCalendarVDom.VNode, Decl(index.d.ts, 2, 30))
13+
>react : Symbol(react, Decl(index.d.ts, 0, 6))
14+
>ReactNode : Symbol(react.ReactNode, Decl(index.d.ts, 2, 25), Decl(index.d.ts, 2, 30))
15+
}
16+
}
17+
18+
export default class FullCalendar {
19+
>FullCalendar : Symbol(FullCalendar, Decl(index.d.ts, 5, 1))
20+
}
21+
22+
=== /node_modules/@fullcalendar/core/index.d.ts ===
23+
import * as preact from 'preact';
24+
>preact : Symbol(preact, Decl(index.d.ts, 0, 6))
25+
26+
declare global {
27+
>global : Symbol(global, Decl(index.d.ts, 0, 33))
28+
29+
namespace FullCalendarVDom {
30+
>FullCalendarVDom : Symbol(FullCalendarVDom, Decl(index.d.ts, 1, 16), Decl(index.d.ts, 1, 16))
31+
32+
type VNode = preact.VNode<any>;
33+
>VNode : Symbol(React.ReactNode, Decl(index.d.ts, 2, 25), Decl(index.d.ts, 2, 30))
34+
>preact : Symbol(preact, Decl(index.d.ts, 0, 6))
35+
>VNode : Symbol(preact.VNode, Decl(index.d.ts, 0, 27))
36+
}
37+
}
38+
39+
export type EventInput = any;
40+
>EventInput : Symbol(EventInput, Decl(index.d.ts, 5, 1))
41+
42+
=== /node_modules/@types/react/index.d.ts ===
43+
export = React;
44+
>React : Symbol(React, Decl(index.d.ts, 1, 26))
45+
46+
export as namespace React;
47+
>React : Symbol(React, Decl(index.d.ts, 0, 15))
48+
49+
declare namespace React {
50+
>React : Symbol(React, Decl(index.d.ts, 1, 26))
51+
52+
type ReactNode = any;
53+
>ReactNode : Symbol(ReactNode, Decl(index.d.ts, 2, 25), Decl(index.d.ts, 2, 30))
54+
55+
function useMemo<T>(factory: () => T, deps: undefined): T;
56+
>useMemo : Symbol(useMemo, Decl(index.d.ts, 3, 25))
57+
>T : Symbol(T, Decl(index.d.ts, 4, 21))
58+
>factory : Symbol(factory, Decl(index.d.ts, 4, 24))
59+
>T : Symbol(T, Decl(index.d.ts, 4, 21))
60+
>deps : Symbol(deps, Decl(index.d.ts, 4, 41))
61+
>T : Symbol(T, Decl(index.d.ts, 4, 21))
62+
}
63+
64+
=== /node_modules/preact/index.d.ts ===
65+
export as namespace preact;
66+
>preact : Symbol(preact, Decl(index.d.ts, 0, 0))
67+
68+
export interface VNode<P = {}> {}
69+
>VNode : Symbol(VNode, Decl(index.d.ts, 0, 27))
70+
>P : Symbol(P, Decl(index.d.ts, 1, 23))
71+
72+
=== /index.tsx ===
73+
import FullCalendar from "@fullcalendar/react";
74+
>FullCalendar : Symbol(FullCalendar, Decl(index.tsx, 0, 6))
75+
76+
import { EventInput } from "@fullcalendar/core";
77+
>EventInput : Symbol(EventInput, Decl(index.tsx, 1, 8))
78+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
=== /node_modules/@fullcalendar/react/index.d.ts ===
2+
import * as react from 'react';
3+
>react : typeof react
4+
5+
declare global {
6+
>global : typeof global
7+
8+
namespace FullCalendarVDom {
9+
>FullCalendarVDom : typeof FullCalendarVDom
10+
11+
export import VNode = react.ReactNode;
12+
>VNode : any
13+
>react : typeof react
14+
>ReactNode : any
15+
}
16+
}
17+
18+
export default class FullCalendar {
19+
>FullCalendar : FullCalendar
20+
}
21+
22+
=== /node_modules/@fullcalendar/core/index.d.ts ===
23+
import * as preact from 'preact';
24+
>preact : typeof preact
25+
26+
declare global {
27+
>global : any
28+
29+
namespace FullCalendarVDom {
30+
type VNode = preact.VNode<any>;
31+
>VNode : any
32+
>preact : any
33+
}
34+
}
35+
36+
export type EventInput = any;
37+
>EventInput : any
38+
39+
=== /node_modules/@types/react/index.d.ts ===
40+
export = React;
41+
>React : typeof React
42+
43+
export as namespace React;
44+
>React : typeof React
45+
46+
declare namespace React {
47+
>React : typeof React
48+
49+
type ReactNode = any;
50+
>ReactNode : any
51+
52+
function useMemo<T>(factory: () => T, deps: undefined): T;
53+
>useMemo : <T>(factory: () => T, deps: undefined) => T
54+
>factory : () => T
55+
>deps : undefined
56+
}
57+
58+
=== /node_modules/preact/index.d.ts ===
59+
export as namespace preact;
60+
>preact : typeof import("/node_modules/preact/index")
61+
62+
export interface VNode<P = {}> {}
63+
64+
=== /index.tsx ===
65+
import FullCalendar from "@fullcalendar/react";
66+
>FullCalendar : typeof FullCalendar
67+
68+
import { EventInput } from "@fullcalendar/core";
69+
>EventInput : any
70+

0 commit comments

Comments
 (0)