From c522f379b20b2be70873ca6b61dd8be7be1c76bf Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 15:02:32 -0700 Subject: [PATCH] Update assertion: symbol in union type may be a Function (#18483) --- src/services/symbolDisplay.ts | 3 ++- .../cases/fourslash/quickInfoUnionOfNamespaces.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/quickInfoUnionOfNamespaces.ts diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 05c451cc3f3..ad8e7ddf975 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -61,7 +61,8 @@ namespace ts.SymbolDisplay { if (rootSymbolFlags & (SymbolFlags.PropertyOrAccessor | SymbolFlags.Variable)) { return ScriptElementKind.memberVariableElement; } - Debug.assert(!!(rootSymbolFlags & SymbolFlags.Method)); + // May be a Function if this was from `typeof N` with `namespace N { function f();. }`. + Debug.assert(!!(rootSymbolFlags & (SymbolFlags.Method | SymbolFlags.Function))); }); if (!unionPropertyKind) { // If this was union of all methods, diff --git a/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts b/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts new file mode 100644 index 00000000000..9b2431092e7 --- /dev/null +++ b/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts @@ -0,0 +1,15 @@ +// See GH#18461 + +/// + +////declare const x: typeof A | typeof B; +////x./**/f; +//// +////namespace A { +//// export function f() {} +////} +////namespace B { +//// export function f() {} +////} + +verify.quickInfoAt("", "(method) f(): void");