mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-14 16:56:06 -05:00
Never return undefined from getExportsOfModule (#17019)
This commit is contained in:
@@ -1770,7 +1770,7 @@ namespace ts {
|
||||
|
||||
function getExportsOfModule(moduleSymbol: Symbol): SymbolTable {
|
||||
const links = getSymbolLinks(moduleSymbol);
|
||||
return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol));
|
||||
return links.resolvedExports || (links.resolvedExports = getExportsOfModuleWorker(moduleSymbol));
|
||||
}
|
||||
|
||||
interface ExportCollisionTracker {
|
||||
@@ -1807,13 +1807,13 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getExportsForModule(moduleSymbol: Symbol): SymbolTable {
|
||||
function getExportsOfModuleWorker(moduleSymbol: Symbol): SymbolTable {
|
||||
const visitedSymbols: Symbol[] = [];
|
||||
|
||||
// A module defined by an 'export=' consists on one export that needs to be resolved
|
||||
moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
|
||||
|
||||
return visit(moduleSymbol) || moduleSymbol.exports;
|
||||
return visit(moduleSymbol) || emptySymbols;
|
||||
|
||||
// The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example,
|
||||
// module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error.
|
||||
|
||||
16
tests/cases/fourslash/completionList_getExportsOfModule.ts
Normal file
16
tests/cases/fourslash/completionList_getExportsOfModule.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// This used to cause a crash because we would ask for exports on `"x"`,
|
||||
// which would return undefined and cause a NPE. Now we return emptySymbol instead.
|
||||
// See GH#16610.
|
||||
|
||||
////declare module "x" {
|
||||
//// declare var x: number;
|
||||
//// export = x;
|
||||
////}
|
||||
////
|
||||
////let y: /**/
|
||||
|
||||
goTo.marker();
|
||||
// This is just a dummy test to cause `getCompletionsAtPosition` to be called.
|
||||
verify.not.completionListContains("x");
|
||||
Reference in New Issue
Block a user