Skip to content

Commit e1278f0

Browse files
authored
Get resolved module exports in symbol chain and not raw exports (#20661)
* Actually get module exports and not module exports sans export stars * style update * Trim test a bit
1 parent 2c6501d commit e1278f0

File tree

5 files changed

+75
-1
lines changed

5 files changed

+75
-1
lines changed

Diff for: src/compiler/checker.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2216,7 +2216,8 @@ namespace ts {
22162216

22172217
// Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain
22182218
// but only if the symbolFromSymbolTable can be qualified
2219-
const accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined;
2219+
const candidateTable = getExportsOfSymbol(resolvedImportedSymbol);
2220+
const accessibleSymbolsFromExports = candidateTable && getAccessibleSymbolChainFromSymbolTable(candidateTable);
22202221
if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) {
22212222
return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports);
22222223
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//// [tests/cases/compiler/declarationEmitAliasExportStar.ts] ////
2+
3+
//// [thingB.ts]
4+
export interface ThingB { }
5+
//// [things.ts]
6+
export * from "./thingB";
7+
//// [index.ts]
8+
import * as things from "./things";
9+
export const thing2 = (param: things.ThingB) => null;
10+
11+
12+
//// [thingB.js]
13+
"use strict";
14+
exports.__esModule = true;
15+
//// [things.js]
16+
"use strict";
17+
exports.__esModule = true;
18+
//// [index.js]
19+
"use strict";
20+
exports.__esModule = true;
21+
exports.thing2 = function (param) { return null; };
22+
23+
24+
//// [thingB.d.ts]
25+
export interface ThingB {
26+
}
27+
//// [things.d.ts]
28+
export * from "./thingB";
29+
//// [index.d.ts]
30+
import * as things from "./things";
31+
export declare const thing2: (param: things.ThingB) => any;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/thingB.ts ===
2+
export interface ThingB { }
3+
>ThingB : Symbol(ThingB, Decl(thingB.ts, 0, 0))
4+
5+
=== tests/cases/compiler/things.ts ===
6+
export * from "./thingB";
7+
No type information for this code.=== tests/cases/compiler/index.ts ===
8+
import * as things from "./things";
9+
>things : Symbol(things, Decl(index.ts, 0, 6))
10+
11+
export const thing2 = (param: things.ThingB) => null;
12+
>thing2 : Symbol(thing2, Decl(index.ts, 1, 12))
13+
>param : Symbol(param, Decl(index.ts, 1, 23))
14+
>things : Symbol(things, Decl(index.ts, 0, 6))
15+
>ThingB : Symbol(things.ThingB, Decl(thingB.ts, 0, 0))
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== tests/cases/compiler/thingB.ts ===
2+
export interface ThingB { }
3+
>ThingB : ThingB
4+
5+
=== tests/cases/compiler/things.ts ===
6+
export * from "./thingB";
7+
No type information for this code.=== tests/cases/compiler/index.ts ===
8+
import * as things from "./things";
9+
>things : typeof things
10+
11+
export const thing2 = (param: things.ThingB) => null;
12+
>thing2 : (param: things.ThingB) => any
13+
>(param: things.ThingB) => null : (param: things.ThingB) => any
14+
>param : things.ThingB
15+
>things : any
16+
>ThingB : things.ThingB
17+
>null : null
18+
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @declaration: true
2+
// @filename: thingB.ts
3+
export interface ThingB { }
4+
// @filename: things.ts
5+
export * from "./thingB";
6+
// @filename: index.ts
7+
import * as things from "./things";
8+
export const thing2 = (param: things.ThingB) => null;

0 commit comments

Comments
 (0)