Skip to content

Commit 6587980

Browse files
authored
Fix globalThis completions (#30441)
* Fix, but with test not quite right * Add missing completions to test * Remove out-of-date comment
1 parent cabf72b commit 6587980

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/services/completions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,9 @@ namespace ts.Completions {
890890
}
891891

892892
// If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods).
893-
if (!isTypeLocation && symbol.declarations.some(d => d.kind !== SyntaxKind.SourceFile && d.kind !== SyntaxKind.ModuleDeclaration && d.kind !== SyntaxKind.EnumDeclaration)) {
893+
if (!isTypeLocation &&
894+
symbol.declarations &&
895+
symbol.declarations.some(d => d.kind !== SyntaxKind.SourceFile && d.kind !== SyntaxKind.ModuleDeclaration && d.kind !== SyntaxKind.EnumDeclaration)) {
894896
addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node));
895897
}
896898

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////globalThis./**/
4+
5+
verify.completions({
6+
marker: "",
7+
exact: [
8+
{ name: "globalThis", kind: "module" },
9+
...completion.globalsVars,
10+
{ name: "undefined", kind: "var" }
11+
]
12+
});

0 commit comments

Comments
 (0)