From e1278f091c42f2587ec55f892bdc9729b8036e90 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 13 Dec 2017 14:01:23 -0800 Subject: [PATCH] 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 --- src/compiler/checker.ts | 3 +- .../declarationEmitAliasExportStar.js | 31 +++++++++++++++++++ .../declarationEmitAliasExportStar.symbols | 16 ++++++++++ .../declarationEmitAliasExportStar.types | 18 +++++++++++ .../declarationEmitAliasExportStar.ts | 8 +++++ 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/declarationEmitAliasExportStar.js create mode 100644 tests/baselines/reference/declarationEmitAliasExportStar.symbols create mode 100644 tests/baselines/reference/declarationEmitAliasExportStar.types create mode 100644 tests/cases/compiler/declarationEmitAliasExportStar.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e8cf80cb1fe..c1b57e5def7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2216,7 +2216,8 @@ namespace ts { // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain // but only if the symbolFromSymbolTable can be qualified - const accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + const candidateTable = getExportsOfSymbol(resolvedImportedSymbol); + const accessibleSymbolsFromExports = candidateTable && getAccessibleSymbolChainFromSymbolTable(candidateTable); if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); } diff --git a/tests/baselines/reference/declarationEmitAliasExportStar.js b/tests/baselines/reference/declarationEmitAliasExportStar.js new file mode 100644 index 00000000000..a7f8932cbf9 --- /dev/null +++ b/tests/baselines/reference/declarationEmitAliasExportStar.js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/declarationEmitAliasExportStar.ts] //// + +//// [thingB.ts] +export interface ThingB { } +//// [things.ts] +export * from "./thingB"; +//// [index.ts] +import * as things from "./things"; +export const thing2 = (param: things.ThingB) => null; + + +//// [thingB.js] +"use strict"; +exports.__esModule = true; +//// [things.js] +"use strict"; +exports.__esModule = true; +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.thing2 = function (param) { return null; }; + + +//// [thingB.d.ts] +export interface ThingB { +} +//// [things.d.ts] +export * from "./thingB"; +//// [index.d.ts] +import * as things from "./things"; +export declare const thing2: (param: things.ThingB) => any; diff --git a/tests/baselines/reference/declarationEmitAliasExportStar.symbols b/tests/baselines/reference/declarationEmitAliasExportStar.symbols new file mode 100644 index 00000000000..8f86cf3dc8c --- /dev/null +++ b/tests/baselines/reference/declarationEmitAliasExportStar.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/thingB.ts === +export interface ThingB { } +>ThingB : Symbol(ThingB, Decl(thingB.ts, 0, 0)) + +=== tests/cases/compiler/things.ts === +export * from "./thingB"; +No type information for this code.=== tests/cases/compiler/index.ts === +import * as things from "./things"; +>things : Symbol(things, Decl(index.ts, 0, 6)) + +export const thing2 = (param: things.ThingB) => null; +>thing2 : Symbol(thing2, Decl(index.ts, 1, 12)) +>param : Symbol(param, Decl(index.ts, 1, 23)) +>things : Symbol(things, Decl(index.ts, 0, 6)) +>ThingB : Symbol(things.ThingB, Decl(thingB.ts, 0, 0)) + diff --git a/tests/baselines/reference/declarationEmitAliasExportStar.types b/tests/baselines/reference/declarationEmitAliasExportStar.types new file mode 100644 index 00000000000..30be7c9ff28 --- /dev/null +++ b/tests/baselines/reference/declarationEmitAliasExportStar.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/thingB.ts === +export interface ThingB { } +>ThingB : ThingB + +=== tests/cases/compiler/things.ts === +export * from "./thingB"; +No type information for this code.=== tests/cases/compiler/index.ts === +import * as things from "./things"; +>things : typeof things + +export const thing2 = (param: things.ThingB) => null; +>thing2 : (param: things.ThingB) => any +>(param: things.ThingB) => null : (param: things.ThingB) => any +>param : things.ThingB +>things : any +>ThingB : things.ThingB +>null : null + diff --git a/tests/cases/compiler/declarationEmitAliasExportStar.ts b/tests/cases/compiler/declarationEmitAliasExportStar.ts new file mode 100644 index 00000000000..f556e35aa0b --- /dev/null +++ b/tests/cases/compiler/declarationEmitAliasExportStar.ts @@ -0,0 +1,8 @@ +// @declaration: true +// @filename: thingB.ts +export interface ThingB { } +// @filename: things.ts +export * from "./thingB"; +// @filename: index.ts +import * as things from "./things"; +export const thing2 = (param: things.ThingB) => null;