diff --git a/src/services/completions.ts b/src/services/completions.ts index 5cdaca020c..ad5b6bbf8e 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -890,7 +890,9 @@ namespace ts.Completions { } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(d => d.kind !== SyntaxKind.SourceFile && d.kind !== SyntaxKind.ModuleDeclaration && d.kind !== SyntaxKind.EnumDeclaration)) { + if (!isTypeLocation && + symbol.declarations && + symbol.declarations.some(d => d.kind !== SyntaxKind.SourceFile && d.kind !== SyntaxKind.ModuleDeclaration && d.kind !== SyntaxKind.EnumDeclaration)) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } diff --git a/tests/cases/fourslash/completionAfterGlobalThis.ts b/tests/cases/fourslash/completionAfterGlobalThis.ts new file mode 100644 index 0000000000..f5241d93c6 --- /dev/null +++ b/tests/cases/fourslash/completionAfterGlobalThis.ts @@ -0,0 +1,12 @@ +/// + +////globalThis./**/ + +verify.completions({ + marker: "", + exact: [ + { name: "globalThis", kind: "module" }, + ...completion.globalsVars, + { name: "undefined", kind: "var" } + ] +});