Skip to content

Commit

Permalink
Fix globalThis completions (microsoft#30441)
Browse files Browse the repository at this point in the history
* Fix, but with test not quite right

* Add missing completions to test

* Remove out-of-date comment
  • Loading branch information
sandersn authored Mar 16, 2019
1 parent cabf72b commit 6587980
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
12 changes: 12 additions & 0 deletions tests/cases/fourslash/completionAfterGlobalThis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>

////globalThis./**/

verify.completions({
marker: "",
exact: [
{ name: "globalThis", kind: "module" },
...completion.globalsVars,
{ name: "undefined", kind: "var" }
]
});

0 comments on commit 6587980

Please sign in to comment.