From 9f1079002355e57bc6d5459e3d654d41ac550b1b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 2 Mar 2018 16:23:10 -0800 Subject: [PATCH] Do not try to resolve alias for default symbol Fixes #22257 --- src/compiler/checker.ts | 3 +- ...rationEmitAliasFromIndirectFile.errors.txt | 31 ------------------- .../reference/exportDefaultProperty.symbols | 12 +++---- .../reference/exportDefaultProperty.types | 8 ++--- .../reference/exportDefaultProperty2.symbols | 6 ++-- 5 files changed, 15 insertions(+), 45 deletions(-) delete mode 100644 tests/baselines/reference/declarationEmitAliasFromIndirectFile.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fa2bd8d3b2e..7156615131c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2531,7 +2531,8 @@ namespace ts { // Check if symbol is any of the alias return forEachEntry(symbols, symbolFromSymbolTable => { if (symbolFromSymbolTable.flags & SymbolFlags.Alias - && symbolFromSymbolTable.escapedName !== "export=" + && symbolFromSymbolTable.escapedName !== InternalSymbolName.ExportEquals + && symbolFromSymbolTable.escapedName !== InternalSymbolName.Default && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && isExternalModule(getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || some(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration))) { diff --git a/tests/baselines/reference/declarationEmitAliasFromIndirectFile.errors.txt b/tests/baselines/reference/declarationEmitAliasFromIndirectFile.errors.txt deleted file mode 100644 index 22d258590e9..00000000000 --- a/tests/baselines/reference/declarationEmitAliasFromIndirectFile.errors.txt +++ /dev/null @@ -1,31 +0,0 @@ -tests/cases/compiler/app.ts(3,16): error TS2503: Cannot find namespace 'fp'. - - -==== tests/cases/compiler/locale.d.ts (0 errors) ==== - export type Locale = { - weekdays: { - shorthand: [string, string, string, string, string, string, string]; - longhand: [string, string, string, string, string, string, string]; - }; - }; - export type CustomLocale = { - weekdays: { - shorthand: [string, string, string, string, string, string, string]; - longhand: [string, string, string, string, string, string, string]; - }; - }; - export type key = "ar" | "bg"; - -==== tests/cases/compiler/instance.d.ts (0 errors) ==== - import { Locale, CustomLocale, key as LocaleKey } from "./locale"; - export interface FlatpickrFn { - l10ns: {[k in LocaleKey]?: CustomLocale } & { default: Locale }; - } - -==== tests/cases/compiler/app.ts (1 errors) ==== - import { FlatpickrFn } from "./instance"; - const fp = { l10ns: {} } as FlatpickrFn; - export default fp.l10ns; - ~~ -!!! error TS2503: Cannot find namespace 'fp'. - \ No newline at end of file diff --git a/tests/baselines/reference/exportDefaultProperty.symbols b/tests/baselines/reference/exportDefaultProperty.symbols index 709bf6c3f37..6f559438ba1 100644 --- a/tests/baselines/reference/exportDefaultProperty.symbols +++ b/tests/baselines/reference/exportDefaultProperty.symbols @@ -56,20 +56,20 @@ declare module "foobar" { >"foobar" : Symbol("foobar", Decl(declarations.d.ts, 5, 1)) export default foo.bar; ->foo.bar : Symbol(default, Decl(declarations.d.ts, 2, 22)) +>foo.bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) >foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) ->bar : Symbol(default, Decl(declarations.d.ts, 2, 22)) +>bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) } declare module "foobarx" { >"foobarx" : Symbol("foobarx", Decl(declarations.d.ts, 9, 1)) export default foo.bar.X; ->foo.bar.X : Symbol(default, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +>foo.bar.X : Symbol(foo.bar.X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) >foo.bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) >foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) >bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) ->X : Symbol(default, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +>X : Symbol(foo.bar.X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) } === tests/cases/compiler/a.ts === @@ -85,9 +85,9 @@ namespace A { >b : Symbol(b, Decl(a.ts, 2, 37)) } export default A.B; ->A.B : Symbol(default, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>A.B : Symbol(A.B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) >A : Symbol(A, Decl(a.ts, 0, 0)) ->B : Symbol(default, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>B : Symbol(A.B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) === tests/cases/compiler/b.ts === export default "foo".length; diff --git a/tests/baselines/reference/exportDefaultProperty.types b/tests/baselines/reference/exportDefaultProperty.types index c7439f7050c..55801a1d92d 100644 --- a/tests/baselines/reference/exportDefaultProperty.types +++ b/tests/baselines/reference/exportDefaultProperty.types @@ -59,9 +59,9 @@ declare module "foobar" { >"foobar" : typeof "foobar" export default foo.bar; ->foo.bar : typeof default +>foo.bar : typeof foo.bar >foo : typeof foo ->bar : typeof default +>bar : typeof foo.bar } declare module "foobarx" { @@ -89,9 +89,9 @@ namespace A { >0 : 0 } export default A.B; ->A.B : typeof default +>A.B : typeof A.B >A : typeof A ->B : typeof default +>B : typeof A.B === tests/cases/compiler/b.ts === export default "foo".length; diff --git a/tests/baselines/reference/exportDefaultProperty2.symbols b/tests/baselines/reference/exportDefaultProperty2.symbols index d3d7519aa94..1ad06f75ae9 100644 --- a/tests/baselines/reference/exportDefaultProperty2.symbols +++ b/tests/baselines/reference/exportDefaultProperty2.symbols @@ -5,7 +5,7 @@ class C { >C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) static B: number; ->B : Symbol(default, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>B : Symbol(C.B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) } namespace C { >C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) @@ -16,9 +16,9 @@ namespace C { } export default C.B; ->C.B : Symbol(default, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>C.B : Symbol(C.B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) >C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) ->B : Symbol(default, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>B : Symbol(C.B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) === tests/cases/compiler/b.ts === import B from "./a";