From a5484ddd090fd49e82d5c7612b0c0b68a71d7920 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 7 Jan 2019 11:34:35 -0800 Subject: [PATCH 01/19] Restore original code from bind-toplevel-this With one or two additional comments --- src/compiler/binder.ts | 9 +++++++-- src/compiler/checker.ts | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7216af4e8172e..87ccfd1569172 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2462,8 +2462,13 @@ namespace ts { declareSymbol(symbolTable, containingClass.symbol, node, SymbolFlags.Property, SymbolFlags.None, /*isReplaceableByMethod*/ true); break; case SyntaxKind.SourceFile: - // this.foo assignment in a source file - // Do not bind. It would be nice to support this someday though. + // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script + if ((thisContainer as SourceFile).commonJsModuleIndicator) { + declareSymbol(thisContainer.symbol.exports!, thisContainer.symbol, node, SymbolFlags.Property | SymbolFlags.ExportValue, SymbolFlags.None); + } + else { + declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); + } break; default: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index de44e8bb37ca7..426574c3258ef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -519,6 +519,7 @@ namespace ts { let deferredGlobalExcludeSymbol: Symbol; let deferredGlobalPickSymbol: Symbol; let deferredGlobalBigIntType: ObjectType; + let deferredGlobalThisType: ObjectType; // (unbound) `window` has type Window & globalThis; `this` and `globalThis` and `global` have type GlobalThis const allPotentiallyUnusedIdentifiers = createMap(); // key is file name @@ -8976,6 +8977,13 @@ namespace ts { return symbol && getTypeOfGlobalSymbol(symbol, arity); } + function getGlobalThisType() { + // TODO: Maybe should allow d.ts file to override this? Probably? Or just Window? + return deferredGlobalThisType || + (deferredGlobalThisType = createAnonymousType(undefined, globals, emptyArray, emptyArray, createIndexInfo(anyType, /*isReadonly*/ false), undefined)) || + emptyObjectType; + } + function getGlobalExtractSymbol(): Symbol { return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract" as __String, SymbolFlags.TypeAlias, Diagnostics.Cannot_find_global_type_0)!); // TODO: GH#18217 } @@ -16759,6 +16767,16 @@ namespace ts { return getFlowTypeOfReference(node, type); } } + if (isSourceFile(container)) { + // look up in the source file's locals or exports + if (container.commonJsModuleIndicator) { + const fileSymbol = getSymbolOfNode(container); + return fileSymbol && getTypeOfSymbol(fileSymbol); + } + else { + return getGlobalThisType(); + } + } } function getClassNameFromPrototypeMethod(container: Node) { From f650492e2c9031688f7cf00951b6804f33d9b461 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 8 Jan 2019 09:57:39 -0800 Subject: [PATCH 02/19] Working in JS, but the symbol is not right. Still need to 1. Make it work in Typescript. 2. Add test (and make them work) for the other uses of GlobalThis: window, globalThis, etc. --- src/compiler/checker.ts | 25 +++++++++-------- .../reference/topLevelThisAssignment.symbols | 27 ++++++++++++++----- .../reference/topLevelThisAssignment.types | 22 +++++++-------- .../typeFromPropertyAssignment23.symbols | 2 ++ .../typeFromPropertyAssignment23.types | 2 +- .../typeFromPropertyAssignment9.symbols | 5 ++++ .../typeFromPropertyAssignment9.types | 10 +++---- 7 files changed, 58 insertions(+), 35 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 426574c3258ef..081624add7d14 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8978,9 +8978,11 @@ namespace ts { } function getGlobalThisType() { - // TODO: Maybe should allow d.ts file to override this? Probably? Or just Window? + // TODO: Maybe should allow d.ts file to override this via getGlobalTypeSymbol? Probably? Or just Window? + const t = createObjectType(ObjectFlags.Interface, createSymbol(SymbolFlags.Type, "GlobalThis" as __String)); + setStructuredTypeMembers(t, globals, emptyArray, emptyArray, createIndexInfo(anyType, /*isReadonly*/ false), undefined); return deferredGlobalThisType || - (deferredGlobalThisType = createAnonymousType(undefined, globals, emptyArray, emptyArray, createIndexInfo(anyType, /*isReadonly*/ false), undefined)) || + (deferredGlobalThisType = t) || emptyObjectType; } @@ -16766,15 +16768,16 @@ namespace ts { if (type && type !== errorType) { return getFlowTypeOfReference(node, type); } - } - if (isSourceFile(container)) { - // look up in the source file's locals or exports - if (container.commonJsModuleIndicator) { - const fileSymbol = getSymbolOfNode(container); - return fileSymbol && getTypeOfSymbol(fileSymbol); - } - else { - return getGlobalThisType(); + if (isSourceFile(container)) { + // TODO: Should go outside the isInJS check; I need to provide a way to print the type name first, though. + // look up in the source file's locals or exports + if (container.commonJsModuleIndicator) { + const fileSymbol = getSymbolOfNode(container); + return fileSymbol && getTypeOfSymbol(fileSymbol); + } + else { + return getGlobalThisType(); + } } } } diff --git a/tests/baselines/reference/topLevelThisAssignment.symbols b/tests/baselines/reference/topLevelThisAssignment.symbols index e9b94983bf287..b8855fb16c5af 100644 --- a/tests/baselines/reference/topLevelThisAssignment.symbols +++ b/tests/baselines/reference/topLevelThisAssignment.symbols @@ -1,10 +1,23 @@ === tests/cases/conformance/salsa/a.js === this.a = 10; -No type information for this code.this.a; -No type information for this code.a; -No type information for this code. -No type information for this code.=== tests/cases/conformance/salsa/b.js === +>this.a : Symbol(a, Decl(a.js, 0, 0)) +>this : Symbol(GlobalThis) +>a : Symbol(a, Decl(a.js, 0, 0)) + this.a; -No type information for this code.a; -No type information for this code. -No type information for this code. \ No newline at end of file +>this.a : Symbol(a, Decl(a.js, 0, 0)) +>this : Symbol(GlobalThis) +>a : Symbol(a, Decl(a.js, 0, 0)) + +a; +>a : Symbol(a, Decl(a.js, 0, 0)) + +=== tests/cases/conformance/salsa/b.js === +this.a; +>this.a : Symbol(a, Decl(a.js, 0, 0)) +>this : Symbol(GlobalThis) +>a : Symbol(a, Decl(a.js, 0, 0)) + +a; +>a : Symbol(a, Decl(a.js, 0, 0)) + diff --git a/tests/baselines/reference/topLevelThisAssignment.types b/tests/baselines/reference/topLevelThisAssignment.types index 92bb458b41f46..bd68e42785d1f 100644 --- a/tests/baselines/reference/topLevelThisAssignment.types +++ b/tests/baselines/reference/topLevelThisAssignment.types @@ -1,25 +1,25 @@ === tests/cases/conformance/salsa/a.js === this.a = 10; >this.a = 10 : 10 ->this.a : any ->this : any ->a : any +>this.a : number +>this : GlobalThis +>a : number >10 : 10 this.a; ->this.a : any ->this : any ->a : any +>this.a : number +>this : GlobalThis +>a : number a; ->a : error +>a : number === tests/cases/conformance/salsa/b.js === this.a; ->this.a : any ->this : any ->a : any +>this.a : number +>this : GlobalThis +>a : number a; ->a : error +>a : number diff --git a/tests/baselines/reference/typeFromPropertyAssignment23.symbols b/tests/baselines/reference/typeFromPropertyAssignment23.symbols index 2ba8651ea535e..bd8b61e2666b8 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment23.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment23.symbols @@ -38,6 +38,8 @@ D.prototype.foo = () => { >foo : Symbol(D.foo, Decl(a.js, 14, 21)) this.n = 'not checked, so no error' +>this : Symbol(GlobalThis) +>n : Symbol(n, Decl(a.js, 15, 26)) } // post-class prototype assignments are trying to show that these properties are abstract diff --git a/tests/baselines/reference/typeFromPropertyAssignment23.types b/tests/baselines/reference/typeFromPropertyAssignment23.types index 4e540e3962fda..6c459adc958e1 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment23.types +++ b/tests/baselines/reference/typeFromPropertyAssignment23.types @@ -46,7 +46,7 @@ D.prototype.foo = () => { this.n = 'not checked, so no error' >this.n = 'not checked, so no error' : "not checked, so no error" >this.n : any ->this : any +>this : GlobalThis >n : any >'not checked, so no error' : "not checked, so no error" } diff --git a/tests/baselines/reference/typeFromPropertyAssignment9.symbols b/tests/baselines/reference/typeFromPropertyAssignment9.symbols index 27188c71b32db..f44063b765b63 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment9.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment9.symbols @@ -118,6 +118,11 @@ min.nest = this.min.nest || function () { }; >min.nest : Symbol(min.nest, Decl(a.js, 29, 27), Decl(a.js, 31, 4)) >min : Symbol(min, Decl(a.js, 29, 3), Decl(a.js, 29, 27), Decl(a.js, 30, 44)) >nest : Symbol(min.nest, Decl(a.js, 29, 27), Decl(a.js, 31, 4)) +>this.min.nest : Symbol(min.nest, Decl(a.js, 29, 27), Decl(a.js, 31, 4)) +>this.min : Symbol(min, Decl(a.js, 29, 3), Decl(a.js, 29, 27), Decl(a.js, 30, 44)) +>this : Symbol(GlobalThis) +>min : Symbol(min, Decl(a.js, 29, 3), Decl(a.js, 29, 27), Decl(a.js, 30, 44)) +>nest : Symbol(min.nest, Decl(a.js, 29, 27), Decl(a.js, 31, 4)) min.nest.other = self.min.nest.other || class { }; >min.nest.other : Symbol(min.nest.other, Decl(a.js, 30, 44)) diff --git a/tests/baselines/reference/typeFromPropertyAssignment9.types b/tests/baselines/reference/typeFromPropertyAssignment9.types index b212f12bb17bd..6be91c95a1c5c 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment9.types +++ b/tests/baselines/reference/typeFromPropertyAssignment9.types @@ -157,11 +157,11 @@ min.nest = this.min.nest || function () { }; >min : typeof min >nest : { (): void; other: typeof other; } >this.min.nest || function () { } : { (): void; other: typeof other; } ->this.min.nest : any ->this.min : any ->this : any ->min : any ->nest : any +>this.min.nest : { (): void; other: typeof other; } +>this.min : typeof min +>this : GlobalThis +>min : typeof min +>nest : { (): void; other: typeof other; } >function () { } : { (): void; other: typeof other; } min.nest.other = self.min.nest.other || class { }; From 4bab559567d70b6d61591b07db65346ce798d43b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 8 Jan 2019 10:32:36 -0800 Subject: [PATCH 03/19] Check in TS also; update some tests Lots of tests still fail, but all but 1 change so far has been correct. --- src/compiler/checker.ts | 19 ++++++------ .../compoundAssignmentLHSIsValue.errors.txt | 8 ++--- ...onentiationAssignmentLHSIsValue.errors.txt | 8 ++--- .../emitArrowFunctionThisCapturing.errors.txt | 20 +++++++++++++ .../emitArrowFunctionThisCapturing.symbols | 7 +++++ .../emitArrowFunctionThisCapturing.types | 6 ++-- ...itArrowFunctionThisCapturingES6.errors.txt | 20 +++++++++++++ .../emitArrowFunctionThisCapturingES6.symbols | 7 +++++ .../emitArrowFunctionThisCapturingES6.types | 6 ++-- .../reference/globalThisVarDeclaration.js | 20 +++++++++++++ .../globalThisVarDeclaration.symbols | 28 +++++++++++++++++ .../reference/globalThisVarDeclaration.types | 30 +++++++++++++++++++ .../reference/parserForStatement8.errors.txt | 4 +-- .../parserUnaryExpression1.errors.txt | 4 +-- .../thisInInvalidContexts.errors.txt | 5 +++- ...InInvalidContextsExternalModule.errors.txt | 5 +++- .../expressions/thisKeyword/typeOfThis.ts | 12 ++++---- .../salsa/topLevelThisAssignment.ts | 1 + 18 files changed, 174 insertions(+), 36 deletions(-) create mode 100644 tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt create mode 100644 tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt create mode 100644 tests/baselines/reference/globalThisVarDeclaration.js create mode 100644 tests/baselines/reference/globalThisVarDeclaration.symbols create mode 100644 tests/baselines/reference/globalThisVarDeclaration.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 081624add7d14..18d4098f661bd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16768,16 +16768,15 @@ namespace ts { if (type && type !== errorType) { return getFlowTypeOfReference(node, type); } - if (isSourceFile(container)) { - // TODO: Should go outside the isInJS check; I need to provide a way to print the type name first, though. - // look up in the source file's locals or exports - if (container.commonJsModuleIndicator) { - const fileSymbol = getSymbolOfNode(container); - return fileSymbol && getTypeOfSymbol(fileSymbol); - } - else { - return getGlobalThisType(); - } + } + if (isSourceFile(container)) { + // look up in the source file's locals or exports + if (container.commonJsModuleIndicator) { + const fileSymbol = getSymbolOfNode(container); + return fileSymbol && getTypeOfSymbol(fileSymbol); + } + else { + return getGlobalThisType(); } } } diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt index 8a13314800787..2c22361bfd637 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt @@ -6,7 +6,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(16,9): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(21,5): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(22,5): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(25,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(25,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(26,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(30,1): error TS2539: Cannot assign to 'M' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(31,1): error TS2539: Cannot assign to 'M' because it is not a variable. @@ -45,7 +45,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(88,11): error TS1005: ';' expected. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(91,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(92,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(95,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(95,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(96,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(97,2): error TS2539: Cannot assign to 'M' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(98,2): error TS2539: Cannot assign to 'M' because it is not a variable. @@ -119,7 +119,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa this *= value; ~~~~ -!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. this += value; ~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -267,7 +267,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa // parentheses, the containted expression is value (this) *= value; ~~~~~~ -!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. (this) += value; ~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt index e3c9918aa4b46..37e9ca6be1de0 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(10,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(13,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(18,5): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(21,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(21,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(25,1): error TS2539: Cannot assign to 'M' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(27,1): error TS2539: Cannot assign to 'C' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(30,1): error TS2539: Cannot assign to 'E' because it is not a variable. @@ -22,7 +22,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(65,21): error TS1128: Declaration or statement expected. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(66,11): error TS1005: ';' expected. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(69,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(72,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(72,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(73,2): error TS2539: Cannot assign to 'M' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(74,2): error TS2539: Cannot assign to 'C' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(75,2): error TS2539: Cannot assign to 'E' because it is not a variable. @@ -70,7 +70,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm this **= value; ~~~~ -!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. // identifiers: module, class, enum, function module M { export var a; } @@ -161,7 +161,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm // parentheses, the containted expression is value (this) **= value; ~~~~~~ -!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. (M) **= value; ~ !!! error TS2539: Cannot assign to 'M' because it is not a variable. diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt b/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt new file mode 100644 index 0000000000000..2030b47b3ec6e --- /dev/null +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturing.ts(6,10): error TS2540: Cannot assign to 'name' because it is a read-only property. + + +==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturing.ts (1 errors) ==== + var f1 = () => { + this.age = 10 + }; + + var f2 = (x: string) => { + this.name = x + ~~~~ +!!! error TS2540: Cannot assign to 'name' because it is a read-only property. + } + + function foo(func: () => boolean) { } + foo(() => { + this.age = 100; + return true; + }); + \ No newline at end of file diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols b/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols index ad62a0df5be92..849488aa30d70 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols @@ -3,6 +3,8 @@ var f1 = () => { >f1 : Symbol(f1, Decl(emitArrowFunctionThisCapturing.ts, 0, 3)) this.age = 10 +>this : Symbol(GlobalThis) + }; var f2 = (x: string) => { @@ -10,6 +12,9 @@ var f2 = (x: string) => { >x : Symbol(x, Decl(emitArrowFunctionThisCapturing.ts, 4, 10)) this.name = x +>this.name : Symbol(name, Decl(lib.dom.d.ts, --, --)) +>this : Symbol(GlobalThis) +>name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(emitArrowFunctionThisCapturing.ts, 4, 10)) } @@ -21,6 +26,8 @@ foo(() => { >foo : Symbol(foo, Decl(emitArrowFunctionThisCapturing.ts, 6, 1)) this.age = 100; +>this : Symbol(GlobalThis) + return true; }); diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.types b/tests/baselines/reference/emitArrowFunctionThisCapturing.types index 0ef27791d1765..647005b36135f 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.types +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.types @@ -6,7 +6,7 @@ var f1 = () => { this.age = 10 >this.age = 10 : 10 >this.age : any ->this : any +>this : GlobalThis >age : any >10 : 10 @@ -20,7 +20,7 @@ var f2 = (x: string) => { this.name = x >this.name = x : string >this.name : any ->this : any +>this : GlobalThis >name : any >x : string } @@ -37,7 +37,7 @@ foo(() => { this.age = 100; >this.age = 100 : 100 >this.age : any ->this : any +>this : GlobalThis >age : any >100 : 100 diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt new file mode 100644 index 0000000000000..fb644a4127e47 --- /dev/null +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturingES6.ts(6,10): error TS2540: Cannot assign to 'name' because it is a read-only property. + + +==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturingES6.ts (1 errors) ==== + var f1 = () => { + this.age = 10 + }; + + var f2 = (x: string) => { + this.name = x + ~~~~ +!!! error TS2540: Cannot assign to 'name' because it is a read-only property. + } + + function foo(func: () => boolean){ } + foo(() => { + this.age = 100; + return true; + }); + \ No newline at end of file diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols index 0e8855dd680c5..cdbd62ce718e9 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols @@ -3,6 +3,8 @@ var f1 = () => { >f1 : Symbol(f1, Decl(emitArrowFunctionThisCapturingES6.ts, 0, 3)) this.age = 10 +>this : Symbol(GlobalThis) + }; var f2 = (x: string) => { @@ -10,6 +12,9 @@ var f2 = (x: string) => { >x : Symbol(x, Decl(emitArrowFunctionThisCapturingES6.ts, 4, 10)) this.name = x +>this.name : Symbol(name, Decl(lib.dom.d.ts, --, --)) +>this : Symbol(GlobalThis) +>name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(emitArrowFunctionThisCapturingES6.ts, 4, 10)) } @@ -21,6 +26,8 @@ foo(() => { >foo : Symbol(foo, Decl(emitArrowFunctionThisCapturingES6.ts, 6, 1)) this.age = 100; +>this : Symbol(GlobalThis) + return true; }); diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types index 3c20bfd195cd2..b938692030f0d 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types @@ -6,7 +6,7 @@ var f1 = () => { this.age = 10 >this.age = 10 : 10 >this.age : any ->this : any +>this : GlobalThis >age : any >10 : 10 @@ -20,7 +20,7 @@ var f2 = (x: string) => { this.name = x >this.name = x : string >this.name : any ->this : any +>this : GlobalThis >name : any >x : string } @@ -37,7 +37,7 @@ foo(() => { this.age = 100; >this.age = 100 : 100 >this.age : any ->this : any +>this : GlobalThis >age : any >100 : 100 diff --git a/tests/baselines/reference/globalThisVarDeclaration.js b/tests/baselines/reference/globalThisVarDeclaration.js new file mode 100644 index 0000000000000..60f52490c0154 --- /dev/null +++ b/tests/baselines/reference/globalThisVarDeclaration.js @@ -0,0 +1,20 @@ +//// [tests/cases/conformance/es2019/globalThisVarDeclaration.ts] //// + +//// [b.js] +var a = 10; +this.a; +this.b; + +//// [actual.ts] +var b = 10; +this.a; +this.b; + + +//// [output.js] +var a = 10; +this.a; +this.b; +var b = 10; +this.a; +this.b; diff --git a/tests/baselines/reference/globalThisVarDeclaration.symbols b/tests/baselines/reference/globalThisVarDeclaration.symbols new file mode 100644 index 0000000000000..5b22663f545b6 --- /dev/null +++ b/tests/baselines/reference/globalThisVarDeclaration.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/es2019/b.js === +var a = 10; +>a : Symbol(a, Decl(b.js, 0, 3)) + +this.a; +>this.a : Symbol(a, Decl(b.js, 0, 3)) +>this : Symbol(GlobalThis) +>a : Symbol(a, Decl(b.js, 0, 3)) + +this.b; +>this.b : Symbol(b, Decl(actual.ts, 0, 3)) +>this : Symbol(GlobalThis) +>b : Symbol(b, Decl(actual.ts, 0, 3)) + +=== tests/cases/conformance/es2019/actual.ts === +var b = 10; +>b : Symbol(b, Decl(actual.ts, 0, 3)) + +this.a; +>this.a : Symbol(a, Decl(b.js, 0, 3)) +>this : Symbol(GlobalThis) +>a : Symbol(a, Decl(b.js, 0, 3)) + +this.b; +>this.b : Symbol(b, Decl(actual.ts, 0, 3)) +>this : Symbol(GlobalThis) +>b : Symbol(b, Decl(actual.ts, 0, 3)) + diff --git a/tests/baselines/reference/globalThisVarDeclaration.types b/tests/baselines/reference/globalThisVarDeclaration.types new file mode 100644 index 0000000000000..5a0d1bbb34906 --- /dev/null +++ b/tests/baselines/reference/globalThisVarDeclaration.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/es2019/b.js === +var a = 10; +>a : number +>10 : 10 + +this.a; +>this.a : number +>this : GlobalThis +>a : number + +this.b; +>this.b : number +>this : GlobalThis +>b : number + +=== tests/cases/conformance/es2019/actual.ts === +var b = 10; +>b : number +>10 : 10 + +this.a; +>this.a : number +>this : GlobalThis +>a : number + +this.b; +>this.b : number +>this : GlobalThis +>b : number + diff --git a/tests/baselines/reference/parserForStatement8.errors.txt b/tests/baselines/reference/parserForStatement8.errors.txt index 21ea55e3b09f1..ac04ed5e5480a 100644 --- a/tests/baselines/reference/parserForStatement8.errors.txt +++ b/tests/baselines/reference/parserForStatement8.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement8.ts(1,6): error TS2406: The left-hand side of a 'for...in' statement must be a variable or a property access. +tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement8.ts(1,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement8.ts(1,14): error TS2304: Cannot find name 'b'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement8.ts (2 errors) ==== for (this in b) { ~~~~ -!!! error TS2406: The left-hand side of a 'for...in' statement must be a variable or a property access. +!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. ~ !!! error TS2304: Cannot find name 'b'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserUnaryExpression1.errors.txt b/tests/baselines/reference/parserUnaryExpression1.errors.txt index 278960d53f31b..4001996551248 100644 --- a/tests/baselines/reference/parserUnaryExpression1.errors.txt +++ b/tests/baselines/reference/parserUnaryExpression1.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/Expressions/parserUnaryExpression1.ts(1,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/parser/ecmascript5/Expressions/parserUnaryExpression1.ts(1,3): error TS2356: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type. ==== tests/cases/conformance/parser/ecmascript5/Expressions/parserUnaryExpression1.ts (1 errors) ==== ++this; ~~~~ -!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. \ No newline at end of file +!!! error TS2356: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/thisInInvalidContexts.errors.txt b/tests/baselines/reference/thisInInvalidContexts.errors.txt index 3581d6d6f29bc..f0152f701a8e6 100644 --- a/tests/baselines/reference/thisInInvalidContexts.errors.txt +++ b/tests/baselines/reference/thisInInvalidContexts.errors.txt @@ -3,11 +3,12 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(14,15): tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(22,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS2507: Type 'GlobalThis' is not a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): error TS2332: 'this' cannot be referenced in current location. -==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts (7 errors) ==== +==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts (8 errors) ==== //'this' in static member initializer class ErrClass1 { static t = this; // Error @@ -56,6 +57,8 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. class ErrClass3 extends this { + ~~~~ +!!! error TS2507: Type 'GlobalThis' is not a constructor function type. } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt index f89b28978922a..54d492cb51291 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt @@ -3,11 +3,12 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(22,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS2507: Type 'GlobalThis' is not a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(45,9): error TS2332: 'this' cannot be referenced in current location. -==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (7 errors) ==== +==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (8 errors) ==== //'this' in static member initializer class ErrClass1 { static t = this; // Error @@ -56,6 +57,8 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. class ErrClass3 extends this { + ~~~~ +!!! error TS2507: Type 'GlobalThis' is not a constructor function type. } diff --git a/tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts b/tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts index 4e9da72af6dfd..64f6288ef2e50 100644 --- a/tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts +++ b/tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts @@ -158,19 +158,19 @@ var q1 = function (s = this) { this.spaaaaace = 4; } -//type of 'this' in a fat arrow expression param list is Any +//type of 'this' in a fat arrow expression param list is GlobalThis var q2 = (s = this) => { - var s: any; + var s: GlobalThis; s.spaaaaaaace = 4; - //type of 'this' in a fat arrow expression body is Any - var t: any; + //type of 'this' in a fat arrow expression body is GlobalThis + var t: GlobalThis; var t = this; this.spaaaaace = 4; } -//type of 'this' in global module is Any -var t: any; +//type of 'this' in global module is GlobalThis +var t: GlobalThis; var t = this; this.spaaaaace = 4; diff --git a/tests/cases/conformance/salsa/topLevelThisAssignment.ts b/tests/cases/conformance/salsa/topLevelThisAssignment.ts index 162bed0c30fc7..aed2f86710803 100644 --- a/tests/cases/conformance/salsa/topLevelThisAssignment.ts +++ b/tests/cases/conformance/salsa/topLevelThisAssignment.ts @@ -1,5 +1,6 @@ // @out: output.js // @allowJs: true +// @checkJs: true // @Filename: a.js this.a = 10; this.a; From d62a8d8a36aa09047a534e16036fd0285193829d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 8 Jan 2019 11:20:21 -0800 Subject: [PATCH 04/19] Update baselines A couple of tests still fail and need to be fixed. --- .../reference/assignmentLHSIsValue.symbols | 2 + .../reference/assignmentLHSIsValue.types | 6 +-- .../castExpressionParentheses.symbols | 4 ++ .../reference/castExpressionParentheses.types | 4 +- ...sionThisExpressionAndAliasInGlobal.symbols | 1 + ...lisionThisExpressionAndAliasInGlobal.types | 6 +-- ...sExpressionAndAmbientClassInGlobal.symbols | 1 + ...hisExpressionAndAmbientClassInGlobal.types | 6 +-- ...hisExpressionAndAmbientVarInGlobal.symbols | 1 + ...nThisExpressionAndAmbientVarInGlobal.types | 6 +-- ...sionThisExpressionAndClassInGlobal.symbols | 1 + ...lisionThisExpressionAndClassInGlobal.types | 6 +-- ...isionThisExpressionAndEnumInGlobal.symbols | 1 + ...llisionThisExpressionAndEnumInGlobal.types | 6 +-- ...nThisExpressionAndFunctionInGlobal.symbols | 1 + ...ionThisExpressionAndFunctionInGlobal.types | 6 +-- ...nThisExpressionAndLocalVarInLambda.symbols | 1 + ...ionThisExpressionAndLocalVarInLambda.types | 2 +- ...ionThisExpressionAndModuleInGlobal.symbols | 1 + ...isionThisExpressionAndModuleInGlobal.types | 6 +-- ...lisionThisExpressionAndVarInGlobal.symbols | 1 + ...ollisionThisExpressionAndVarInGlobal.types | 6 +-- .../reference/commentsInterface.symbols | 6 +++ .../reference/commentsInterface.types | 12 +++--- .../compoundAssignmentLHSIsValue.symbols | 4 ++ .../compoundAssignmentLHSIsValue.types | 12 +++--- ...ExponentiationAssignmentLHSIsValue.symbols | 2 + ...ndExponentiationAssignmentLHSIsValue.types | 6 +-- .../computedPropertyNames20_ES5.symbols | 1 + .../computedPropertyNames20_ES5.types | 2 +- .../computedPropertyNames20_ES6.symbols | 1 + .../computedPropertyNames20_ES6.types | 2 +- ...ructorWithIncompleteTypeAnnotation.symbols | 1 + ...structorWithIncompleteTypeAnnotation.types | 2 +- ...CapturingThisInTupleDestructuring1.symbols | 3 ++ ...itCapturingThisInTupleDestructuring1.types | 6 +-- .../reference/globalThisCapture.symbols | 3 ++ .../reference/globalThisCapture.types | 10 ++--- .../reference/implicitAnyInCatch.symbols | 1 + .../reference/implicitAnyInCatch.types | 2 +- ...neJsxFactoryDeclarationsLocalTypes.symbols | 1 + ...lineJsxFactoryDeclarationsLocalTypes.types | 2 +- ...jsxAttributeWithoutExpressionReact.symbols | 1 + .../jsxAttributeWithoutExpressionReact.types | 2 +- .../reference/jsxReactTestSuite.symbols | 5 +++ .../reference/jsxReactTestSuite.types | 6 +-- ...pertyAccessAndArrowFunctionIndent1.symbols | 3 ++ ...ropertyAccessAndArrowFunctionIndent1.types | 4 +- .../reference/noImplicitThisFunctions.symbols | 2 + .../reference/noImplicitThisFunctions.types | 10 ++--- .../parserCommaInTypeMemberList2.symbols | 1 + .../parserCommaInTypeMemberList2.types | 2 +- .../parserConditionalExpression1.symbols | 5 ++- .../parserConditionalExpression1.types | 6 +-- .../reference/parserForStatement8.symbols | 4 +- .../reference/parserForStatement8.types | 2 +- .../parserModifierOnStatementInBlock2.symbols | 1 + .../parserModifierOnStatementInBlock2.types | 4 +- .../reference/parserStrictMode16.symbols | 11 ++--- .../reference/parserStrictMode16.types | 2 +- .../reference/parserUnaryExpression1.symbols | 3 +- .../reference/parserUnaryExpression1.types | 2 +- .../reference/propertyWrappedInTry.symbols | 1 + .../reference/propertyWrappedInTry.types | 2 +- .../reference/thisInInvalidContexts.symbols | 1 + .../reference/thisInInvalidContexts.types | 2 +- ...hisInInvalidContextsExternalModule.symbols | 1 + .../thisInInvalidContextsExternalModule.types | 2 +- .../reference/thisTypeInFunctions.symbols | 11 +++++ .../reference/thisTypeInFunctions.types | 40 +++++++++---------- .../thisTypeInFunctionsNegative.symbols | 6 +++ .../thisTypeInFunctionsNegative.types | 12 +++--- .../reference/topLevelLambda2.symbols | 3 ++ .../baselines/reference/topLevelLambda2.types | 8 ++-- .../reference/topLevelLambda3.symbols | 3 ++ .../baselines/reference/topLevelLambda3.types | 6 +-- .../reference/topLevelLambda4.symbols | 3 ++ .../baselines/reference/topLevelLambda4.types | 10 ++--- .../tsxAttributeResolution15.symbols | 1 + .../reference/tsxAttributeResolution15.types | 2 +- .../tsxSpreadAttributesResolution4.symbols | 1 + .../tsxSpreadAttributesResolution4.types | 2 +- .../reference/unknownSymbols1.symbols | 1 + .../baselines/reference/unknownSymbols1.types | 2 +- .../reference/wrappedIncovations1.symbols | 1 + .../reference/wrappedIncovations1.types | 2 +- .../reference/wrappedIncovations2.symbols | 1 + .../reference/wrappedIncovations2.types | 2 +- 88 files changed, 223 insertions(+), 133 deletions(-) diff --git a/tests/baselines/reference/assignmentLHSIsValue.symbols b/tests/baselines/reference/assignmentLHSIsValue.symbols index 17925257dfb4b..4fc74db7ab825 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.symbols +++ b/tests/baselines/reference/assignmentLHSIsValue.symbols @@ -27,6 +27,7 @@ function foo() { this = value; } >value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) this = value; +>this : Symbol(GlobalThis) >value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) // identifiers: module, class, enum, function @@ -116,6 +117,7 @@ foo() = value; // parentheses, the containted expression is value (this) = value; +>this : Symbol(GlobalThis) >value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) (M) = value; diff --git a/tests/baselines/reference/assignmentLHSIsValue.types b/tests/baselines/reference/assignmentLHSIsValue.types index b35c15bfe2365..e7b66a559f94b 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.types +++ b/tests/baselines/reference/assignmentLHSIsValue.types @@ -33,7 +33,7 @@ function foo() { this = value; } this = value; >this = value : any ->this : any +>this : GlobalThis >value : any // identifiers: module, class, enum, function @@ -159,8 +159,8 @@ foo() = value; // parentheses, the containted expression is value (this) = value; >(this) = value : any ->(this) : any ->this : any +>(this) : GlobalThis +>this : GlobalThis >value : any (M) = value; diff --git a/tests/baselines/reference/castExpressionParentheses.symbols b/tests/baselines/reference/castExpressionParentheses.symbols index df7ef6a1f2f7f..3dcf8828deb38 100644 --- a/tests/baselines/reference/castExpressionParentheses.symbols +++ b/tests/baselines/reference/castExpressionParentheses.symbols @@ -21,7 +21,11 @@ declare var a; (null); // names and dotted names (this); +>this : Symbol(GlobalThis) + (this.x); +>this : Symbol(GlobalThis) + ((a).x); >a : Symbol(a, Decl(castExpressionParentheses.ts, 0, 11)) diff --git a/tests/baselines/reference/castExpressionParentheses.types b/tests/baselines/reference/castExpressionParentheses.types index db38aad5a47e4..f07d0e65f36d3 100644 --- a/tests/baselines/reference/castExpressionParentheses.types +++ b/tests/baselines/reference/castExpressionParentheses.types @@ -77,13 +77,13 @@ declare var a; (this); >(this) : any >this : any ->this : any +>this : GlobalThis (this.x); >(this.x) : any >this.x : any >this.x : any ->this : any +>this : GlobalThis >x : any ((a).x); diff --git a/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols index b8904c087b308..9dd035002a5c1 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols @@ -7,6 +7,7 @@ module a { } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndAliasInGlobal.ts, 3, 3)) +>this : Symbol(GlobalThis) import _this = a; // Error >_this : Symbol(_this, Decl(collisionThisExpressionAndAliasInGlobal.ts, 3, 19)) diff --git a/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.types index 2bc6c89031972..f30e9fe1b80f7 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.types @@ -7,9 +7,9 @@ module a { >10 : 10 } var f = () => this; ->f : () => any ->() => this : () => any ->this : any +>f : () => GlobalThis +>() => this : () => GlobalThis +>this : GlobalThis import _this = a; // Error >_this : typeof a diff --git a/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols index 71aaa26e2ea44..9d126a7d3393d 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols @@ -4,6 +4,7 @@ declare class _this { // no error - as no code generation } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndAmbientClassInGlobal.ts, 2, 3)) +>this : Symbol(GlobalThis) var a = new _this(); // Error >a : Symbol(a, Decl(collisionThisExpressionAndAmbientClassInGlobal.ts, 3, 3)) diff --git a/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.types index ea0c8505fa0b2..88302206ad2f8 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.types @@ -3,9 +3,9 @@ declare class _this { // no error - as no code generation >_this : _this } var f = () => this; ->f : () => any ->() => this : () => any ->this : any +>f : () => GlobalThis +>() => this : () => GlobalThis +>this : GlobalThis var a = new _this(); // Error >a : _this diff --git a/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols index 859234b35faa3..eb09871949d0a 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols @@ -4,6 +4,7 @@ declare var _this: number; // no error as no code gen var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndAmbientVarInGlobal.ts, 1, 3)) +>this : Symbol(GlobalThis) _this = 10; // Error >_this : Symbol(_this, Decl(collisionThisExpressionAndAmbientVarInGlobal.ts, 0, 11)) diff --git a/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.types index c4038602bbae8..ec6c041eb41f7 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.types @@ -3,9 +3,9 @@ declare var _this: number; // no error as no code gen >_this : number var f = () => this; ->f : () => any ->() => this : () => any ->this : any +>f : () => GlobalThis +>() => this : () => GlobalThis +>this : GlobalThis _this = 10; // Error >_this = 10 : 10 diff --git a/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols index 73781af4894f7..0a1dc32c0bf88 100644 --- a/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols @@ -4,4 +4,5 @@ class _this { } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndClassInGlobal.ts, 2, 3)) +>this : Symbol(GlobalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.types index 5e4cd6e0ab48e..85f079b1a36c6 100644 --- a/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.types @@ -3,7 +3,7 @@ class _this { >_this : _this } var f = () => this; ->f : () => any ->() => this : () => any ->this : any +>f : () => GlobalThis +>() => this : () => GlobalThis +>this : GlobalThis diff --git a/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols index 022b6487d026d..51f156bba049e 100644 --- a/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols @@ -10,4 +10,5 @@ enum _this { // Error } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndEnumInGlobal.ts, 4, 3)) +>this : Symbol(GlobalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.types index 87a28ada0e2b7..534704a77ef8a 100644 --- a/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.types @@ -9,7 +9,7 @@ enum _this { // Error >_thisVal2 : _this._thisVal2 } var f = () => this; ->f : () => any ->() => this : () => any ->this : any +>f : () => GlobalThis +>() => this : () => GlobalThis +>this : GlobalThis diff --git a/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols index a5d171dbe9475..58e3f08726b01 100644 --- a/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols @@ -6,4 +6,5 @@ function _this() { //Error } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndFunctionInGlobal.ts, 3, 3)) +>this : Symbol(GlobalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.types index bb0e11172cc2b..646669c6b4c75 100644 --- a/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.types @@ -6,7 +6,7 @@ function _this() { //Error >10 : 10 } var f = () => this; ->f : () => any ->() => this : () => any ->this : any +>f : () => GlobalThis +>() => this : () => GlobalThis +>this : GlobalThis diff --git a/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols b/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols index 2105baf09a2d4..400d71b5bbeb1 100644 --- a/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols @@ -15,6 +15,7 @@ var x = { return callback(this); >callback : Symbol(callback, Decl(collisionThisExpressionAndLocalVarInLambda.ts, 3, 14)) +>this : Symbol(GlobalThis) } } alert(x.doStuff(x => alert(x))); diff --git a/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.types b/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.types index cbc625b36e1ce..edfd3032f1553 100644 --- a/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.types +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.types @@ -20,7 +20,7 @@ var x = { return callback(this); >callback(this) : any >callback : any ->this : any +>this : GlobalThis } } alert(x.doStuff(x => alert(x))); diff --git a/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols index 8dcb9dca6d20c..cf5568911debb 100644 --- a/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols @@ -8,4 +8,5 @@ module _this { //Error } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndModuleInGlobal.ts, 4, 3)) +>this : Symbol(GlobalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.types index b950cda2d100c..46a9625bd34c8 100644 --- a/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.types @@ -7,7 +7,7 @@ module _this { //Error } } var f = () => this; ->f : () => any ->() => this : () => any ->this : any +>f : () => GlobalThis +>() => this : () => GlobalThis +>this : GlobalThis diff --git a/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols index 5895e29b2c235..f7946d818c0f7 100644 --- a/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols @@ -4,4 +4,5 @@ var _this = 1; var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndVarInGlobal.ts, 1, 3)) +>this : Symbol(GlobalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.types index dd12ea635023a..da536d7f7fa75 100644 --- a/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.types @@ -4,7 +4,7 @@ var _this = 1; >1 : 1 var f = () => this; ->f : () => any ->() => this : () => any ->this : any +>f : () => GlobalThis +>() => this : () => GlobalThis +>this : GlobalThis diff --git a/tests/baselines/reference/commentsInterface.symbols b/tests/baselines/reference/commentsInterface.symbols index 6e3a9e2797826..da4b34bc1b40f 100644 --- a/tests/baselines/reference/commentsInterface.symbols +++ b/tests/baselines/reference/commentsInterface.symbols @@ -187,19 +187,25 @@ i3_i = { l: this.f, >l : Symbol(l, Decl(commentsInterface.ts, 56, 56)) +>this : Symbol(GlobalThis) /** own x*/ x: this.f(10), >x : Symbol(x, Decl(commentsInterface.ts, 57, 14)) +>this : Symbol(GlobalThis) nc_x: this.l(this.x), >nc_x : Symbol(nc_x, Decl(commentsInterface.ts, 59, 18)) +>this : Symbol(GlobalThis) +>this : Symbol(GlobalThis) nc_f: this.f, >nc_f : Symbol(nc_f, Decl(commentsInterface.ts, 60, 25)) +>this : Symbol(GlobalThis) nc_l: this.l >nc_l : Symbol(nc_l, Decl(commentsInterface.ts, 61, 17)) +>this : Symbol(GlobalThis) }; i3_i.f(10); diff --git a/tests/baselines/reference/commentsInterface.types b/tests/baselines/reference/commentsInterface.types index 65f1f5f4a38f0..f109f4bc341e9 100644 --- a/tests/baselines/reference/commentsInterface.types +++ b/tests/baselines/reference/commentsInterface.types @@ -198,7 +198,7 @@ i3_i = { l: this.f, >l : any >this.f : any ->this : any +>this : GlobalThis >f : any /** own x*/ @@ -206,7 +206,7 @@ i3_i = { >x : any >this.f(10) : any >this.f : any ->this : any +>this : GlobalThis >f : any >10 : 10 @@ -214,22 +214,22 @@ i3_i = { >nc_x : any >this.l(this.x) : any >this.l : any ->this : any +>this : GlobalThis >l : any >this.x : any ->this : any +>this : GlobalThis >x : any nc_f: this.f, >nc_f : any >this.f : any ->this : any +>this : GlobalThis >f : any nc_l: this.l >nc_l : any >this.l : any ->this : any +>this : GlobalThis >l : any }; diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols b/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols index 790c05ed9a124..630de274757b3 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols @@ -51,9 +51,11 @@ function foo() { } this *= value; +>this : Symbol(GlobalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) this += value; +>this : Symbol(GlobalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) // identifiers: module, class, enum, function @@ -216,9 +218,11 @@ foo() += value; // parentheses, the containted expression is value (this) *= value; +>this : Symbol(GlobalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) (this) += value; +>this : Symbol(GlobalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) (M) *= value; diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.types b/tests/baselines/reference/compoundAssignmentLHSIsValue.types index 7736256f97356..1aa99cce2fa5b 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.types +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.types @@ -62,12 +62,12 @@ function foo() { this *= value; >this *= value : number ->this : any +>this : GlobalThis >value : any this += value; >this += value : any ->this : any +>this : GlobalThis >value : any // identifiers: module, class, enum, function @@ -300,14 +300,14 @@ foo() += value; // parentheses, the containted expression is value (this) *= value; >(this) *= value : number ->(this) : any ->this : any +>(this) : GlobalThis +>this : GlobalThis >value : any (this) += value; >(this) += value : any ->(this) : any ->this : any +>(this) : GlobalThis +>this : GlobalThis >value : any (M) *= value; diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols index 7e85139b7a89f..9027ee620d692 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols @@ -36,6 +36,7 @@ function foo() { } this **= value; +>this : Symbol(GlobalThis) >value : Symbol(value, Decl(compoundExponentiationAssignmentLHSIsValue.ts, 1, 3)) // identifiers: module, class, enum, function @@ -135,6 +136,7 @@ foo() **= value; // parentheses, the containted expression is value (this) **= value; +>this : Symbol(GlobalThis) >value : Symbol(value, Decl(compoundExponentiationAssignmentLHSIsValue.ts, 1, 3)) (M) **= value; diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.types b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.types index 982b6b2bdee9e..52d3f8db875e9 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.types +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.types @@ -42,7 +42,7 @@ function foo() { this **= value; >this **= value : number ->this : any +>this : GlobalThis >value : any // identifiers: module, class, enum, function @@ -178,8 +178,8 @@ foo() **= value; // parentheses, the containted expression is value (this) **= value; >(this) **= value : number ->(this) : any ->this : any +>(this) : GlobalThis +>this : GlobalThis >value : any (M) **= value; diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.symbols b/tests/baselines/reference/computedPropertyNames20_ES5.symbols index 2b249fd8f9507..b29a51bd33136 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames20_ES5.symbols @@ -4,4 +4,5 @@ var obj = { [this.bar]: 0 >[this.bar] : Symbol([this.bar], Decl(computedPropertyNames20_ES5.ts, 0, 11)) +>this : Symbol(GlobalThis) } diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.types b/tests/baselines/reference/computedPropertyNames20_ES5.types index cc0614b3d0b45..2dcda458901c3 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.types +++ b/tests/baselines/reference/computedPropertyNames20_ES5.types @@ -6,7 +6,7 @@ var obj = { [this.bar]: 0 >[this.bar] : number >this.bar : any ->this : any +>this : GlobalThis >bar : any >0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames20_ES6.symbols b/tests/baselines/reference/computedPropertyNames20_ES6.symbols index ffd5645ccd6f3..19ec84cbc1211 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames20_ES6.symbols @@ -4,4 +4,5 @@ var obj = { [this.bar]: 0 >[this.bar] : Symbol([this.bar], Decl(computedPropertyNames20_ES6.ts, 0, 11)) +>this : Symbol(GlobalThis) } diff --git a/tests/baselines/reference/computedPropertyNames20_ES6.types b/tests/baselines/reference/computedPropertyNames20_ES6.types index 5ffc037860e99..36d2e9985f1e9 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES6.types +++ b/tests/baselines/reference/computedPropertyNames20_ES6.types @@ -6,7 +6,7 @@ var obj = { [this.bar]: 0 >[this.bar] : number >this.bar : any ->this : any +>this : GlobalThis >bar : any >0 : 0 } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols index c5f1afffb2f5f..6d062ab90f0bb 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols @@ -579,6 +579,7 @@ module TypeScriptAllInOne { } public method2() { return 2 * this.method1(2); +>this : Symbol(GlobalThis) } } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types index c4428efcd4dad..c3a8baee96307 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types @@ -869,7 +869,7 @@ module TypeScriptAllInOne { >2 : 2 >this.method1(2) : any >this.method1 : any ->this : any +>this : GlobalThis >method1 : any >2 : 2 } diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols index 6bd13ccfd470b..10420fc44c62c 100644 --- a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols @@ -8,6 +8,9 @@ wrapper((array: [any]) => { >array : Symbol(array, Decl(emitCapturingThisInTupleDestructuring1.ts, 1, 9)) [this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this" +>this : Symbol(GlobalThis) +>this : Symbol(GlobalThis) +>this : Symbol(GlobalThis) >array : Symbol(array, Decl(emitCapturingThisInTupleDestructuring1.ts, 1, 9)) }); diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.types b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.types index 7e9f03780caba..ff3af78b51b0e 100644 --- a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.types +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.types @@ -13,13 +13,13 @@ wrapper((array: [any]) => { >[this.test, this.test1, this.test2] = array : [any] >[this.test, this.test1, this.test2] : [any, any, any] >this.test : any ->this : any +>this : GlobalThis >test : any >this.test1 : any ->this : any +>this : GlobalThis >test1 : any >this.test2 : any ->this : any +>this : GlobalThis >test2 : any >array : [any] diff --git a/tests/baselines/reference/globalThisCapture.symbols b/tests/baselines/reference/globalThisCapture.symbols index bfb7bf147c0a4..1da1a1b0ae2f2 100644 --- a/tests/baselines/reference/globalThisCapture.symbols +++ b/tests/baselines/reference/globalThisCapture.symbols @@ -1,6 +1,9 @@ === tests/cases/compiler/globalThisCapture.ts === // Add a lambda to ensure global 'this' capture is triggered (()=>this.window); +>this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) +>this : Symbol(GlobalThis) +>window : Symbol(window, Decl(lib.dom.d.ts, --, --)) var parts = []; >parts : Symbol(parts, Decl(globalThisCapture.ts, 3, 3)) diff --git a/tests/baselines/reference/globalThisCapture.types b/tests/baselines/reference/globalThisCapture.types index 063100ff78eaf..4ac1dca5c7d24 100644 --- a/tests/baselines/reference/globalThisCapture.types +++ b/tests/baselines/reference/globalThisCapture.types @@ -1,11 +1,11 @@ === tests/cases/compiler/globalThisCapture.ts === // Add a lambda to ensure global 'this' capture is triggered (()=>this.window); ->(()=>this.window) : () => any ->()=>this.window : () => any ->this.window : any ->this : any ->window : any +>(()=>this.window) : () => Window +>()=>this.window : () => Window +>this.window : Window +>this : GlobalThis +>window : Window var parts = []; >parts : any[] diff --git a/tests/baselines/reference/implicitAnyInCatch.symbols b/tests/baselines/reference/implicitAnyInCatch.symbols index 7ce3ac40f369d..63f97268ab188 100644 --- a/tests/baselines/reference/implicitAnyInCatch.symbols +++ b/tests/baselines/reference/implicitAnyInCatch.symbols @@ -8,6 +8,7 @@ try { } catch (error) { } for (var key in this) { } >key : Symbol(key, Decl(implicitAnyInCatch.ts, 4, 8)) +>this : Symbol(GlobalThis) class C { >C : Symbol(C, Decl(implicitAnyInCatch.ts, 4, 25)) diff --git a/tests/baselines/reference/implicitAnyInCatch.types b/tests/baselines/reference/implicitAnyInCatch.types index 6f70165407f99..8ca928493666e 100644 --- a/tests/baselines/reference/implicitAnyInCatch.types +++ b/tests/baselines/reference/implicitAnyInCatch.types @@ -13,7 +13,7 @@ try { } catch (error) { } for (var key in this) { } >key : string ->this : any +>this : GlobalThis class C { >C : C diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols index 25af733e40f35..7016108959cda 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols +++ b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols @@ -127,6 +127,7 @@ export const MySFC = (props: {x: number, y: number, children?: predom.JSX.Elemen >props.y : Symbol(y, Decl(component.tsx, 3, 40)) >props : Symbol(props, Decl(component.tsx, 3, 22)) >y : Symbol(y, Decl(component.tsx, 3, 40)) +>this : Symbol(GlobalThis) >p : Symbol(predom.JSX.IntrinsicElements, Decl(renderer2.d.ts, 1, 19)) export class MyClass implements predom.JSX.Element { diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types index a1c0e79909d89..8f2b8f673657c 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types +++ b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types @@ -99,7 +99,7 @@ export const MySFC = (props: {x: number, y: number, children?: predom.JSX.Elemen >y : number >this.props.children : any >this.props : any ->this : any +>this : GlobalThis >props : any >children : any >p : any diff --git a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols index fc489ff899d04..11c981b097718 100644 --- a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols +++ b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols @@ -12,6 +12,7 @@ declare var React: any; } dataSource={this.state.ds} renderRow={}> >dataSource : Symbol(dataSource, Decl(jsxAttributeWithoutExpressionReact.tsx, 4, 5)) +>this : Symbol(GlobalThis) >renderRow : Symbol(renderRow, Decl(jsxAttributeWithoutExpressionReact.tsx, 4, 32)) diff --git a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.types b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.types index e5c192b4876eb..fc261a13aa43f 100644 --- a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.types +++ b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.types @@ -21,7 +21,7 @@ declare var React: any; >dataSource : any >this.state.ds : any >this.state : any ->this : any +>this : GlobalThis >state : any >ds : any >renderRow : any diff --git a/tests/baselines/reference/jsxReactTestSuite.symbols b/tests/baselines/reference/jsxReactTestSuite.symbols index dfcc4c70bd801..bb5b0dfe99cc1 100644 --- a/tests/baselines/reference/jsxReactTestSuite.symbols +++ b/tests/baselines/reference/jsxReactTestSuite.symbols @@ -39,6 +39,8 @@ declare var hasOwnProperty:any;
{this.props.children} +>this : Symbol(GlobalThis) +
;
@@ -57,6 +59,8 @@ declare var hasOwnProperty:any; >Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 2, 11)) {this.props.children} +>this : Symbol(GlobalThis) + ; >Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 2, 11)) @@ -154,6 +158,7 @@ var x = >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 1, 11)) {...this.props} sound="moo" />; +>this : Symbol(GlobalThis) >sound : Symbol(sound, Decl(jsxReactTestSuite.tsx, 93, 19)) ; diff --git a/tests/baselines/reference/jsxReactTestSuite.types b/tests/baselines/reference/jsxReactTestSuite.types index 3637a21c2682a..d922269a3c214 100644 --- a/tests/baselines/reference/jsxReactTestSuite.types +++ b/tests/baselines/reference/jsxReactTestSuite.types @@ -47,7 +47,7 @@ declare var hasOwnProperty:any; {this.props.children} >this.props.children : any >this.props : any ->this : any +>this : GlobalThis >props : any >children : any @@ -89,7 +89,7 @@ declare var hasOwnProperty:any; {this.props.children} >this.props.children : any >this.props : any ->this : any +>this : GlobalThis >props : any >children : any @@ -262,7 +262,7 @@ var x = {...this.props} sound="moo" />; >this.props : any ->this : any +>this : GlobalThis >props : any >sound : string diff --git a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols index 306e629e82df7..746fe594f5070 100644 --- a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols +++ b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols @@ -1,9 +1,12 @@ === tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts === return this.edit(role) +>this : Symbol(GlobalThis) + .then((role: Role) => >role : Symbol(role, Decl(multiLinePropertyAccessAndArrowFunctionIndent1.ts, 1, 11)) this.roleService.add(role) +>this : Symbol(GlobalThis) >role : Symbol(role, Decl(multiLinePropertyAccessAndArrowFunctionIndent1.ts, 1, 11)) .then((data: ng.IHttpPromiseCallbackArg) => data.data)); diff --git a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.types b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.types index 5347dbb876dfb..342d18b4f6db8 100644 --- a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.types +++ b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.types @@ -4,7 +4,7 @@ return this.edit(role) >this.edit(role) .then : any >this.edit(role) : any >this.edit : any ->this : any +>this : GlobalThis >edit : any >role : any @@ -19,7 +19,7 @@ return this.edit(role) >this.roleService.add(role) : any >this.roleService.add : any >this.roleService : any ->this : any +>this : GlobalThis >roleService : any >add : any >role : any diff --git a/tests/baselines/reference/noImplicitThisFunctions.symbols b/tests/baselines/reference/noImplicitThisFunctions.symbols index d8d937893f32b..f0e21a6bacc50 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.symbols +++ b/tests/baselines/reference/noImplicitThisFunctions.symbols @@ -31,10 +31,12 @@ let f4: (b: number) => number = b => this.c + b; >f4 : Symbol(f4, Decl(noImplicitThisFunctions.ts, 16, 3)) >b : Symbol(b, Decl(noImplicitThisFunctions.ts, 16, 9)) >b : Symbol(b, Decl(noImplicitThisFunctions.ts, 16, 31)) +>this : Symbol(GlobalThis) >b : Symbol(b, Decl(noImplicitThisFunctions.ts, 16, 31)) let f5 = () => () => this; >f5 : Symbol(f5, Decl(noImplicitThisFunctions.ts, 17, 3)) +>this : Symbol(GlobalThis) let f6 = function() { return () => this; }; >f6 : Symbol(f6, Decl(noImplicitThisFunctions.ts, 19, 3)) diff --git a/tests/baselines/reference/noImplicitThisFunctions.types b/tests/baselines/reference/noImplicitThisFunctions.types index f5b93fa9efbc1..712928e3261f9 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.types +++ b/tests/baselines/reference/noImplicitThisFunctions.types @@ -42,15 +42,15 @@ let f4: (b: number) => number = b => this.c + b; >b : number >this.c + b : any >this.c : any ->this : any +>this : GlobalThis >c : any >b : number let f5 = () => () => this; ->f5 : () => () => any ->() => () => this : () => () => any ->() => this : () => any ->this : any +>f5 : () => () => GlobalThis +>() => () => this : () => () => GlobalThis +>() => this : () => GlobalThis +>this : GlobalThis let f6 = function() { return () => this; }; >f6 : () => () => any diff --git a/tests/baselines/reference/parserCommaInTypeMemberList2.symbols b/tests/baselines/reference/parserCommaInTypeMemberList2.symbols index ffaac46fd2749..2f303d16f92f3 100644 --- a/tests/baselines/reference/parserCommaInTypeMemberList2.symbols +++ b/tests/baselines/reference/parserCommaInTypeMemberList2.symbols @@ -5,4 +5,5 @@ var s = $.extend< { workItem: any }, { workItem: any, width: string }>({ workIte >workItem : Symbol(workItem, Decl(parserCommaInTypeMemberList2.ts, 0, 38)) >width : Symbol(width, Decl(parserCommaInTypeMemberList2.ts, 0, 53)) >workItem : Symbol(workItem, Decl(parserCommaInTypeMemberList2.ts, 0, 72)) +>this : Symbol(GlobalThis) diff --git a/tests/baselines/reference/parserCommaInTypeMemberList2.types b/tests/baselines/reference/parserCommaInTypeMemberList2.types index cfa270d983871..45fa3ebcb7db9 100644 --- a/tests/baselines/reference/parserCommaInTypeMemberList2.types +++ b/tests/baselines/reference/parserCommaInTypeMemberList2.types @@ -11,7 +11,7 @@ var s = $.extend< { workItem: any }, { workItem: any, width: string }>({ workIte >{ workItem: this._workItem } : { workItem: any; } >workItem : any >this._workItem : any ->this : any +>this : GlobalThis >_workItem : any >{} : {} diff --git a/tests/baselines/reference/parserConditionalExpression1.symbols b/tests/baselines/reference/parserConditionalExpression1.symbols index e271c68b4a0b3..9e12295caec66 100644 --- a/tests/baselines/reference/parserConditionalExpression1.symbols +++ b/tests/baselines/reference/parserConditionalExpression1.symbols @@ -1,3 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/Expressions/parserConditionalExpression1.ts === (a=this.R[c])?a.JW||(a.e5(this,c),a.JW=_.l):this.A -No type information for this code. \ No newline at end of file +>this : Symbol(GlobalThis) +>this : Symbol(GlobalThis) +>this : Symbol(GlobalThis) + diff --git a/tests/baselines/reference/parserConditionalExpression1.types b/tests/baselines/reference/parserConditionalExpression1.types index 930d744d48ab8..4133fdcb8c01d 100644 --- a/tests/baselines/reference/parserConditionalExpression1.types +++ b/tests/baselines/reference/parserConditionalExpression1.types @@ -6,7 +6,7 @@ >a : any >this.R[c] : any >this.R : any ->this : any +>this : GlobalThis >R : any >c : any >a.JW||(a.e5(this,c),a.JW=_.l) : any @@ -19,7 +19,7 @@ >a.e5 : any >a : any >e5 : any ->this : any +>this : GlobalThis >c : any >a.JW=_.l : any >a.JW : any @@ -29,6 +29,6 @@ >_ : any >l : any >this.A : any ->this : any +>this : GlobalThis >A : any diff --git a/tests/baselines/reference/parserForStatement8.symbols b/tests/baselines/reference/parserForStatement8.symbols index 4e34f8b90c91c..f55c3ac2a2ca9 100644 --- a/tests/baselines/reference/parserForStatement8.symbols +++ b/tests/baselines/reference/parserForStatement8.symbols @@ -1,4 +1,4 @@ === tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement8.ts === for (this in b) { -No type information for this code.} -No type information for this code. \ No newline at end of file +>this : Symbol(GlobalThis) +} diff --git a/tests/baselines/reference/parserForStatement8.types b/tests/baselines/reference/parserForStatement8.types index 0a52052875902..93d834e429a4b 100644 --- a/tests/baselines/reference/parserForStatement8.types +++ b/tests/baselines/reference/parserForStatement8.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement8.ts === for (this in b) { ->this : any +>this : GlobalThis >b : any } diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols b/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols index c118eff4a863b..751b96bd51ccc 100644 --- a/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols +++ b/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols @@ -2,5 +2,6 @@ { declare var x = this; >x : Symbol(x, Decl(parserModifierOnStatementInBlock2.ts, 1, 14)) +>this : Symbol(GlobalThis) } diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock2.types b/tests/baselines/reference/parserModifierOnStatementInBlock2.types index a74d3a0c544d0..928c45f3e36e6 100644 --- a/tests/baselines/reference/parserModifierOnStatementInBlock2.types +++ b/tests/baselines/reference/parserModifierOnStatementInBlock2.types @@ -1,7 +1,7 @@ === tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock2.ts === { declare var x = this; ->x : any ->this : any +>x : GlobalThis +>this : GlobalThis } diff --git a/tests/baselines/reference/parserStrictMode16.symbols b/tests/baselines/reference/parserStrictMode16.symbols index 655201fbea2bf..e76e39cd941f9 100644 --- a/tests/baselines/reference/parserStrictMode16.symbols +++ b/tests/baselines/reference/parserStrictMode16.symbols @@ -1,7 +1,8 @@ === tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts === "use strict"; -No type information for this code.delete this; -No type information for this code.delete 1; -No type information for this code.delete null; -No type information for this code.delete "a"; -No type information for this code. \ No newline at end of file +delete this; +>this : Symbol(GlobalThis) + +delete 1; +delete null; +delete "a"; diff --git a/tests/baselines/reference/parserStrictMode16.types b/tests/baselines/reference/parserStrictMode16.types index fbe701f374b13..36fb6c8a17f30 100644 --- a/tests/baselines/reference/parserStrictMode16.types +++ b/tests/baselines/reference/parserStrictMode16.types @@ -4,7 +4,7 @@ delete this; >delete this : boolean ->this : any +>this : GlobalThis delete 1; >delete 1 : boolean diff --git a/tests/baselines/reference/parserUnaryExpression1.symbols b/tests/baselines/reference/parserUnaryExpression1.symbols index 2311212b63d6f..3d5e96d1daabb 100644 --- a/tests/baselines/reference/parserUnaryExpression1.symbols +++ b/tests/baselines/reference/parserUnaryExpression1.symbols @@ -1,3 +1,4 @@ === tests/cases/conformance/parser/ecmascript5/Expressions/parserUnaryExpression1.ts === ++this; -No type information for this code. \ No newline at end of file +>this : Symbol(GlobalThis) + diff --git a/tests/baselines/reference/parserUnaryExpression1.types b/tests/baselines/reference/parserUnaryExpression1.types index 5803ac1f1f835..89468794834b7 100644 --- a/tests/baselines/reference/parserUnaryExpression1.types +++ b/tests/baselines/reference/parserUnaryExpression1.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript5/Expressions/parserUnaryExpression1.ts === ++this; >++this : number ->this : any +>this : GlobalThis diff --git a/tests/baselines/reference/propertyWrappedInTry.symbols b/tests/baselines/reference/propertyWrappedInTry.symbols index cce74c0981b94..9b43ccdc4ede4 100644 --- a/tests/baselines/reference/propertyWrappedInTry.symbols +++ b/tests/baselines/reference/propertyWrappedInTry.symbols @@ -14,6 +14,7 @@ class Foo { public baz() { return this.bar; // doesn't get rewritten to Foo.bar. +>this : Symbol(GlobalThis) } diff --git a/tests/baselines/reference/propertyWrappedInTry.types b/tests/baselines/reference/propertyWrappedInTry.types index 29be27edee9d4..b40929c0a8a59 100644 --- a/tests/baselines/reference/propertyWrappedInTry.types +++ b/tests/baselines/reference/propertyWrappedInTry.types @@ -21,7 +21,7 @@ class Foo { return this.bar; // doesn't get rewritten to Foo.bar. >this.bar : any ->this : any +>this : GlobalThis >bar : any } diff --git a/tests/baselines/reference/thisInInvalidContexts.symbols b/tests/baselines/reference/thisInInvalidContexts.symbols index 417b9cc5ea81a..fedb2c6b95e22 100644 --- a/tests/baselines/reference/thisInInvalidContexts.symbols +++ b/tests/baselines/reference/thisInInvalidContexts.symbols @@ -69,6 +69,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContexts.ts, 35, 29)) +>this : Symbol(GlobalThis) } diff --git a/tests/baselines/reference/thisInInvalidContexts.types b/tests/baselines/reference/thisInInvalidContexts.types index 672a8fe58c4ee..42c8777dceba0 100644 --- a/tests/baselines/reference/thisInInvalidContexts.types +++ b/tests/baselines/reference/thisInInvalidContexts.types @@ -72,7 +72,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : ErrClass3 ->this : any +>this : GlobalThis } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols b/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols index 9cf261fa672b3..8954656036d09 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols @@ -69,6 +69,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContextsExternalModule.ts, 35, 29)) +>this : Symbol(GlobalThis) } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.types b/tests/baselines/reference/thisInInvalidContextsExternalModule.types index cdc1317307771..f24267027f943 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.types +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.types @@ -72,7 +72,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : ErrClass3 ->this : any +>this : GlobalThis } diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index ad16785f28830..4c1c9c75a5e2c 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -126,6 +126,7 @@ let impl: I = { explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) >explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 38, 10)) +>this : Symbol(GlobalThis) explicitVoid1() { return 12; }, >explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 39, 32)) @@ -365,6 +366,7 @@ let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + th >x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 45)) >x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 68)) >x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 68)) +>this : Symbol(GlobalThis) let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; >specifiedToSpecified : Symbol(specifiedToSpecified, Decl(thisTypeInFunctions.ts, 93, 3)) @@ -495,6 +497,9 @@ c.explicitC = m => m + this.n; >explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) +>this : Symbol(GlobalThis) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) c.explicitThis = m => m + this.n; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) @@ -502,6 +507,9 @@ c.explicitThis = m => m + this.n; >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) +>this : Symbol(GlobalThis) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) c.explicitProperty = m => m + this.n; >c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) @@ -509,6 +517,9 @@ c.explicitProperty = m => m + this.n; >explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) +>this : Symbol(GlobalThis) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) //NOTE: this=C here, I guess? c.explicitThis = explicitCFunction; diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index caf4e9a5971cd..a6fda78497a37 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -137,7 +137,7 @@ let impl: I = { >explicitVoid2 : () => any >() => this.a : () => any >this.a : any ->this : any +>this : GlobalThis >a : any explicitVoid1() { return 12; }, @@ -431,7 +431,7 @@ let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + th >x + this.y : any >x : number >this.y : any ->this : any +>this : GlobalThis >y : any let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; @@ -580,43 +580,43 @@ c.explicitProperty = m => m; // this inside lambdas refer to outer scope // the outer-scoped lambda at top-level is still just `any` c.explicitC = m => m + this.n; ->c.explicitC = m => m + this.n : (this: C, m: number) => any +>c.explicitC = m => m + this.n : (this: C, m: number) => number >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->m => m + this.n : (this: C, m: number) => any +>m => m + this.n : (this: C, m: number) => number >m : number ->m + this.n : any +>m + this.n : number >m : number ->this.n : any ->this : any ->n : any +>this.n : number +>this : GlobalThis +>n : number c.explicitThis = m => m + this.n; ->c.explicitThis = m => m + this.n : (this: C, m: number) => any +>c.explicitThis = m => m + this.n : (this: C, m: number) => number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->m => m + this.n : (this: C, m: number) => any +>m => m + this.n : (this: C, m: number) => number >m : number ->m + this.n : any +>m + this.n : number >m : number ->this.n : any ->this : any ->n : any +>this.n : number +>this : GlobalThis +>n : number c.explicitProperty = m => m + this.n; ->c.explicitProperty = m => m + this.n : (this: { n: number; }, m: number) => any +>c.explicitProperty = m => m + this.n : (this: { n: number; }, m: number) => number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->m => m + this.n : (this: { n: number; }, m: number) => any +>m => m + this.n : (this: { n: number; }, m: number) => number >m : number ->m + this.n : any +>m + this.n : number >m : number ->this.n : any ->this : any ->n : any +>this.n : number +>this : GlobalThis +>n : number //NOTE: this=C here, I guess? c.explicitThis = explicitCFunction; diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.symbols b/tests/baselines/reference/thisTypeInFunctionsNegative.symbols index 024ae663a9d70..6b6f35c1916fc 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.symbols +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.symbols @@ -134,6 +134,7 @@ let impl: I = { }, explicitVoid2: () => this.a, // ok, `this:any` because it refers to an outer object >explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctionsNegative.ts, 39, 6)) +>this : Symbol(GlobalThis) explicitStructural: () => 12, >explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctionsNegative.ts, 40, 32)) @@ -655,6 +656,7 @@ function initializer(this: C = new C()): number { return this.n; } >C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 171, 30)) >C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 171, 34)) +>this : Symbol(GlobalThis) // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; @@ -664,6 +666,7 @@ c.explicitProperty = (this, m) => m + this.n; >this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 174, 22)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 174, 27)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 174, 27)) +>this : Symbol(GlobalThis) const f2 = (this: {n: number}, m: number) => m + this.n; >f2 : Symbol(f2, Decl(thisTypeInFunctionsNegative.ts, 175, 5)) @@ -672,6 +675,7 @@ const f2 = (this: {n: number}, m: number) => m + this.n; >n : Symbol(n, Decl(thisTypeInFunctionsNegative.ts, 175, 22)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 175, 33)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 175, 33)) +>this : Symbol(GlobalThis) const f3 = async (this: {n: number}, m: number) => m + this.n; >f3 : Symbol(f3, Decl(thisTypeInFunctionsNegative.ts, 176, 5)) @@ -679,6 +683,7 @@ const f3 = async (this: {n: number}, m: number) => m + this.n; >n : Symbol(n, Decl(thisTypeInFunctionsNegative.ts, 176, 25)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 176, 36)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 176, 36)) +>this : Symbol(GlobalThis) const f4 = async (this: {n: number}, m: number) => m + this.n; >f4 : Symbol(f4, Decl(thisTypeInFunctionsNegative.ts, 177, 5)) @@ -687,4 +692,5 @@ const f4 = async (this: {n: number}, m: number) => m + this.n; >n : Symbol(n, Decl(thisTypeInFunctionsNegative.ts, 177, 28)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 177, 39)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 177, 39)) +>this : Symbol(GlobalThis) diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.types b/tests/baselines/reference/thisTypeInFunctionsNegative.types index 90a5f06ad40a2..07f03d7d2fed2 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.types +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.types @@ -143,7 +143,7 @@ let impl: I = { >explicitVoid2 : () => any >() => this.a : () => any >this.a : any ->this : any +>this : GlobalThis >a : any explicitStructural: () => 12, @@ -751,7 +751,7 @@ function initializer(this: C = new C()): number { return this.n; } > : any >number : any >this.n : any ->this : any +>this : GlobalThis >n : any // can't name parameters 'this' in a lambda. @@ -766,7 +766,7 @@ c.explicitProperty = (this, m) => m + this.n; >m + this.n : any >m : number >this.n : any ->this : any +>this : GlobalThis >n : any const f2 = (this: {n: number}, m: number) => m + this.n; @@ -778,7 +778,7 @@ const f2 = (this: {n: number}, m: number) => m + this.n; >m + this.n : any >m : number >this.n : any ->this : any +>this : GlobalThis >n : any const f3 = async (this: {n: number}, m: number) => m + this.n; @@ -790,7 +790,7 @@ const f3 = async (this: {n: number}, m: number) => m + this.n; >m + this.n : any >m : number >this.n : any ->this : any +>this : GlobalThis >n : any const f4 = async (this: {n: number}, m: number) => m + this.n; @@ -802,6 +802,6 @@ const f4 = async (this: {n: number}, m: number) => m + this.n; >m + this.n : any >m : number >this.n : any ->this : any +>this : GlobalThis >n : any diff --git a/tests/baselines/reference/topLevelLambda2.symbols b/tests/baselines/reference/topLevelLambda2.symbols index 712d0a1611afc..0297d4b7492c9 100644 --- a/tests/baselines/reference/topLevelLambda2.symbols +++ b/tests/baselines/reference/topLevelLambda2.symbols @@ -5,4 +5,7 @@ function foo(x:any) {} foo(()=>this.window); >foo : Symbol(foo, Decl(topLevelLambda2.ts, 0, 0)) +>this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) +>this : Symbol(GlobalThis) +>window : Symbol(window, Decl(lib.dom.d.ts, --, --)) diff --git a/tests/baselines/reference/topLevelLambda2.types b/tests/baselines/reference/topLevelLambda2.types index 7dcb909cdf952..2b5343ddc8c27 100644 --- a/tests/baselines/reference/topLevelLambda2.types +++ b/tests/baselines/reference/topLevelLambda2.types @@ -6,8 +6,8 @@ function foo(x:any) {} foo(()=>this.window); >foo(()=>this.window) : void >foo : (x: any) => void ->()=>this.window : () => any ->this.window : any ->this : any ->window : any +>()=>this.window : () => Window +>this.window : Window +>this : GlobalThis +>window : Window diff --git a/tests/baselines/reference/topLevelLambda3.symbols b/tests/baselines/reference/topLevelLambda3.symbols index 6ec9476ff743a..be077cb760ea0 100644 --- a/tests/baselines/reference/topLevelLambda3.symbols +++ b/tests/baselines/reference/topLevelLambda3.symbols @@ -1,4 +1,7 @@ === tests/cases/compiler/topLevelLambda3.ts === var f = () => {this.window;} >f : Symbol(f, Decl(topLevelLambda3.ts, 0, 3)) +>this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) +>this : Symbol(GlobalThis) +>window : Symbol(window, Decl(lib.dom.d.ts, --, --)) diff --git a/tests/baselines/reference/topLevelLambda3.types b/tests/baselines/reference/topLevelLambda3.types index e96d40880fca1..9c1ae547ff76f 100644 --- a/tests/baselines/reference/topLevelLambda3.types +++ b/tests/baselines/reference/topLevelLambda3.types @@ -2,7 +2,7 @@ var f = () => {this.window;} >f : () => void >() => {this.window;} : () => void ->this.window : any ->this : any ->window : any +>this.window : Window +>this : GlobalThis +>window : Window diff --git a/tests/baselines/reference/topLevelLambda4.symbols b/tests/baselines/reference/topLevelLambda4.symbols index a4f403a762ffd..a9ad8e38349d2 100644 --- a/tests/baselines/reference/topLevelLambda4.symbols +++ b/tests/baselines/reference/topLevelLambda4.symbols @@ -1,4 +1,7 @@ === tests/cases/compiler/topLevelLambda4.ts === export var x = () => this.window; >x : Symbol(x, Decl(topLevelLambda4.ts, 0, 10)) +>this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) +>this : Symbol(GlobalThis) +>window : Symbol(window, Decl(lib.dom.d.ts, --, --)) diff --git a/tests/baselines/reference/topLevelLambda4.types b/tests/baselines/reference/topLevelLambda4.types index f6c8752c267fb..b88f0bd05b6a6 100644 --- a/tests/baselines/reference/topLevelLambda4.types +++ b/tests/baselines/reference/topLevelLambda4.types @@ -1,8 +1,8 @@ === tests/cases/compiler/topLevelLambda4.ts === export var x = () => this.window; ->x : () => any ->() => this.window : () => any ->this.window : any ->this : any ->window : any +>x : () => Window +>() => this.window : () => Window +>this.window : Window +>this : GlobalThis +>window : Window diff --git a/tests/baselines/reference/tsxAttributeResolution15.symbols b/tests/baselines/reference/tsxAttributeResolution15.symbols index 5c91d12a103f7..481b8cd101b01 100644 --- a/tests/baselines/reference/tsxAttributeResolution15.symbols +++ b/tests/baselines/reference/tsxAttributeResolution15.symbols @@ -31,6 +31,7 @@ let b = { this.textInput = input; }} /> >BigGreeter : Symbol(BigGreeter, Decl(file.tsx, 0, 32)) >ref : Symbol(ref, Decl(file.tsx, 13, 19)) >input : Symbol(input, Decl(file.tsx, 13, 26)) +>this : Symbol(GlobalThis) >input : Symbol(input, Decl(file.tsx, 13, 26)) let c = diff --git a/tests/baselines/reference/tsxAttributeResolution15.types b/tests/baselines/reference/tsxAttributeResolution15.types index b95dcffcaf7bb..eb8f2a7184538 100644 --- a/tests/baselines/reference/tsxAttributeResolution15.types +++ b/tests/baselines/reference/tsxAttributeResolution15.types @@ -37,7 +37,7 @@ let b = { this.textInput = input; }} /> >input : BigGreeter >this.textInput = input : BigGreeter >this.textInput : any ->this : any +>this : GlobalThis >textInput : any >input : BigGreeter diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols index e599665b156fd..1757e4c01074e 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols @@ -79,6 +79,7 @@ let e3 = { this.textInput = input; } }} /> >EmptyProp : Symbol(EmptyProp, Decl(file.tsx, 19, 30)) >ref : Symbol(ref, Decl(file.tsx, 31, 25)) >input : Symbol(input, Decl(file.tsx, 31, 32)) +>this : Symbol(GlobalThis) >input : Symbol(input, Decl(file.tsx, 31, 32)) let e4 = diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.types b/tests/baselines/reference/tsxSpreadAttributesResolution4.types index 194993348dc5f..f424de2feb0a9 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.types @@ -89,7 +89,7 @@ let e3 = { this.textInput = input; } }} /> >input : EmptyProp >this.textInput = input : EmptyProp >this.textInput : any ->this : any +>this : GlobalThis >textInput : any >input : EmptyProp diff --git a/tests/baselines/reference/unknownSymbols1.symbols b/tests/baselines/reference/unknownSymbols1.symbols index d9726011f1ac6..b61235aad9ea8 100644 --- a/tests/baselines/reference/unknownSymbols1.symbols +++ b/tests/baselines/reference/unknownSymbols1.symbols @@ -54,6 +54,7 @@ class C4 extends C3 { var x2 = this.asdf; // no error, this is any >x2 : Symbol(x2, Decl(unknownSymbols1.ts, 25, 3)) +>this : Symbol(GlobalThis) class C5 { >C5 : Symbol(C5, Decl(unknownSymbols1.ts, 25, 19)) diff --git a/tests/baselines/reference/unknownSymbols1.types b/tests/baselines/reference/unknownSymbols1.types index f453273348519..8eccd2bcdf690 100644 --- a/tests/baselines/reference/unknownSymbols1.types +++ b/tests/baselines/reference/unknownSymbols1.types @@ -57,7 +57,7 @@ class C4 extends C3 { var x2 = this.asdf; // no error, this is any >x2 : any >this.asdf : any ->this : any +>this : GlobalThis >asdf : any class C5 { diff --git a/tests/baselines/reference/wrappedIncovations1.symbols b/tests/baselines/reference/wrappedIncovations1.symbols index 49ccc1fa896ab..0c988bf0909c4 100644 --- a/tests/baselines/reference/wrappedIncovations1.symbols +++ b/tests/baselines/reference/wrappedIncovations1.symbols @@ -1,6 +1,7 @@ === tests/cases/compiler/wrappedIncovations1.ts === var v = this >v : Symbol(v, Decl(wrappedIncovations1.ts, 0, 3)) +>this : Symbol(GlobalThis) .foo() .bar() diff --git a/tests/baselines/reference/wrappedIncovations1.types b/tests/baselines/reference/wrappedIncovations1.types index 32f7bb0e1b846..4a41fb7430123 100644 --- a/tests/baselines/reference/wrappedIncovations1.types +++ b/tests/baselines/reference/wrappedIncovations1.types @@ -7,7 +7,7 @@ var v = this >this .foo() .bar : any >this .foo() : any >this .foo : any ->this : any +>this : GlobalThis .foo() >foo : any diff --git a/tests/baselines/reference/wrappedIncovations2.symbols b/tests/baselines/reference/wrappedIncovations2.symbols index 2836bf7c19cbe..3b7c7e6ac76de 100644 --- a/tests/baselines/reference/wrappedIncovations2.symbols +++ b/tests/baselines/reference/wrappedIncovations2.symbols @@ -1,6 +1,7 @@ === tests/cases/compiler/wrappedIncovations2.ts === var v = this. >v : Symbol(v, Decl(wrappedIncovations2.ts, 0, 3)) +>this : Symbol(GlobalThis) foo(). bar(). diff --git a/tests/baselines/reference/wrappedIncovations2.types b/tests/baselines/reference/wrappedIncovations2.types index 96337796bcd62..629a9d2224313 100644 --- a/tests/baselines/reference/wrappedIncovations2.types +++ b/tests/baselines/reference/wrappedIncovations2.types @@ -7,7 +7,7 @@ var v = this. >this. foo(). bar : any >this. foo() : any >this. foo : any ->this : any +>this : GlobalThis foo(). >foo : any From f07c5d62529f29d4a43a2fe1246964fb30fd10ad Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 8 Jan 2019 16:43:55 -0800 Subject: [PATCH 05/19] Handle type references to globalThis The type reference must be `typeof globalThis`. Just `globalThis` will be treated as a value reference in type position -- an error. --- src/compiler/checker.ts | 16 +- src/compiler/commandLineParser.ts | 1 + src/compiler/parser.ts | 6 +- src/compiler/scanner.ts | 1 + src/compiler/types.ts | 3 + .../reference/api/tsserverlibrary.d.ts | 394 +++++++++--------- tests/baselines/reference/api/typescript.d.ts | 394 +++++++++--------- .../reference/assignmentLHSIsValue.symbols | 4 +- .../reference/assignmentLHSIsValue.types | 6 +- .../castExpressionParentheses.symbols | 4 +- .../reference/castExpressionParentheses.types | 4 +- ...sionThisExpressionAndAliasInGlobal.symbols | 2 +- ...lisionThisExpressionAndAliasInGlobal.types | 6 +- ...sExpressionAndAmbientClassInGlobal.symbols | 2 +- ...hisExpressionAndAmbientClassInGlobal.types | 6 +- ...hisExpressionAndAmbientVarInGlobal.symbols | 2 +- ...nThisExpressionAndAmbientVarInGlobal.types | 6 +- ...sionThisExpressionAndClassInGlobal.symbols | 2 +- ...lisionThisExpressionAndClassInGlobal.types | 6 +- ...isionThisExpressionAndEnumInGlobal.symbols | 2 +- ...llisionThisExpressionAndEnumInGlobal.types | 6 +- ...nThisExpressionAndFunctionInGlobal.symbols | 2 +- ...ionThisExpressionAndFunctionInGlobal.types | 6 +- ...nThisExpressionAndLocalVarInLambda.symbols | 2 +- ...ionThisExpressionAndLocalVarInLambda.types | 2 +- ...ionThisExpressionAndModuleInGlobal.symbols | 2 +- ...isionThisExpressionAndModuleInGlobal.types | 6 +- ...lisionThisExpressionAndVarInGlobal.symbols | 2 +- ...ollisionThisExpressionAndVarInGlobal.types | 6 +- .../reference/commentsInterface.symbols | 12 +- .../reference/commentsInterface.types | 12 +- .../compoundAssignmentLHSIsValue.symbols | 8 +- .../compoundAssignmentLHSIsValue.types | 12 +- ...ExponentiationAssignmentLHSIsValue.symbols | 4 +- ...ndExponentiationAssignmentLHSIsValue.types | 6 +- .../computedPropertyNames20_ES5.symbols | 2 +- .../computedPropertyNames20_ES5.types | 2 +- .../computedPropertyNames20_ES6.symbols | 2 +- .../computedPropertyNames20_ES6.types | 2 +- ...ructorWithIncompleteTypeAnnotation.symbols | 2 +- ...structorWithIncompleteTypeAnnotation.types | 2 +- .../emitArrowFunctionThisCapturing.symbols | 6 +- .../emitArrowFunctionThisCapturing.types | 6 +- .../emitArrowFunctionThisCapturingES6.symbols | 6 +- .../emitArrowFunctionThisCapturingES6.types | 6 +- ...CapturingThisInTupleDestructuring1.symbols | 6 +- ...itCapturingThisInTupleDestructuring1.types | 6 +- .../reference/globalThisCapture.symbols | 2 +- .../reference/globalThisCapture.types | 2 +- .../globalThisVarDeclaration.symbols | 8 +- .../reference/globalThisVarDeclaration.types | 8 +- .../reference/implicitAnyInCatch.symbols | 2 +- .../reference/implicitAnyInCatch.types | 2 +- ...neJsxFactoryDeclarationsLocalTypes.symbols | 2 +- ...lineJsxFactoryDeclarationsLocalTypes.types | 2 +- ...jsxAttributeWithoutExpressionReact.symbols | 2 +- .../jsxAttributeWithoutExpressionReact.types | 2 +- .../reference/jsxReactTestSuite.symbols | 6 +- .../reference/jsxReactTestSuite.types | 6 +- ...pertyAccessAndArrowFunctionIndent1.symbols | 4 +- ...ropertyAccessAndArrowFunctionIndent1.types | 4 +- .../parserCommaInTypeMemberList2.symbols | 2 +- .../parserCommaInTypeMemberList2.types | 2 +- .../parserConditionalExpression1.symbols | 6 +- .../parserConditionalExpression1.types | 6 +- .../reference/parserForStatement8.symbols | 2 +- .../reference/parserForStatement8.types | 2 +- .../parserModifierOnStatementInBlock2.symbols | 2 +- .../parserModifierOnStatementInBlock2.types | 4 +- .../reference/parserStrictMode16.symbols | 2 +- .../reference/parserStrictMode16.types | 2 +- .../reference/parserUnaryExpression1.symbols | 2 +- .../reference/parserUnaryExpression1.types | 2 +- .../reference/propertyWrappedInTry.symbols | 2 +- .../reference/propertyWrappedInTry.types | 2 +- .../thisInInvalidContexts.errors.txt | 4 +- .../reference/thisInInvalidContexts.symbols | 2 +- .../reference/thisInInvalidContexts.types | 2 +- ...InInvalidContextsExternalModule.errors.txt | 4 +- ...hisInInvalidContextsExternalModule.symbols | 2 +- .../thisInInvalidContextsExternalModule.types | 2 +- .../reference/thisTypeInFunctions.symbols | 10 +- .../reference/thisTypeInFunctions.types | 10 +- .../thisTypeInFunctionsNegative.symbols | 12 +- .../thisTypeInFunctionsNegative.types | 12 +- .../reference/topLevelLambda2.symbols | 2 +- .../baselines/reference/topLevelLambda2.types | 2 +- .../reference/topLevelLambda3.symbols | 2 +- .../baselines/reference/topLevelLambda3.types | 2 +- .../reference/topLevelLambda4.symbols | 2 +- .../baselines/reference/topLevelLambda4.types | 2 +- .../reference/topLevelThisAssignment.symbols | 6 +- .../reference/topLevelThisAssignment.types | 6 +- .../tsxAttributeResolution15.symbols | 2 +- .../reference/tsxAttributeResolution15.types | 2 +- .../tsxSpreadAttributesResolution4.symbols | 2 +- .../tsxSpreadAttributesResolution4.types | 2 +- .../typeFromPropertyAssignment23.symbols | 2 +- .../typeFromPropertyAssignment23.types | 2 +- .../typeFromPropertyAssignment9.symbols | 2 +- .../typeFromPropertyAssignment9.types | 2 +- .../baselines/reference/typeOfThis.errors.txt | 38 +- tests/baselines/reference/typeOfThis.js | 200 ++++----- tests/baselines/reference/typeOfThis.symbols | 17 +- tests/baselines/reference/typeOfThis.types | 40 +- .../reference/unknownSymbols1.symbols | 2 +- .../baselines/reference/unknownSymbols1.types | 2 +- .../reference/wrappedIncovations1.symbols | 2 +- .../reference/wrappedIncovations1.types | 2 +- .../reference/wrappedIncovations2.symbols | 2 +- .../reference/wrappedIncovations2.types | 2 +- .../es2019/globalThisVarDeclaration.ts | 14 + .../expressions/thisKeyword/typeOfThis.ts | 11 +- 113 files changed, 755 insertions(+), 770 deletions(-) create mode 100644 tests/cases/conformance/es2019/globalThisVarDeclaration.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 18d4098f661bd..c3f9d436dca3b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8978,12 +8978,12 @@ namespace ts { } function getGlobalThisType() { - // TODO: Maybe should allow d.ts file to override this via getGlobalTypeSymbol? Probably? Or just Window? - const t = createObjectType(ObjectFlags.Interface, createSymbol(SymbolFlags.Type, "GlobalThis" as __String)); - setStructuredTypeMembers(t, globals, emptyArray, emptyArray, createIndexInfo(anyType, /*isReadonly*/ false), undefined); - return deferredGlobalThisType || - (deferredGlobalThisType = t) || - emptyObjectType; + if (!deferredGlobalThisType) { + const t = createObjectType(ObjectFlags.Interface, createSymbol(SymbolFlags.Type, "typeof globalThis" as __String)); + setStructuredTypeMembers(t, globals, emptyArray, emptyArray, createIndexInfo(anyType, /*isReadonly*/ false), undefined); + deferredGlobalThisType = t; + } + return deferredGlobalThisType; } function getGlobalExtractSymbol(): Symbol { @@ -10117,6 +10117,10 @@ namespace ts { function getTypeFromImportTypeNode(node: ImportTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { + if (node.isGlobalThis) { + Debug.assert(!!node.isTypeOf); + return links.resolvedType = getGlobalThisType(); + } if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments error(node, Diagnostics.Type_arguments_cannot_be_used_here); links.resolvedSymbol = unknownSymbol; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 43275605e2390..53bbb14776b1b 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -42,6 +42,7 @@ namespace ts { ["es2018.promise", "lib.es2018.promise.d.ts"], ["es2018.regexp", "lib.es2018.regexp.d.ts"], ["esnext.array", "lib.esnext.array.d.ts"], + ["esnext.globalthis", "lib.esnext.globalthis.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f976f77ea985a..7986c58575369 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2869,7 +2869,7 @@ namespace ts { function isStartOfTypeOfImportType() { nextToken(); - return token() === SyntaxKind.ImportKeyword; + return token() === SyntaxKind.ImportKeyword || token() === SyntaxKind.GlobalThisKeyword; } function parseImportType(): ImportTypeNode { @@ -2877,6 +2877,10 @@ namespace ts { const node = createNode(SyntaxKind.ImportType) as ImportTypeNode; if (parseOptional(SyntaxKind.TypeOfKeyword)) { node.isTypeOf = true; + node.isGlobalThis = parseOptional(SyntaxKind.GlobalThisKeyword); + if (node.isGlobalThis) { + return finishNode(node); + } } parseExpected(SyntaxKind.ImportKeyword); parseExpected(SyntaxKind.OpenParenToken); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index d59be9758656c..045349ae99df6 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -88,6 +88,7 @@ namespace ts { from: SyntaxKind.FromKeyword, function: SyntaxKind.FunctionKeyword, get: SyntaxKind.GetKeyword, + globalThis: SyntaxKind.GlobalThisKeyword, if: SyntaxKind.IfKeyword, implements: SyntaxKind.ImplementsKeyword, import: SyntaxKind.ImportKeyword, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5c42d3eb5104c..8917bef9d3f0a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -55,6 +55,7 @@ namespace ts { | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword + | SyntaxKind.GlobalThisKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword @@ -254,6 +255,7 @@ namespace ts { ConstructorKeyword, DeclareKeyword, GetKeyword, + GlobalThisKeyword, InferKeyword, IsKeyword, KeyOfKeyword, @@ -1125,6 +1127,7 @@ namespace ts { export interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; + isGlobalThis: boolean; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 91f492ddd1d52..20886502c37c9 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -73,7 +73,7 @@ declare namespace ts { end: number; } type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalThisKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { Unknown = 0, @@ -203,192 +203,193 @@ declare namespace ts { ConstructorKeyword = 124, DeclareKeyword = 125, GetKeyword = 126, - InferKeyword = 127, - IsKeyword = 128, - KeyOfKeyword = 129, - ModuleKeyword = 130, - NamespaceKeyword = 131, - NeverKeyword = 132, - ReadonlyKeyword = 133, - RequireKeyword = 134, - NumberKeyword = 135, - ObjectKeyword = 136, - SetKeyword = 137, - StringKeyword = 138, - SymbolKeyword = 139, - TypeKeyword = 140, - UndefinedKeyword = 141, - UniqueKeyword = 142, - UnknownKeyword = 143, - FromKeyword = 144, - GlobalKeyword = 145, - BigIntKeyword = 146, - OfKeyword = 147, - QualifiedName = 148, - ComputedPropertyName = 149, - TypeParameter = 150, - Parameter = 151, - Decorator = 152, - PropertySignature = 153, - PropertyDeclaration = 154, - MethodSignature = 155, - MethodDeclaration = 156, - Constructor = 157, - GetAccessor = 158, - SetAccessor = 159, - CallSignature = 160, - ConstructSignature = 161, - IndexSignature = 162, - TypePredicate = 163, - TypeReference = 164, - FunctionType = 165, - ConstructorType = 166, - TypeQuery = 167, - TypeLiteral = 168, - ArrayType = 169, - TupleType = 170, - OptionalType = 171, - RestType = 172, - UnionType = 173, - IntersectionType = 174, - ConditionalType = 175, - InferType = 176, - ParenthesizedType = 177, - ThisType = 178, - TypeOperator = 179, - IndexedAccessType = 180, - MappedType = 181, - LiteralType = 182, - ImportType = 183, - ObjectBindingPattern = 184, - ArrayBindingPattern = 185, - BindingElement = 186, - ArrayLiteralExpression = 187, - ObjectLiteralExpression = 188, - PropertyAccessExpression = 189, - ElementAccessExpression = 190, - CallExpression = 191, - NewExpression = 192, - TaggedTemplateExpression = 193, - TypeAssertionExpression = 194, - ParenthesizedExpression = 195, - FunctionExpression = 196, - ArrowFunction = 197, - DeleteExpression = 198, - TypeOfExpression = 199, - VoidExpression = 200, - AwaitExpression = 201, - PrefixUnaryExpression = 202, - PostfixUnaryExpression = 203, - BinaryExpression = 204, - ConditionalExpression = 205, - TemplateExpression = 206, - YieldExpression = 207, - SpreadElement = 208, - ClassExpression = 209, - OmittedExpression = 210, - ExpressionWithTypeArguments = 211, - AsExpression = 212, - NonNullExpression = 213, - MetaProperty = 214, - SyntheticExpression = 215, - TemplateSpan = 216, - SemicolonClassElement = 217, - Block = 218, - VariableStatement = 219, - EmptyStatement = 220, - ExpressionStatement = 221, - IfStatement = 222, - DoStatement = 223, - WhileStatement = 224, - ForStatement = 225, - ForInStatement = 226, - ForOfStatement = 227, - ContinueStatement = 228, - BreakStatement = 229, - ReturnStatement = 230, - WithStatement = 231, - SwitchStatement = 232, - LabeledStatement = 233, - ThrowStatement = 234, - TryStatement = 235, - DebuggerStatement = 236, - VariableDeclaration = 237, - VariableDeclarationList = 238, - FunctionDeclaration = 239, - ClassDeclaration = 240, - InterfaceDeclaration = 241, - TypeAliasDeclaration = 242, - EnumDeclaration = 243, - ModuleDeclaration = 244, - ModuleBlock = 245, - CaseBlock = 246, - NamespaceExportDeclaration = 247, - ImportEqualsDeclaration = 248, - ImportDeclaration = 249, - ImportClause = 250, - NamespaceImport = 251, - NamedImports = 252, - ImportSpecifier = 253, - ExportAssignment = 254, - ExportDeclaration = 255, - NamedExports = 256, - ExportSpecifier = 257, - MissingDeclaration = 258, - ExternalModuleReference = 259, - JsxElement = 260, - JsxSelfClosingElement = 261, - JsxOpeningElement = 262, - JsxClosingElement = 263, - JsxFragment = 264, - JsxOpeningFragment = 265, - JsxClosingFragment = 266, - JsxAttribute = 267, - JsxAttributes = 268, - JsxSpreadAttribute = 269, - JsxExpression = 270, - CaseClause = 271, - DefaultClause = 272, - HeritageClause = 273, - CatchClause = 274, - PropertyAssignment = 275, - ShorthandPropertyAssignment = 276, - SpreadAssignment = 277, - EnumMember = 278, - SourceFile = 279, - Bundle = 280, - UnparsedSource = 281, - InputFiles = 282, - JSDocTypeExpression = 283, - JSDocAllType = 284, - JSDocUnknownType = 285, - JSDocNullableType = 286, - JSDocNonNullableType = 287, - JSDocOptionalType = 288, - JSDocFunctionType = 289, - JSDocVariadicType = 290, - JSDocComment = 291, - JSDocTypeLiteral = 292, - JSDocSignature = 293, - JSDocTag = 294, - JSDocAugmentsTag = 295, - JSDocClassTag = 296, - JSDocCallbackTag = 297, - JSDocEnumTag = 298, - JSDocParameterTag = 299, - JSDocReturnTag = 300, - JSDocThisTag = 301, - JSDocTypeTag = 302, - JSDocTemplateTag = 303, - JSDocTypedefTag = 304, - JSDocPropertyTag = 305, - SyntaxList = 306, - NotEmittedStatement = 307, - PartiallyEmittedExpression = 308, - CommaListExpression = 309, - MergeDeclarationMarker = 310, - EndOfDeclarationMarker = 311, - Count = 312, + GlobalThisKeyword = 127, + InferKeyword = 128, + IsKeyword = 129, + KeyOfKeyword = 130, + ModuleKeyword = 131, + NamespaceKeyword = 132, + NeverKeyword = 133, + ReadonlyKeyword = 134, + RequireKeyword = 135, + NumberKeyword = 136, + ObjectKeyword = 137, + SetKeyword = 138, + StringKeyword = 139, + SymbolKeyword = 140, + TypeKeyword = 141, + UndefinedKeyword = 142, + UniqueKeyword = 143, + UnknownKeyword = 144, + FromKeyword = 145, + GlobalKeyword = 146, + BigIntKeyword = 147, + OfKeyword = 148, + QualifiedName = 149, + ComputedPropertyName = 150, + TypeParameter = 151, + Parameter = 152, + Decorator = 153, + PropertySignature = 154, + PropertyDeclaration = 155, + MethodSignature = 156, + MethodDeclaration = 157, + Constructor = 158, + GetAccessor = 159, + SetAccessor = 160, + CallSignature = 161, + ConstructSignature = 162, + IndexSignature = 163, + TypePredicate = 164, + TypeReference = 165, + FunctionType = 166, + ConstructorType = 167, + TypeQuery = 168, + TypeLiteral = 169, + ArrayType = 170, + TupleType = 171, + OptionalType = 172, + RestType = 173, + UnionType = 174, + IntersectionType = 175, + ConditionalType = 176, + InferType = 177, + ParenthesizedType = 178, + ThisType = 179, + TypeOperator = 180, + IndexedAccessType = 181, + MappedType = 182, + LiteralType = 183, + ImportType = 184, + ObjectBindingPattern = 185, + ArrayBindingPattern = 186, + BindingElement = 187, + ArrayLiteralExpression = 188, + ObjectLiteralExpression = 189, + PropertyAccessExpression = 190, + ElementAccessExpression = 191, + CallExpression = 192, + NewExpression = 193, + TaggedTemplateExpression = 194, + TypeAssertionExpression = 195, + ParenthesizedExpression = 196, + FunctionExpression = 197, + ArrowFunction = 198, + DeleteExpression = 199, + TypeOfExpression = 200, + VoidExpression = 201, + AwaitExpression = 202, + PrefixUnaryExpression = 203, + PostfixUnaryExpression = 204, + BinaryExpression = 205, + ConditionalExpression = 206, + TemplateExpression = 207, + YieldExpression = 208, + SpreadElement = 209, + ClassExpression = 210, + OmittedExpression = 211, + ExpressionWithTypeArguments = 212, + AsExpression = 213, + NonNullExpression = 214, + MetaProperty = 215, + SyntheticExpression = 216, + TemplateSpan = 217, + SemicolonClassElement = 218, + Block = 219, + VariableStatement = 220, + EmptyStatement = 221, + ExpressionStatement = 222, + IfStatement = 223, + DoStatement = 224, + WhileStatement = 225, + ForStatement = 226, + ForInStatement = 227, + ForOfStatement = 228, + ContinueStatement = 229, + BreakStatement = 230, + ReturnStatement = 231, + WithStatement = 232, + SwitchStatement = 233, + LabeledStatement = 234, + ThrowStatement = 235, + TryStatement = 236, + DebuggerStatement = 237, + VariableDeclaration = 238, + VariableDeclarationList = 239, + FunctionDeclaration = 240, + ClassDeclaration = 241, + InterfaceDeclaration = 242, + TypeAliasDeclaration = 243, + EnumDeclaration = 244, + ModuleDeclaration = 245, + ModuleBlock = 246, + CaseBlock = 247, + NamespaceExportDeclaration = 248, + ImportEqualsDeclaration = 249, + ImportDeclaration = 250, + ImportClause = 251, + NamespaceImport = 252, + NamedImports = 253, + ImportSpecifier = 254, + ExportAssignment = 255, + ExportDeclaration = 256, + NamedExports = 257, + ExportSpecifier = 258, + MissingDeclaration = 259, + ExternalModuleReference = 260, + JsxElement = 261, + JsxSelfClosingElement = 262, + JsxOpeningElement = 263, + JsxClosingElement = 264, + JsxFragment = 265, + JsxOpeningFragment = 266, + JsxClosingFragment = 267, + JsxAttribute = 268, + JsxAttributes = 269, + JsxSpreadAttribute = 270, + JsxExpression = 271, + CaseClause = 272, + DefaultClause = 273, + HeritageClause = 274, + CatchClause = 275, + PropertyAssignment = 276, + ShorthandPropertyAssignment = 277, + SpreadAssignment = 278, + EnumMember = 279, + SourceFile = 280, + Bundle = 281, + UnparsedSource = 282, + InputFiles = 283, + JSDocTypeExpression = 284, + JSDocAllType = 285, + JSDocUnknownType = 286, + JSDocNullableType = 287, + JSDocNonNullableType = 288, + JSDocOptionalType = 289, + JSDocFunctionType = 290, + JSDocVariadicType = 291, + JSDocComment = 292, + JSDocTypeLiteral = 293, + JSDocSignature = 294, + JSDocTag = 295, + JSDocAugmentsTag = 296, + JSDocClassTag = 297, + JSDocCallbackTag = 298, + JSDocEnumTag = 299, + JSDocParameterTag = 300, + JSDocReturnTag = 301, + JSDocThisTag = 302, + JSDocTypeTag = 303, + JSDocTemplateTag = 304, + JSDocTypedefTag = 305, + JSDocPropertyTag = 306, + SyntaxList = 307, + NotEmittedStatement = 308, + PartiallyEmittedExpression = 309, + CommaListExpression = 310, + MergeDeclarationMarker = 311, + EndOfDeclarationMarker = 312, + Count = 313, FirstAssignment = 59, LastAssignment = 71, FirstCompoundAssignment = 60, @@ -396,15 +397,15 @@ declare namespace ts { FirstReservedWord = 73, LastReservedWord = 108, FirstKeyword = 73, - LastKeyword = 147, + LastKeyword = 148, FirstFutureReservedWord = 109, LastFutureReservedWord = 117, - FirstTypeNode = 163, - LastTypeNode = 183, + FirstTypeNode = 164, + LastTypeNode = 184, FirstPunctuation = 18, LastPunctuation = 71, FirstToken = 0, - LastToken = 147, + LastToken = 148, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -413,11 +414,11 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 71, - FirstNode = 148, - FirstJSDocNode = 283, - LastJSDocNode = 305, - FirstJSDocTagNode = 294, - LastJSDocTagNode = 305 + FirstNode = 149, + FirstJSDocNode = 284, + LastJSDocNode = 306, + FirstJSDocTagNode = 295, + LastJSDocTagNode = 306 } enum NodeFlags { None = 0, @@ -732,6 +733,7 @@ declare namespace ts { } interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; + isGlobalThis: boolean; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 0e693f698f253..c747edf0e95ba 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -73,7 +73,7 @@ declare namespace ts { end: number; } type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalThisKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { Unknown = 0, @@ -203,192 +203,193 @@ declare namespace ts { ConstructorKeyword = 124, DeclareKeyword = 125, GetKeyword = 126, - InferKeyword = 127, - IsKeyword = 128, - KeyOfKeyword = 129, - ModuleKeyword = 130, - NamespaceKeyword = 131, - NeverKeyword = 132, - ReadonlyKeyword = 133, - RequireKeyword = 134, - NumberKeyword = 135, - ObjectKeyword = 136, - SetKeyword = 137, - StringKeyword = 138, - SymbolKeyword = 139, - TypeKeyword = 140, - UndefinedKeyword = 141, - UniqueKeyword = 142, - UnknownKeyword = 143, - FromKeyword = 144, - GlobalKeyword = 145, - BigIntKeyword = 146, - OfKeyword = 147, - QualifiedName = 148, - ComputedPropertyName = 149, - TypeParameter = 150, - Parameter = 151, - Decorator = 152, - PropertySignature = 153, - PropertyDeclaration = 154, - MethodSignature = 155, - MethodDeclaration = 156, - Constructor = 157, - GetAccessor = 158, - SetAccessor = 159, - CallSignature = 160, - ConstructSignature = 161, - IndexSignature = 162, - TypePredicate = 163, - TypeReference = 164, - FunctionType = 165, - ConstructorType = 166, - TypeQuery = 167, - TypeLiteral = 168, - ArrayType = 169, - TupleType = 170, - OptionalType = 171, - RestType = 172, - UnionType = 173, - IntersectionType = 174, - ConditionalType = 175, - InferType = 176, - ParenthesizedType = 177, - ThisType = 178, - TypeOperator = 179, - IndexedAccessType = 180, - MappedType = 181, - LiteralType = 182, - ImportType = 183, - ObjectBindingPattern = 184, - ArrayBindingPattern = 185, - BindingElement = 186, - ArrayLiteralExpression = 187, - ObjectLiteralExpression = 188, - PropertyAccessExpression = 189, - ElementAccessExpression = 190, - CallExpression = 191, - NewExpression = 192, - TaggedTemplateExpression = 193, - TypeAssertionExpression = 194, - ParenthesizedExpression = 195, - FunctionExpression = 196, - ArrowFunction = 197, - DeleteExpression = 198, - TypeOfExpression = 199, - VoidExpression = 200, - AwaitExpression = 201, - PrefixUnaryExpression = 202, - PostfixUnaryExpression = 203, - BinaryExpression = 204, - ConditionalExpression = 205, - TemplateExpression = 206, - YieldExpression = 207, - SpreadElement = 208, - ClassExpression = 209, - OmittedExpression = 210, - ExpressionWithTypeArguments = 211, - AsExpression = 212, - NonNullExpression = 213, - MetaProperty = 214, - SyntheticExpression = 215, - TemplateSpan = 216, - SemicolonClassElement = 217, - Block = 218, - VariableStatement = 219, - EmptyStatement = 220, - ExpressionStatement = 221, - IfStatement = 222, - DoStatement = 223, - WhileStatement = 224, - ForStatement = 225, - ForInStatement = 226, - ForOfStatement = 227, - ContinueStatement = 228, - BreakStatement = 229, - ReturnStatement = 230, - WithStatement = 231, - SwitchStatement = 232, - LabeledStatement = 233, - ThrowStatement = 234, - TryStatement = 235, - DebuggerStatement = 236, - VariableDeclaration = 237, - VariableDeclarationList = 238, - FunctionDeclaration = 239, - ClassDeclaration = 240, - InterfaceDeclaration = 241, - TypeAliasDeclaration = 242, - EnumDeclaration = 243, - ModuleDeclaration = 244, - ModuleBlock = 245, - CaseBlock = 246, - NamespaceExportDeclaration = 247, - ImportEqualsDeclaration = 248, - ImportDeclaration = 249, - ImportClause = 250, - NamespaceImport = 251, - NamedImports = 252, - ImportSpecifier = 253, - ExportAssignment = 254, - ExportDeclaration = 255, - NamedExports = 256, - ExportSpecifier = 257, - MissingDeclaration = 258, - ExternalModuleReference = 259, - JsxElement = 260, - JsxSelfClosingElement = 261, - JsxOpeningElement = 262, - JsxClosingElement = 263, - JsxFragment = 264, - JsxOpeningFragment = 265, - JsxClosingFragment = 266, - JsxAttribute = 267, - JsxAttributes = 268, - JsxSpreadAttribute = 269, - JsxExpression = 270, - CaseClause = 271, - DefaultClause = 272, - HeritageClause = 273, - CatchClause = 274, - PropertyAssignment = 275, - ShorthandPropertyAssignment = 276, - SpreadAssignment = 277, - EnumMember = 278, - SourceFile = 279, - Bundle = 280, - UnparsedSource = 281, - InputFiles = 282, - JSDocTypeExpression = 283, - JSDocAllType = 284, - JSDocUnknownType = 285, - JSDocNullableType = 286, - JSDocNonNullableType = 287, - JSDocOptionalType = 288, - JSDocFunctionType = 289, - JSDocVariadicType = 290, - JSDocComment = 291, - JSDocTypeLiteral = 292, - JSDocSignature = 293, - JSDocTag = 294, - JSDocAugmentsTag = 295, - JSDocClassTag = 296, - JSDocCallbackTag = 297, - JSDocEnumTag = 298, - JSDocParameterTag = 299, - JSDocReturnTag = 300, - JSDocThisTag = 301, - JSDocTypeTag = 302, - JSDocTemplateTag = 303, - JSDocTypedefTag = 304, - JSDocPropertyTag = 305, - SyntaxList = 306, - NotEmittedStatement = 307, - PartiallyEmittedExpression = 308, - CommaListExpression = 309, - MergeDeclarationMarker = 310, - EndOfDeclarationMarker = 311, - Count = 312, + GlobalThisKeyword = 127, + InferKeyword = 128, + IsKeyword = 129, + KeyOfKeyword = 130, + ModuleKeyword = 131, + NamespaceKeyword = 132, + NeverKeyword = 133, + ReadonlyKeyword = 134, + RequireKeyword = 135, + NumberKeyword = 136, + ObjectKeyword = 137, + SetKeyword = 138, + StringKeyword = 139, + SymbolKeyword = 140, + TypeKeyword = 141, + UndefinedKeyword = 142, + UniqueKeyword = 143, + UnknownKeyword = 144, + FromKeyword = 145, + GlobalKeyword = 146, + BigIntKeyword = 147, + OfKeyword = 148, + QualifiedName = 149, + ComputedPropertyName = 150, + TypeParameter = 151, + Parameter = 152, + Decorator = 153, + PropertySignature = 154, + PropertyDeclaration = 155, + MethodSignature = 156, + MethodDeclaration = 157, + Constructor = 158, + GetAccessor = 159, + SetAccessor = 160, + CallSignature = 161, + ConstructSignature = 162, + IndexSignature = 163, + TypePredicate = 164, + TypeReference = 165, + FunctionType = 166, + ConstructorType = 167, + TypeQuery = 168, + TypeLiteral = 169, + ArrayType = 170, + TupleType = 171, + OptionalType = 172, + RestType = 173, + UnionType = 174, + IntersectionType = 175, + ConditionalType = 176, + InferType = 177, + ParenthesizedType = 178, + ThisType = 179, + TypeOperator = 180, + IndexedAccessType = 181, + MappedType = 182, + LiteralType = 183, + ImportType = 184, + ObjectBindingPattern = 185, + ArrayBindingPattern = 186, + BindingElement = 187, + ArrayLiteralExpression = 188, + ObjectLiteralExpression = 189, + PropertyAccessExpression = 190, + ElementAccessExpression = 191, + CallExpression = 192, + NewExpression = 193, + TaggedTemplateExpression = 194, + TypeAssertionExpression = 195, + ParenthesizedExpression = 196, + FunctionExpression = 197, + ArrowFunction = 198, + DeleteExpression = 199, + TypeOfExpression = 200, + VoidExpression = 201, + AwaitExpression = 202, + PrefixUnaryExpression = 203, + PostfixUnaryExpression = 204, + BinaryExpression = 205, + ConditionalExpression = 206, + TemplateExpression = 207, + YieldExpression = 208, + SpreadElement = 209, + ClassExpression = 210, + OmittedExpression = 211, + ExpressionWithTypeArguments = 212, + AsExpression = 213, + NonNullExpression = 214, + MetaProperty = 215, + SyntheticExpression = 216, + TemplateSpan = 217, + SemicolonClassElement = 218, + Block = 219, + VariableStatement = 220, + EmptyStatement = 221, + ExpressionStatement = 222, + IfStatement = 223, + DoStatement = 224, + WhileStatement = 225, + ForStatement = 226, + ForInStatement = 227, + ForOfStatement = 228, + ContinueStatement = 229, + BreakStatement = 230, + ReturnStatement = 231, + WithStatement = 232, + SwitchStatement = 233, + LabeledStatement = 234, + ThrowStatement = 235, + TryStatement = 236, + DebuggerStatement = 237, + VariableDeclaration = 238, + VariableDeclarationList = 239, + FunctionDeclaration = 240, + ClassDeclaration = 241, + InterfaceDeclaration = 242, + TypeAliasDeclaration = 243, + EnumDeclaration = 244, + ModuleDeclaration = 245, + ModuleBlock = 246, + CaseBlock = 247, + NamespaceExportDeclaration = 248, + ImportEqualsDeclaration = 249, + ImportDeclaration = 250, + ImportClause = 251, + NamespaceImport = 252, + NamedImports = 253, + ImportSpecifier = 254, + ExportAssignment = 255, + ExportDeclaration = 256, + NamedExports = 257, + ExportSpecifier = 258, + MissingDeclaration = 259, + ExternalModuleReference = 260, + JsxElement = 261, + JsxSelfClosingElement = 262, + JsxOpeningElement = 263, + JsxClosingElement = 264, + JsxFragment = 265, + JsxOpeningFragment = 266, + JsxClosingFragment = 267, + JsxAttribute = 268, + JsxAttributes = 269, + JsxSpreadAttribute = 270, + JsxExpression = 271, + CaseClause = 272, + DefaultClause = 273, + HeritageClause = 274, + CatchClause = 275, + PropertyAssignment = 276, + ShorthandPropertyAssignment = 277, + SpreadAssignment = 278, + EnumMember = 279, + SourceFile = 280, + Bundle = 281, + UnparsedSource = 282, + InputFiles = 283, + JSDocTypeExpression = 284, + JSDocAllType = 285, + JSDocUnknownType = 286, + JSDocNullableType = 287, + JSDocNonNullableType = 288, + JSDocOptionalType = 289, + JSDocFunctionType = 290, + JSDocVariadicType = 291, + JSDocComment = 292, + JSDocTypeLiteral = 293, + JSDocSignature = 294, + JSDocTag = 295, + JSDocAugmentsTag = 296, + JSDocClassTag = 297, + JSDocCallbackTag = 298, + JSDocEnumTag = 299, + JSDocParameterTag = 300, + JSDocReturnTag = 301, + JSDocThisTag = 302, + JSDocTypeTag = 303, + JSDocTemplateTag = 304, + JSDocTypedefTag = 305, + JSDocPropertyTag = 306, + SyntaxList = 307, + NotEmittedStatement = 308, + PartiallyEmittedExpression = 309, + CommaListExpression = 310, + MergeDeclarationMarker = 311, + EndOfDeclarationMarker = 312, + Count = 313, FirstAssignment = 59, LastAssignment = 71, FirstCompoundAssignment = 60, @@ -396,15 +397,15 @@ declare namespace ts { FirstReservedWord = 73, LastReservedWord = 108, FirstKeyword = 73, - LastKeyword = 147, + LastKeyword = 148, FirstFutureReservedWord = 109, LastFutureReservedWord = 117, - FirstTypeNode = 163, - LastTypeNode = 183, + FirstTypeNode = 164, + LastTypeNode = 184, FirstPunctuation = 18, LastPunctuation = 71, FirstToken = 0, - LastToken = 147, + LastToken = 148, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -413,11 +414,11 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 71, - FirstNode = 148, - FirstJSDocNode = 283, - LastJSDocNode = 305, - FirstJSDocTagNode = 294, - LastJSDocTagNode = 305 + FirstNode = 149, + FirstJSDocNode = 284, + LastJSDocNode = 306, + FirstJSDocTagNode = 295, + LastJSDocTagNode = 306 } enum NodeFlags { None = 0, @@ -732,6 +733,7 @@ declare namespace ts { } interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; + isGlobalThis: boolean; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; diff --git a/tests/baselines/reference/assignmentLHSIsValue.symbols b/tests/baselines/reference/assignmentLHSIsValue.symbols index 4fc74db7ab825..4af81616834b7 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.symbols +++ b/tests/baselines/reference/assignmentLHSIsValue.symbols @@ -27,7 +27,7 @@ function foo() { this = value; } >value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) this = value; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) // identifiers: module, class, enum, function @@ -117,7 +117,7 @@ foo() = value; // parentheses, the containted expression is value (this) = value; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) (M) = value; diff --git a/tests/baselines/reference/assignmentLHSIsValue.types b/tests/baselines/reference/assignmentLHSIsValue.types index e7b66a559f94b..81fd5dc537b5a 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.types +++ b/tests/baselines/reference/assignmentLHSIsValue.types @@ -33,7 +33,7 @@ function foo() { this = value; } this = value; >this = value : any ->this : GlobalThis +>this : typeof globalThis >value : any // identifiers: module, class, enum, function @@ -159,8 +159,8 @@ foo() = value; // parentheses, the containted expression is value (this) = value; >(this) = value : any ->(this) : GlobalThis ->this : GlobalThis +>(this) : typeof globalThis +>this : typeof globalThis >value : any (M) = value; diff --git a/tests/baselines/reference/castExpressionParentheses.symbols b/tests/baselines/reference/castExpressionParentheses.symbols index 3dcf8828deb38..40434e49351c2 100644 --- a/tests/baselines/reference/castExpressionParentheses.symbols +++ b/tests/baselines/reference/castExpressionParentheses.symbols @@ -21,10 +21,10 @@ declare var a; (null); // names and dotted names (this); ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) (this.x); ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) ((a).x); >a : Symbol(a, Decl(castExpressionParentheses.ts, 0, 11)) diff --git a/tests/baselines/reference/castExpressionParentheses.types b/tests/baselines/reference/castExpressionParentheses.types index f07d0e65f36d3..a2d789577a018 100644 --- a/tests/baselines/reference/castExpressionParentheses.types +++ b/tests/baselines/reference/castExpressionParentheses.types @@ -77,13 +77,13 @@ declare var a; (this); >(this) : any >this : any ->this : GlobalThis +>this : typeof globalThis (this.x); >(this.x) : any >this.x : any >this.x : any ->this : GlobalThis +>this : typeof globalThis >x : any ((a).x); diff --git a/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols index 9dd035002a5c1..a09cbf16ccd63 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols @@ -7,7 +7,7 @@ module a { } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndAliasInGlobal.ts, 3, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) import _this = a; // Error >_this : Symbol(_this, Decl(collisionThisExpressionAndAliasInGlobal.ts, 3, 19)) diff --git a/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.types index f30e9fe1b80f7..1a4b1c9182114 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.types @@ -7,9 +7,9 @@ module a { >10 : 10 } var f = () => this; ->f : () => GlobalThis ->() => this : () => GlobalThis ->this : GlobalThis +>f : () => typeof globalThis +>() => this : () => typeof globalThis +>this : typeof globalThis import _this = a; // Error >_this : typeof a diff --git a/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols index 9d126a7d3393d..a2f376ae1b29f 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols @@ -4,7 +4,7 @@ declare class _this { // no error - as no code generation } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndAmbientClassInGlobal.ts, 2, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) var a = new _this(); // Error >a : Symbol(a, Decl(collisionThisExpressionAndAmbientClassInGlobal.ts, 3, 3)) diff --git a/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.types index 88302206ad2f8..886e0c70eea2a 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.types @@ -3,9 +3,9 @@ declare class _this { // no error - as no code generation >_this : _this } var f = () => this; ->f : () => GlobalThis ->() => this : () => GlobalThis ->this : GlobalThis +>f : () => typeof globalThis +>() => this : () => typeof globalThis +>this : typeof globalThis var a = new _this(); // Error >a : _this diff --git a/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols index eb09871949d0a..3bc464d2e2aa0 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols @@ -4,7 +4,7 @@ declare var _this: number; // no error as no code gen var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndAmbientVarInGlobal.ts, 1, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) _this = 10; // Error >_this : Symbol(_this, Decl(collisionThisExpressionAndAmbientVarInGlobal.ts, 0, 11)) diff --git a/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.types index ec6c041eb41f7..ed58281dfd687 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.types @@ -3,9 +3,9 @@ declare var _this: number; // no error as no code gen >_this : number var f = () => this; ->f : () => GlobalThis ->() => this : () => GlobalThis ->this : GlobalThis +>f : () => typeof globalThis +>() => this : () => typeof globalThis +>this : typeof globalThis _this = 10; // Error >_this = 10 : 10 diff --git a/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols index 0a1dc32c0bf88..170b62d9ad770 100644 --- a/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols @@ -4,5 +4,5 @@ class _this { } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndClassInGlobal.ts, 2, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.types index 85f079b1a36c6..f68d4212c1f47 100644 --- a/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.types @@ -3,7 +3,7 @@ class _this { >_this : _this } var f = () => this; ->f : () => GlobalThis ->() => this : () => GlobalThis ->this : GlobalThis +>f : () => typeof globalThis +>() => this : () => typeof globalThis +>this : typeof globalThis diff --git a/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols index 51f156bba049e..5b1530d1e40f4 100644 --- a/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols @@ -10,5 +10,5 @@ enum _this { // Error } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndEnumInGlobal.ts, 4, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.types index 534704a77ef8a..5be7877f4e92f 100644 --- a/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.types @@ -9,7 +9,7 @@ enum _this { // Error >_thisVal2 : _this._thisVal2 } var f = () => this; ->f : () => GlobalThis ->() => this : () => GlobalThis ->this : GlobalThis +>f : () => typeof globalThis +>() => this : () => typeof globalThis +>this : typeof globalThis diff --git a/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols index 58e3f08726b01..63e067f573ad0 100644 --- a/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols @@ -6,5 +6,5 @@ function _this() { //Error } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndFunctionInGlobal.ts, 3, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.types index 646669c6b4c75..d3e4b57f58cd1 100644 --- a/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.types @@ -6,7 +6,7 @@ function _this() { //Error >10 : 10 } var f = () => this; ->f : () => GlobalThis ->() => this : () => GlobalThis ->this : GlobalThis +>f : () => typeof globalThis +>() => this : () => typeof globalThis +>this : typeof globalThis diff --git a/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols b/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols index 400d71b5bbeb1..8c78af6cef5ee 100644 --- a/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols @@ -15,7 +15,7 @@ var x = { return callback(this); >callback : Symbol(callback, Decl(collisionThisExpressionAndLocalVarInLambda.ts, 3, 14)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) } } alert(x.doStuff(x => alert(x))); diff --git a/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.types b/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.types index edfd3032f1553..d1f051e339cba 100644 --- a/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.types +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.types @@ -20,7 +20,7 @@ var x = { return callback(this); >callback(this) : any >callback : any ->this : GlobalThis +>this : typeof globalThis } } alert(x.doStuff(x => alert(x))); diff --git a/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols index cf5568911debb..aaa8818b13b59 100644 --- a/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols @@ -8,5 +8,5 @@ module _this { //Error } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndModuleInGlobal.ts, 4, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.types index 46a9625bd34c8..ffa6fcb1a0237 100644 --- a/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.types @@ -7,7 +7,7 @@ module _this { //Error } } var f = () => this; ->f : () => GlobalThis ->() => this : () => GlobalThis ->this : GlobalThis +>f : () => typeof globalThis +>() => this : () => typeof globalThis +>this : typeof globalThis diff --git a/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols index f7946d818c0f7..9ab40210b9a10 100644 --- a/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols @@ -4,5 +4,5 @@ var _this = 1; var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndVarInGlobal.ts, 1, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.types b/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.types index da536d7f7fa75..a82334edc49e8 100644 --- a/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.types +++ b/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.types @@ -4,7 +4,7 @@ var _this = 1; >1 : 1 var f = () => this; ->f : () => GlobalThis ->() => this : () => GlobalThis ->this : GlobalThis +>f : () => typeof globalThis +>() => this : () => typeof globalThis +>this : typeof globalThis diff --git a/tests/baselines/reference/commentsInterface.symbols b/tests/baselines/reference/commentsInterface.symbols index da4b34bc1b40f..6e0d02acaa4e6 100644 --- a/tests/baselines/reference/commentsInterface.symbols +++ b/tests/baselines/reference/commentsInterface.symbols @@ -187,25 +187,25 @@ i3_i = { l: this.f, >l : Symbol(l, Decl(commentsInterface.ts, 56, 56)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) /** own x*/ x: this.f(10), >x : Symbol(x, Decl(commentsInterface.ts, 57, 14)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) nc_x: this.l(this.x), >nc_x : Symbol(nc_x, Decl(commentsInterface.ts, 59, 18)) ->this : Symbol(GlobalThis) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) +>this : Symbol(typeof globalThis) nc_f: this.f, >nc_f : Symbol(nc_f, Decl(commentsInterface.ts, 60, 25)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) nc_l: this.l >nc_l : Symbol(nc_l, Decl(commentsInterface.ts, 61, 17)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) }; i3_i.f(10); diff --git a/tests/baselines/reference/commentsInterface.types b/tests/baselines/reference/commentsInterface.types index f109f4bc341e9..97169b771d382 100644 --- a/tests/baselines/reference/commentsInterface.types +++ b/tests/baselines/reference/commentsInterface.types @@ -198,7 +198,7 @@ i3_i = { l: this.f, >l : any >this.f : any ->this : GlobalThis +>this : typeof globalThis >f : any /** own x*/ @@ -206,7 +206,7 @@ i3_i = { >x : any >this.f(10) : any >this.f : any ->this : GlobalThis +>this : typeof globalThis >f : any >10 : 10 @@ -214,22 +214,22 @@ i3_i = { >nc_x : any >this.l(this.x) : any >this.l : any ->this : GlobalThis +>this : typeof globalThis >l : any >this.x : any ->this : GlobalThis +>this : typeof globalThis >x : any nc_f: this.f, >nc_f : any >this.f : any ->this : GlobalThis +>this : typeof globalThis >f : any nc_l: this.l >nc_l : any >this.l : any ->this : GlobalThis +>this : typeof globalThis >l : any }; diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols b/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols index 630de274757b3..f546c65034b7c 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols @@ -51,11 +51,11 @@ function foo() { } this *= value; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) this += value; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) // identifiers: module, class, enum, function @@ -218,11 +218,11 @@ foo() += value; // parentheses, the containted expression is value (this) *= value; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) (this) += value; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) (M) *= value; diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.types b/tests/baselines/reference/compoundAssignmentLHSIsValue.types index 1aa99cce2fa5b..5aafaa2647c64 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.types +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.types @@ -62,12 +62,12 @@ function foo() { this *= value; >this *= value : number ->this : GlobalThis +>this : typeof globalThis >value : any this += value; >this += value : any ->this : GlobalThis +>this : typeof globalThis >value : any // identifiers: module, class, enum, function @@ -300,14 +300,14 @@ foo() += value; // parentheses, the containted expression is value (this) *= value; >(this) *= value : number ->(this) : GlobalThis ->this : GlobalThis +>(this) : typeof globalThis +>this : typeof globalThis >value : any (this) += value; >(this) += value : any ->(this) : GlobalThis ->this : GlobalThis +>(this) : typeof globalThis +>this : typeof globalThis >value : any (M) *= value; diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols index 9027ee620d692..c7daff9a0530d 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols @@ -36,7 +36,7 @@ function foo() { } this **= value; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >value : Symbol(value, Decl(compoundExponentiationAssignmentLHSIsValue.ts, 1, 3)) // identifiers: module, class, enum, function @@ -136,7 +136,7 @@ foo() **= value; // parentheses, the containted expression is value (this) **= value; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >value : Symbol(value, Decl(compoundExponentiationAssignmentLHSIsValue.ts, 1, 3)) (M) **= value; diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.types b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.types index 52d3f8db875e9..58ec77add862e 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.types +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.types @@ -42,7 +42,7 @@ function foo() { this **= value; >this **= value : number ->this : GlobalThis +>this : typeof globalThis >value : any // identifiers: module, class, enum, function @@ -178,8 +178,8 @@ foo() **= value; // parentheses, the containted expression is value (this) **= value; >(this) **= value : number ->(this) : GlobalThis ->this : GlobalThis +>(this) : typeof globalThis +>this : typeof globalThis >value : any (M) **= value; diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.symbols b/tests/baselines/reference/computedPropertyNames20_ES5.symbols index b29a51bd33136..15a9f9865b320 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames20_ES5.symbols @@ -4,5 +4,5 @@ var obj = { [this.bar]: 0 >[this.bar] : Symbol([this.bar], Decl(computedPropertyNames20_ES5.ts, 0, 11)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) } diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.types b/tests/baselines/reference/computedPropertyNames20_ES5.types index 2dcda458901c3..7a95872481129 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.types +++ b/tests/baselines/reference/computedPropertyNames20_ES5.types @@ -6,7 +6,7 @@ var obj = { [this.bar]: 0 >[this.bar] : number >this.bar : any ->this : GlobalThis +>this : typeof globalThis >bar : any >0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames20_ES6.symbols b/tests/baselines/reference/computedPropertyNames20_ES6.symbols index 19ec84cbc1211..5895a1aec8191 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames20_ES6.symbols @@ -4,5 +4,5 @@ var obj = { [this.bar]: 0 >[this.bar] : Symbol([this.bar], Decl(computedPropertyNames20_ES6.ts, 0, 11)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) } diff --git a/tests/baselines/reference/computedPropertyNames20_ES6.types b/tests/baselines/reference/computedPropertyNames20_ES6.types index 36d2e9985f1e9..516559e3e3eeb 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES6.types +++ b/tests/baselines/reference/computedPropertyNames20_ES6.types @@ -6,7 +6,7 @@ var obj = { [this.bar]: 0 >[this.bar] : number >this.bar : any ->this : GlobalThis +>this : typeof globalThis >bar : any >0 : 0 } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols index 6d062ab90f0bb..8581326f8ec0d 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols @@ -579,7 +579,7 @@ module TypeScriptAllInOne { } public method2() { return 2 * this.method1(2); ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) } } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types index c3a8baee96307..affae0f3108fb 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types @@ -869,7 +869,7 @@ module TypeScriptAllInOne { >2 : 2 >this.method1(2) : any >this.method1 : any ->this : GlobalThis +>this : typeof globalThis >method1 : any >2 : 2 } diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols b/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols index 849488aa30d70..0083b96821072 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols @@ -3,7 +3,7 @@ var f1 = () => { >f1 : Symbol(f1, Decl(emitArrowFunctionThisCapturing.ts, 0, 3)) this.age = 10 ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) }; @@ -13,7 +13,7 @@ var f2 = (x: string) => { this.name = x >this.name : Symbol(name, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(emitArrowFunctionThisCapturing.ts, 4, 10)) } @@ -26,7 +26,7 @@ foo(() => { >foo : Symbol(foo, Decl(emitArrowFunctionThisCapturing.ts, 6, 1)) this.age = 100; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) return true; }); diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.types b/tests/baselines/reference/emitArrowFunctionThisCapturing.types index 647005b36135f..8edaa3141da7f 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.types +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.types @@ -6,7 +6,7 @@ var f1 = () => { this.age = 10 >this.age = 10 : 10 >this.age : any ->this : GlobalThis +>this : typeof globalThis >age : any >10 : 10 @@ -20,7 +20,7 @@ var f2 = (x: string) => { this.name = x >this.name = x : string >this.name : any ->this : GlobalThis +>this : typeof globalThis >name : any >x : string } @@ -37,7 +37,7 @@ foo(() => { this.age = 100; >this.age = 100 : 100 >this.age : any ->this : GlobalThis +>this : typeof globalThis >age : any >100 : 100 diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols index cdbd62ce718e9..61e65b7b4cabb 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols @@ -3,7 +3,7 @@ var f1 = () => { >f1 : Symbol(f1, Decl(emitArrowFunctionThisCapturingES6.ts, 0, 3)) this.age = 10 ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) }; @@ -13,7 +13,7 @@ var f2 = (x: string) => { this.name = x >this.name : Symbol(name, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(emitArrowFunctionThisCapturingES6.ts, 4, 10)) } @@ -26,7 +26,7 @@ foo(() => { >foo : Symbol(foo, Decl(emitArrowFunctionThisCapturingES6.ts, 6, 1)) this.age = 100; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) return true; }); diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types index b938692030f0d..c57317ec5bfb8 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types @@ -6,7 +6,7 @@ var f1 = () => { this.age = 10 >this.age = 10 : 10 >this.age : any ->this : GlobalThis +>this : typeof globalThis >age : any >10 : 10 @@ -20,7 +20,7 @@ var f2 = (x: string) => { this.name = x >this.name = x : string >this.name : any ->this : GlobalThis +>this : typeof globalThis >name : any >x : string } @@ -37,7 +37,7 @@ foo(() => { this.age = 100; >this.age = 100 : 100 >this.age : any ->this : GlobalThis +>this : typeof globalThis >age : any >100 : 100 diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols index 10420fc44c62c..18f7cbb401980 100644 --- a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols @@ -8,9 +8,9 @@ wrapper((array: [any]) => { >array : Symbol(array, Decl(emitCapturingThisInTupleDestructuring1.ts, 1, 9)) [this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this" ->this : Symbol(GlobalThis) ->this : Symbol(GlobalThis) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) +>this : Symbol(typeof globalThis) +>this : Symbol(typeof globalThis) >array : Symbol(array, Decl(emitCapturingThisInTupleDestructuring1.ts, 1, 9)) }); diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.types b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.types index ff3af78b51b0e..9cd06b6b5600b 100644 --- a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.types +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.types @@ -13,13 +13,13 @@ wrapper((array: [any]) => { >[this.test, this.test1, this.test2] = array : [any] >[this.test, this.test1, this.test2] : [any, any, any] >this.test : any ->this : GlobalThis +>this : typeof globalThis >test : any >this.test1 : any ->this : GlobalThis +>this : typeof globalThis >test1 : any >this.test2 : any ->this : GlobalThis +>this : typeof globalThis >test2 : any >array : [any] diff --git a/tests/baselines/reference/globalThisCapture.symbols b/tests/baselines/reference/globalThisCapture.symbols index 1da1a1b0ae2f2..43b291a1ba972 100644 --- a/tests/baselines/reference/globalThisCapture.symbols +++ b/tests/baselines/reference/globalThisCapture.symbols @@ -2,7 +2,7 @@ // Add a lambda to ensure global 'this' capture is triggered (()=>this.window); >this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) var parts = []; diff --git a/tests/baselines/reference/globalThisCapture.types b/tests/baselines/reference/globalThisCapture.types index 4ac1dca5c7d24..43a061382282c 100644 --- a/tests/baselines/reference/globalThisCapture.types +++ b/tests/baselines/reference/globalThisCapture.types @@ -4,7 +4,7 @@ >(()=>this.window) : () => Window >()=>this.window : () => Window >this.window : Window ->this : GlobalThis +>this : typeof globalThis >window : Window var parts = []; diff --git a/tests/baselines/reference/globalThisVarDeclaration.symbols b/tests/baselines/reference/globalThisVarDeclaration.symbols index 5b22663f545b6..18e012062e102 100644 --- a/tests/baselines/reference/globalThisVarDeclaration.symbols +++ b/tests/baselines/reference/globalThisVarDeclaration.symbols @@ -4,12 +4,12 @@ var a = 10; this.a; >this.a : Symbol(a, Decl(b.js, 0, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >a : Symbol(a, Decl(b.js, 0, 3)) this.b; >this.b : Symbol(b, Decl(actual.ts, 0, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >b : Symbol(b, Decl(actual.ts, 0, 3)) === tests/cases/conformance/es2019/actual.ts === @@ -18,11 +18,11 @@ var b = 10; this.a; >this.a : Symbol(a, Decl(b.js, 0, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >a : Symbol(a, Decl(b.js, 0, 3)) this.b; >this.b : Symbol(b, Decl(actual.ts, 0, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >b : Symbol(b, Decl(actual.ts, 0, 3)) diff --git a/tests/baselines/reference/globalThisVarDeclaration.types b/tests/baselines/reference/globalThisVarDeclaration.types index 5a0d1bbb34906..d24c057e1ef0d 100644 --- a/tests/baselines/reference/globalThisVarDeclaration.types +++ b/tests/baselines/reference/globalThisVarDeclaration.types @@ -5,12 +5,12 @@ var a = 10; this.a; >this.a : number ->this : GlobalThis +>this : typeof globalThis >a : number this.b; >this.b : number ->this : GlobalThis +>this : typeof globalThis >b : number === tests/cases/conformance/es2019/actual.ts === @@ -20,11 +20,11 @@ var b = 10; this.a; >this.a : number ->this : GlobalThis +>this : typeof globalThis >a : number this.b; >this.b : number ->this : GlobalThis +>this : typeof globalThis >b : number diff --git a/tests/baselines/reference/implicitAnyInCatch.symbols b/tests/baselines/reference/implicitAnyInCatch.symbols index 63f97268ab188..b0353c7d5ea64 100644 --- a/tests/baselines/reference/implicitAnyInCatch.symbols +++ b/tests/baselines/reference/implicitAnyInCatch.symbols @@ -8,7 +8,7 @@ try { } catch (error) { } for (var key in this) { } >key : Symbol(key, Decl(implicitAnyInCatch.ts, 4, 8)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) class C { >C : Symbol(C, Decl(implicitAnyInCatch.ts, 4, 25)) diff --git a/tests/baselines/reference/implicitAnyInCatch.types b/tests/baselines/reference/implicitAnyInCatch.types index 8ca928493666e..5619ec536224f 100644 --- a/tests/baselines/reference/implicitAnyInCatch.types +++ b/tests/baselines/reference/implicitAnyInCatch.types @@ -13,7 +13,7 @@ try { } catch (error) { } for (var key in this) { } >key : string ->this : GlobalThis +>this : typeof globalThis class C { >C : C diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols index 7016108959cda..a111187bc51e0 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols +++ b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols @@ -127,7 +127,7 @@ export const MySFC = (props: {x: number, y: number, children?: predom.JSX.Elemen >props.y : Symbol(y, Decl(component.tsx, 3, 40)) >props : Symbol(props, Decl(component.tsx, 3, 22)) >y : Symbol(y, Decl(component.tsx, 3, 40)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >p : Symbol(predom.JSX.IntrinsicElements, Decl(renderer2.d.ts, 1, 19)) export class MyClass implements predom.JSX.Element { diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types index 8f2b8f673657c..ab33876cbdadb 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types +++ b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types @@ -99,7 +99,7 @@ export const MySFC = (props: {x: number, y: number, children?: predom.JSX.Elemen >y : number >this.props.children : any >this.props : any ->this : GlobalThis +>this : typeof globalThis >props : any >children : any >p : any diff --git a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols index 11c981b097718..c11267dc6d452 100644 --- a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols +++ b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols @@ -12,7 +12,7 @@ declare var React: any; } dataSource={this.state.ds} renderRow={}> >dataSource : Symbol(dataSource, Decl(jsxAttributeWithoutExpressionReact.tsx, 4, 5)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >renderRow : Symbol(renderRow, Decl(jsxAttributeWithoutExpressionReact.tsx, 4, 32)) diff --git a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.types b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.types index fc261a13aa43f..dac0e2c3df4e2 100644 --- a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.types +++ b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.types @@ -21,7 +21,7 @@ declare var React: any; >dataSource : any >this.state.ds : any >this.state : any ->this : GlobalThis +>this : typeof globalThis >state : any >ds : any >renderRow : any diff --git a/tests/baselines/reference/jsxReactTestSuite.symbols b/tests/baselines/reference/jsxReactTestSuite.symbols index bb5b0dfe99cc1..d6c03dcc18648 100644 --- a/tests/baselines/reference/jsxReactTestSuite.symbols +++ b/tests/baselines/reference/jsxReactTestSuite.symbols @@ -39,7 +39,7 @@ declare var hasOwnProperty:any;
{this.props.children} ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis)
; @@ -59,7 +59,7 @@ declare var hasOwnProperty:any; >Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 2, 11)) {this.props.children} ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) ; >Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 2, 11)) @@ -158,7 +158,7 @@ var x = >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 1, 11)) {...this.props} sound="moo" />; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >sound : Symbol(sound, Decl(jsxReactTestSuite.tsx, 93, 19)) ; diff --git a/tests/baselines/reference/jsxReactTestSuite.types b/tests/baselines/reference/jsxReactTestSuite.types index d922269a3c214..dae8b8ae91221 100644 --- a/tests/baselines/reference/jsxReactTestSuite.types +++ b/tests/baselines/reference/jsxReactTestSuite.types @@ -47,7 +47,7 @@ declare var hasOwnProperty:any; {this.props.children} >this.props.children : any >this.props : any ->this : GlobalThis +>this : typeof globalThis >props : any >children : any @@ -89,7 +89,7 @@ declare var hasOwnProperty:any; {this.props.children} >this.props.children : any >this.props : any ->this : GlobalThis +>this : typeof globalThis >props : any >children : any @@ -262,7 +262,7 @@ var x = {...this.props} sound="moo" />; >this.props : any ->this : GlobalThis +>this : typeof globalThis >props : any >sound : string diff --git a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols index 746fe594f5070..60f7820addf39 100644 --- a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols +++ b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts === return this.edit(role) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) .then((role: Role) => >role : Symbol(role, Decl(multiLinePropertyAccessAndArrowFunctionIndent1.ts, 1, 11)) this.roleService.add(role) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >role : Symbol(role, Decl(multiLinePropertyAccessAndArrowFunctionIndent1.ts, 1, 11)) .then((data: ng.IHttpPromiseCallbackArg) => data.data)); diff --git a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.types b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.types index 342d18b4f6db8..9f35e8fff5799 100644 --- a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.types +++ b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.types @@ -4,7 +4,7 @@ return this.edit(role) >this.edit(role) .then : any >this.edit(role) : any >this.edit : any ->this : GlobalThis +>this : typeof globalThis >edit : any >role : any @@ -19,7 +19,7 @@ return this.edit(role) >this.roleService.add(role) : any >this.roleService.add : any >this.roleService : any ->this : GlobalThis +>this : typeof globalThis >roleService : any >add : any >role : any diff --git a/tests/baselines/reference/parserCommaInTypeMemberList2.symbols b/tests/baselines/reference/parserCommaInTypeMemberList2.symbols index 2f303d16f92f3..ccd3f23ff58cc 100644 --- a/tests/baselines/reference/parserCommaInTypeMemberList2.symbols +++ b/tests/baselines/reference/parserCommaInTypeMemberList2.symbols @@ -5,5 +5,5 @@ var s = $.extend< { workItem: any }, { workItem: any, width: string }>({ workIte >workItem : Symbol(workItem, Decl(parserCommaInTypeMemberList2.ts, 0, 38)) >width : Symbol(width, Decl(parserCommaInTypeMemberList2.ts, 0, 53)) >workItem : Symbol(workItem, Decl(parserCommaInTypeMemberList2.ts, 0, 72)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) diff --git a/tests/baselines/reference/parserCommaInTypeMemberList2.types b/tests/baselines/reference/parserCommaInTypeMemberList2.types index 45fa3ebcb7db9..0b172848ccd4e 100644 --- a/tests/baselines/reference/parserCommaInTypeMemberList2.types +++ b/tests/baselines/reference/parserCommaInTypeMemberList2.types @@ -11,7 +11,7 @@ var s = $.extend< { workItem: any }, { workItem: any, width: string }>({ workIte >{ workItem: this._workItem } : { workItem: any; } >workItem : any >this._workItem : any ->this : GlobalThis +>this : typeof globalThis >_workItem : any >{} : {} diff --git a/tests/baselines/reference/parserConditionalExpression1.symbols b/tests/baselines/reference/parserConditionalExpression1.symbols index 9e12295caec66..7847ae5e8c653 100644 --- a/tests/baselines/reference/parserConditionalExpression1.symbols +++ b/tests/baselines/reference/parserConditionalExpression1.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/Expressions/parserConditionalExpression1.ts === (a=this.R[c])?a.JW||(a.e5(this,c),a.JW=_.l):this.A ->this : Symbol(GlobalThis) ->this : Symbol(GlobalThis) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) +>this : Symbol(typeof globalThis) +>this : Symbol(typeof globalThis) diff --git a/tests/baselines/reference/parserConditionalExpression1.types b/tests/baselines/reference/parserConditionalExpression1.types index 4133fdcb8c01d..d0fb5556033f9 100644 --- a/tests/baselines/reference/parserConditionalExpression1.types +++ b/tests/baselines/reference/parserConditionalExpression1.types @@ -6,7 +6,7 @@ >a : any >this.R[c] : any >this.R : any ->this : GlobalThis +>this : typeof globalThis >R : any >c : any >a.JW||(a.e5(this,c),a.JW=_.l) : any @@ -19,7 +19,7 @@ >a.e5 : any >a : any >e5 : any ->this : GlobalThis +>this : typeof globalThis >c : any >a.JW=_.l : any >a.JW : any @@ -29,6 +29,6 @@ >_ : any >l : any >this.A : any ->this : GlobalThis +>this : typeof globalThis >A : any diff --git a/tests/baselines/reference/parserForStatement8.symbols b/tests/baselines/reference/parserForStatement8.symbols index f55c3ac2a2ca9..977d399f63962 100644 --- a/tests/baselines/reference/parserForStatement8.symbols +++ b/tests/baselines/reference/parserForStatement8.symbols @@ -1,4 +1,4 @@ === tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement8.ts === for (this in b) { ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) } diff --git a/tests/baselines/reference/parserForStatement8.types b/tests/baselines/reference/parserForStatement8.types index 93d834e429a4b..72572e68cfc4c 100644 --- a/tests/baselines/reference/parserForStatement8.types +++ b/tests/baselines/reference/parserForStatement8.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement8.ts === for (this in b) { ->this : GlobalThis +>this : typeof globalThis >b : any } diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols b/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols index 751b96bd51ccc..bf1c42fb899e6 100644 --- a/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols +++ b/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols @@ -2,6 +2,6 @@ { declare var x = this; >x : Symbol(x, Decl(parserModifierOnStatementInBlock2.ts, 1, 14)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) } diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock2.types b/tests/baselines/reference/parserModifierOnStatementInBlock2.types index 928c45f3e36e6..3bb3aee1cf9cc 100644 --- a/tests/baselines/reference/parserModifierOnStatementInBlock2.types +++ b/tests/baselines/reference/parserModifierOnStatementInBlock2.types @@ -1,7 +1,7 @@ === tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnStatementInBlock2.ts === { declare var x = this; ->x : GlobalThis ->this : GlobalThis +>x : typeof globalThis +>this : typeof globalThis } diff --git a/tests/baselines/reference/parserStrictMode16.symbols b/tests/baselines/reference/parserStrictMode16.symbols index e76e39cd941f9..892a0b069d1f6 100644 --- a/tests/baselines/reference/parserStrictMode16.symbols +++ b/tests/baselines/reference/parserStrictMode16.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts === "use strict"; delete this; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) delete 1; delete null; diff --git a/tests/baselines/reference/parserStrictMode16.types b/tests/baselines/reference/parserStrictMode16.types index 36fb6c8a17f30..94c8a6a6bd75f 100644 --- a/tests/baselines/reference/parserStrictMode16.types +++ b/tests/baselines/reference/parserStrictMode16.types @@ -4,7 +4,7 @@ delete this; >delete this : boolean ->this : GlobalThis +>this : typeof globalThis delete 1; >delete 1 : boolean diff --git a/tests/baselines/reference/parserUnaryExpression1.symbols b/tests/baselines/reference/parserUnaryExpression1.symbols index 3d5e96d1daabb..e617530f2e38a 100644 --- a/tests/baselines/reference/parserUnaryExpression1.symbols +++ b/tests/baselines/reference/parserUnaryExpression1.symbols @@ -1,4 +1,4 @@ === tests/cases/conformance/parser/ecmascript5/Expressions/parserUnaryExpression1.ts === ++this; ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) diff --git a/tests/baselines/reference/parserUnaryExpression1.types b/tests/baselines/reference/parserUnaryExpression1.types index 89468794834b7..534dad664747d 100644 --- a/tests/baselines/reference/parserUnaryExpression1.types +++ b/tests/baselines/reference/parserUnaryExpression1.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript5/Expressions/parserUnaryExpression1.ts === ++this; >++this : number ->this : GlobalThis +>this : typeof globalThis diff --git a/tests/baselines/reference/propertyWrappedInTry.symbols b/tests/baselines/reference/propertyWrappedInTry.symbols index 9b43ccdc4ede4..3bb84efe8cfc6 100644 --- a/tests/baselines/reference/propertyWrappedInTry.symbols +++ b/tests/baselines/reference/propertyWrappedInTry.symbols @@ -14,7 +14,7 @@ class Foo { public baz() { return this.bar; // doesn't get rewritten to Foo.bar. ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) } diff --git a/tests/baselines/reference/propertyWrappedInTry.types b/tests/baselines/reference/propertyWrappedInTry.types index b40929c0a8a59..8138f41091f41 100644 --- a/tests/baselines/reference/propertyWrappedInTry.types +++ b/tests/baselines/reference/propertyWrappedInTry.types @@ -21,7 +21,7 @@ class Foo { return this.bar; // doesn't get rewritten to Foo.bar. >this.bar : any ->this : GlobalThis +>this : typeof globalThis >bar : any } diff --git a/tests/baselines/reference/thisInInvalidContexts.errors.txt b/tests/baselines/reference/thisInInvalidContexts.errors.txt index f0152f701a8e6..7a357e1327ea5 100644 --- a/tests/baselines/reference/thisInInvalidContexts.errors.txt +++ b/tests/baselines/reference/thisInInvalidContexts.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(14,15): tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(22,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS2507: Type 'GlobalThis' is not a constructor function type. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS2507: Type 'typeof globalThis' is not a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): error TS2332: 'this' cannot be referenced in current location. @@ -58,7 +58,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): class ErrClass3 extends this { ~~~~ -!!! error TS2507: Type 'GlobalThis' is not a constructor function type. +!!! error TS2507: Type 'typeof globalThis' is not a constructor function type. } diff --git a/tests/baselines/reference/thisInInvalidContexts.symbols b/tests/baselines/reference/thisInInvalidContexts.symbols index fedb2c6b95e22..a73229c751bd0 100644 --- a/tests/baselines/reference/thisInInvalidContexts.symbols +++ b/tests/baselines/reference/thisInInvalidContexts.symbols @@ -69,7 +69,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContexts.ts, 35, 29)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) } diff --git a/tests/baselines/reference/thisInInvalidContexts.types b/tests/baselines/reference/thisInInvalidContexts.types index 42c8777dceba0..6f35006b6c12a 100644 --- a/tests/baselines/reference/thisInInvalidContexts.types +++ b/tests/baselines/reference/thisInInvalidContexts.types @@ -72,7 +72,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : ErrClass3 ->this : GlobalThis +>this : typeof globalThis } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt index 54d492cb51291..4cfd109b00e12 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(22,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS2507: Type 'GlobalThis' is not a constructor function type. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS2507: Type 'typeof globalThis' is not a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(45,9): error TS2332: 'this' cannot be referenced in current location. @@ -58,7 +58,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod class ErrClass3 extends this { ~~~~ -!!! error TS2507: Type 'GlobalThis' is not a constructor function type. +!!! error TS2507: Type 'typeof globalThis' is not a constructor function type. } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols b/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols index 8954656036d09..235aa34ce875b 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols @@ -69,7 +69,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContextsExternalModule.ts, 35, 29)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.types b/tests/baselines/reference/thisInInvalidContextsExternalModule.types index f24267027f943..e6ad34c9a2077 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.types +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.types @@ -72,7 +72,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : ErrClass3 ->this : GlobalThis +>this : typeof globalThis } diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index 4c1c9c75a5e2c..796eda3668d95 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -126,7 +126,7 @@ let impl: I = { explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) >explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 38, 10)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) explicitVoid1() { return 12; }, >explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 39, 32)) @@ -366,7 +366,7 @@ let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + th >x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 45)) >x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 68)) >x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 68)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; >specifiedToSpecified : Symbol(specifiedToSpecified, Decl(thisTypeInFunctions.ts, 93, 3)) @@ -498,7 +498,7 @@ c.explicitC = m => m + this.n; >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) >this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) c.explicitThis = m => m + this.n; @@ -508,7 +508,7 @@ c.explicitThis = m => m + this.n; >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) >this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) c.explicitProperty = m => m + this.n; @@ -518,7 +518,7 @@ c.explicitProperty = m => m + this.n; >m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) >this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) //NOTE: this=C here, I guess? diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index a6fda78497a37..7408a764f1a91 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -137,7 +137,7 @@ let impl: I = { >explicitVoid2 : () => any >() => this.a : () => any >this.a : any ->this : GlobalThis +>this : typeof globalThis >a : any explicitVoid1() { return 12; }, @@ -431,7 +431,7 @@ let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + th >x + this.y : any >x : number >this.y : any ->this : GlobalThis +>this : typeof globalThis >y : any let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; @@ -589,7 +589,7 @@ c.explicitC = m => m + this.n; >m + this.n : number >m : number >this.n : number ->this : GlobalThis +>this : typeof globalThis >n : number c.explicitThis = m => m + this.n; @@ -602,7 +602,7 @@ c.explicitThis = m => m + this.n; >m + this.n : number >m : number >this.n : number ->this : GlobalThis +>this : typeof globalThis >n : number c.explicitProperty = m => m + this.n; @@ -615,7 +615,7 @@ c.explicitProperty = m => m + this.n; >m + this.n : number >m : number >this.n : number ->this : GlobalThis +>this : typeof globalThis >n : number //NOTE: this=C here, I guess? diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.symbols b/tests/baselines/reference/thisTypeInFunctionsNegative.symbols index 6b6f35c1916fc..f44d8bb83e741 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.symbols +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.symbols @@ -134,7 +134,7 @@ let impl: I = { }, explicitVoid2: () => this.a, // ok, `this:any` because it refers to an outer object >explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctionsNegative.ts, 39, 6)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) explicitStructural: () => 12, >explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctionsNegative.ts, 40, 32)) @@ -656,7 +656,7 @@ function initializer(this: C = new C()): number { return this.n; } >C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 171, 30)) >C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 171, 34)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; @@ -666,7 +666,7 @@ c.explicitProperty = (this, m) => m + this.n; >this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 174, 22)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 174, 27)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 174, 27)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) const f2 = (this: {n: number}, m: number) => m + this.n; >f2 : Symbol(f2, Decl(thisTypeInFunctionsNegative.ts, 175, 5)) @@ -675,7 +675,7 @@ const f2 = (this: {n: number}, m: number) => m + this.n; >n : Symbol(n, Decl(thisTypeInFunctionsNegative.ts, 175, 22)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 175, 33)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 175, 33)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) const f3 = async (this: {n: number}, m: number) => m + this.n; >f3 : Symbol(f3, Decl(thisTypeInFunctionsNegative.ts, 176, 5)) @@ -683,7 +683,7 @@ const f3 = async (this: {n: number}, m: number) => m + this.n; >n : Symbol(n, Decl(thisTypeInFunctionsNegative.ts, 176, 25)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 176, 36)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 176, 36)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) const f4 = async (this: {n: number}, m: number) => m + this.n; >f4 : Symbol(f4, Decl(thisTypeInFunctionsNegative.ts, 177, 5)) @@ -692,5 +692,5 @@ const f4 = async (this: {n: number}, m: number) => m + this.n; >n : Symbol(n, Decl(thisTypeInFunctionsNegative.ts, 177, 28)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 177, 39)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 177, 39)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.types b/tests/baselines/reference/thisTypeInFunctionsNegative.types index 07f03d7d2fed2..3a86203772f45 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.types +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.types @@ -143,7 +143,7 @@ let impl: I = { >explicitVoid2 : () => any >() => this.a : () => any >this.a : any ->this : GlobalThis +>this : typeof globalThis >a : any explicitStructural: () => 12, @@ -751,7 +751,7 @@ function initializer(this: C = new C()): number { return this.n; } > : any >number : any >this.n : any ->this : GlobalThis +>this : typeof globalThis >n : any // can't name parameters 'this' in a lambda. @@ -766,7 +766,7 @@ c.explicitProperty = (this, m) => m + this.n; >m + this.n : any >m : number >this.n : any ->this : GlobalThis +>this : typeof globalThis >n : any const f2 = (this: {n: number}, m: number) => m + this.n; @@ -778,7 +778,7 @@ const f2 = (this: {n: number}, m: number) => m + this.n; >m + this.n : any >m : number >this.n : any ->this : GlobalThis +>this : typeof globalThis >n : any const f3 = async (this: {n: number}, m: number) => m + this.n; @@ -790,7 +790,7 @@ const f3 = async (this: {n: number}, m: number) => m + this.n; >m + this.n : any >m : number >this.n : any ->this : GlobalThis +>this : typeof globalThis >n : any const f4 = async (this: {n: number}, m: number) => m + this.n; @@ -802,6 +802,6 @@ const f4 = async (this: {n: number}, m: number) => m + this.n; >m + this.n : any >m : number >this.n : any ->this : GlobalThis +>this : typeof globalThis >n : any diff --git a/tests/baselines/reference/topLevelLambda2.symbols b/tests/baselines/reference/topLevelLambda2.symbols index 0297d4b7492c9..501ffcba88e61 100644 --- a/tests/baselines/reference/topLevelLambda2.symbols +++ b/tests/baselines/reference/topLevelLambda2.symbols @@ -6,6 +6,6 @@ function foo(x:any) {} foo(()=>this.window); >foo : Symbol(foo, Decl(topLevelLambda2.ts, 0, 0)) >this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) diff --git a/tests/baselines/reference/topLevelLambda2.types b/tests/baselines/reference/topLevelLambda2.types index 2b5343ddc8c27..ddca05514d0ee 100644 --- a/tests/baselines/reference/topLevelLambda2.types +++ b/tests/baselines/reference/topLevelLambda2.types @@ -8,6 +8,6 @@ foo(()=>this.window); >foo : (x: any) => void >()=>this.window : () => Window >this.window : Window ->this : GlobalThis +>this : typeof globalThis >window : Window diff --git a/tests/baselines/reference/topLevelLambda3.symbols b/tests/baselines/reference/topLevelLambda3.symbols index be077cb760ea0..0250c07b94355 100644 --- a/tests/baselines/reference/topLevelLambda3.symbols +++ b/tests/baselines/reference/topLevelLambda3.symbols @@ -2,6 +2,6 @@ var f = () => {this.window;} >f : Symbol(f, Decl(topLevelLambda3.ts, 0, 3)) >this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) diff --git a/tests/baselines/reference/topLevelLambda3.types b/tests/baselines/reference/topLevelLambda3.types index 9c1ae547ff76f..b2bb8f30bad4a 100644 --- a/tests/baselines/reference/topLevelLambda3.types +++ b/tests/baselines/reference/topLevelLambda3.types @@ -3,6 +3,6 @@ var f = () => {this.window;} >f : () => void >() => {this.window;} : () => void >this.window : Window ->this : GlobalThis +>this : typeof globalThis >window : Window diff --git a/tests/baselines/reference/topLevelLambda4.symbols b/tests/baselines/reference/topLevelLambda4.symbols index a9ad8e38349d2..096958b869c40 100644 --- a/tests/baselines/reference/topLevelLambda4.symbols +++ b/tests/baselines/reference/topLevelLambda4.symbols @@ -2,6 +2,6 @@ export var x = () => this.window; >x : Symbol(x, Decl(topLevelLambda4.ts, 0, 10)) >this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) diff --git a/tests/baselines/reference/topLevelLambda4.types b/tests/baselines/reference/topLevelLambda4.types index b88f0bd05b6a6..081f5c47c5ae1 100644 --- a/tests/baselines/reference/topLevelLambda4.types +++ b/tests/baselines/reference/topLevelLambda4.types @@ -3,6 +3,6 @@ export var x = () => this.window; >x : () => Window >() => this.window : () => Window >this.window : Window ->this : GlobalThis +>this : typeof globalThis >window : Window diff --git a/tests/baselines/reference/topLevelThisAssignment.symbols b/tests/baselines/reference/topLevelThisAssignment.symbols index b8855fb16c5af..d0747b4a3be4f 100644 --- a/tests/baselines/reference/topLevelThisAssignment.symbols +++ b/tests/baselines/reference/topLevelThisAssignment.symbols @@ -1,12 +1,12 @@ === tests/cases/conformance/salsa/a.js === this.a = 10; >this.a : Symbol(a, Decl(a.js, 0, 0)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >a : Symbol(a, Decl(a.js, 0, 0)) this.a; >this.a : Symbol(a, Decl(a.js, 0, 0)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >a : Symbol(a, Decl(a.js, 0, 0)) a; @@ -15,7 +15,7 @@ a; === tests/cases/conformance/salsa/b.js === this.a; >this.a : Symbol(a, Decl(a.js, 0, 0)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >a : Symbol(a, Decl(a.js, 0, 0)) a; diff --git a/tests/baselines/reference/topLevelThisAssignment.types b/tests/baselines/reference/topLevelThisAssignment.types index bd68e42785d1f..11c7b5a82e143 100644 --- a/tests/baselines/reference/topLevelThisAssignment.types +++ b/tests/baselines/reference/topLevelThisAssignment.types @@ -2,13 +2,13 @@ this.a = 10; >this.a = 10 : 10 >this.a : number ->this : GlobalThis +>this : typeof globalThis >a : number >10 : 10 this.a; >this.a : number ->this : GlobalThis +>this : typeof globalThis >a : number a; @@ -17,7 +17,7 @@ a; === tests/cases/conformance/salsa/b.js === this.a; >this.a : number ->this : GlobalThis +>this : typeof globalThis >a : number a; diff --git a/tests/baselines/reference/tsxAttributeResolution15.symbols b/tests/baselines/reference/tsxAttributeResolution15.symbols index 481b8cd101b01..c4dac3f82be13 100644 --- a/tests/baselines/reference/tsxAttributeResolution15.symbols +++ b/tests/baselines/reference/tsxAttributeResolution15.symbols @@ -31,7 +31,7 @@ let b = { this.textInput = input; }} /> >BigGreeter : Symbol(BigGreeter, Decl(file.tsx, 0, 32)) >ref : Symbol(ref, Decl(file.tsx, 13, 19)) >input : Symbol(input, Decl(file.tsx, 13, 26)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >input : Symbol(input, Decl(file.tsx, 13, 26)) let c = diff --git a/tests/baselines/reference/tsxAttributeResolution15.types b/tests/baselines/reference/tsxAttributeResolution15.types index eb8f2a7184538..469f146cc45ce 100644 --- a/tests/baselines/reference/tsxAttributeResolution15.types +++ b/tests/baselines/reference/tsxAttributeResolution15.types @@ -37,7 +37,7 @@ let b = { this.textInput = input; }} /> >input : BigGreeter >this.textInput = input : BigGreeter >this.textInput : any ->this : GlobalThis +>this : typeof globalThis >textInput : any >input : BigGreeter diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols index 1757e4c01074e..898581d35f69f 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols @@ -79,7 +79,7 @@ let e3 = { this.textInput = input; } }} /> >EmptyProp : Symbol(EmptyProp, Decl(file.tsx, 19, 30)) >ref : Symbol(ref, Decl(file.tsx, 31, 25)) >input : Symbol(input, Decl(file.tsx, 31, 32)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >input : Symbol(input, Decl(file.tsx, 31, 32)) let e4 = diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.types b/tests/baselines/reference/tsxSpreadAttributesResolution4.types index f424de2feb0a9..82173c0df83b6 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.types @@ -89,7 +89,7 @@ let e3 = { this.textInput = input; } }} /> >input : EmptyProp >this.textInput = input : EmptyProp >this.textInput : any ->this : GlobalThis +>this : typeof globalThis >textInput : any >input : EmptyProp diff --git a/tests/baselines/reference/typeFromPropertyAssignment23.symbols b/tests/baselines/reference/typeFromPropertyAssignment23.symbols index bd8b61e2666b8..c3267bcf8363e 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment23.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment23.symbols @@ -38,7 +38,7 @@ D.prototype.foo = () => { >foo : Symbol(D.foo, Decl(a.js, 14, 21)) this.n = 'not checked, so no error' ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >n : Symbol(n, Decl(a.js, 15, 26)) } diff --git a/tests/baselines/reference/typeFromPropertyAssignment23.types b/tests/baselines/reference/typeFromPropertyAssignment23.types index 6c459adc958e1..03bf1d91776c2 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment23.types +++ b/tests/baselines/reference/typeFromPropertyAssignment23.types @@ -46,7 +46,7 @@ D.prototype.foo = () => { this.n = 'not checked, so no error' >this.n = 'not checked, so no error' : "not checked, so no error" >this.n : any ->this : GlobalThis +>this : typeof globalThis >n : any >'not checked, so no error' : "not checked, so no error" } diff --git a/tests/baselines/reference/typeFromPropertyAssignment9.symbols b/tests/baselines/reference/typeFromPropertyAssignment9.symbols index f44063b765b63..8f5ff83ce2191 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment9.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment9.symbols @@ -120,7 +120,7 @@ min.nest = this.min.nest || function () { }; >nest : Symbol(min.nest, Decl(a.js, 29, 27), Decl(a.js, 31, 4)) >this.min.nest : Symbol(min.nest, Decl(a.js, 29, 27), Decl(a.js, 31, 4)) >this.min : Symbol(min, Decl(a.js, 29, 3), Decl(a.js, 29, 27), Decl(a.js, 30, 44)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >min : Symbol(min, Decl(a.js, 29, 3), Decl(a.js, 29, 27), Decl(a.js, 30, 44)) >nest : Symbol(min.nest, Decl(a.js, 29, 27), Decl(a.js, 31, 4)) diff --git a/tests/baselines/reference/typeFromPropertyAssignment9.types b/tests/baselines/reference/typeFromPropertyAssignment9.types index 6be91c95a1c5c..c4f813f0a8985 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment9.types +++ b/tests/baselines/reference/typeFromPropertyAssignment9.types @@ -159,7 +159,7 @@ min.nest = this.min.nest || function () { }; >this.min.nest || function () { } : { (): void; other: typeof other; } >this.min.nest : { (): void; other: typeof other; } >this.min : typeof min ->this : GlobalThis +>this : typeof globalThis >min : typeof min >nest : { (): void; other: typeof other; } >function () { } : { (): void; other: typeof other; } diff --git a/tests/baselines/reference/typeOfThis.errors.txt b/tests/baselines/reference/typeOfThis.errors.txt index 83d450570fce9..b47207670cc62 100644 --- a/tests/baselines/reference/typeOfThis.errors.txt +++ b/tests/baselines/reference/typeOfThis.errors.txt @@ -1,24 +1,16 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(14,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyTestClass'. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(18,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyTestClass'. -tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(22,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(24,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyTestClass'. -tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(27,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(29,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyTestClass'. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(37,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyTestClass'. -tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(53,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(61,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(83,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyGenericTestClass'. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(87,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyGenericTestClass'. -tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(91,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(93,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyGenericTestClass'. -tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(96,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(98,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyGenericTestClass'. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(106,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyGenericTestClass'. -tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(122,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -==== tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts (18 errors) ==== +==== tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts (10 errors) ==== class MyTestClass { private canary: number; static staticCanary: number; @@ -45,8 +37,6 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 //type of 'this' in member accessor(get and set) body is the class instance type get prop() { - ~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var p = this; var p: MyTestClass; ~ @@ -54,8 +44,6 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 return this; } set prop(v) { - ~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var p = this; var p: MyTestClass; ~ @@ -86,8 +74,6 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 } static get staticProp() { - ~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. //type of 'this' in static accessor body is constructor function type var p = this; var p: typeof MyTestClass; @@ -96,8 +82,6 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 return this; } static set staticProp(v: typeof MyTestClass) { - ~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. //type of 'this' in static accessor body is constructor function type var p = this; var p: typeof MyTestClass; @@ -132,8 +116,6 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 //type of 'this' in member accessor(get and set) body is the class instance type get prop() { - ~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var p = this; var p: MyGenericTestClass; ~ @@ -141,8 +123,6 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 return this; } set prop(v) { - ~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var p = this; var p: MyGenericTestClass; ~ @@ -173,8 +153,6 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 } static get staticProp() { - ~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. //type of 'this' in static accessor body is constructor function type var p = this; var p: typeof MyGenericTestClass; @@ -183,8 +161,6 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 return this; } static set staticProp(v: typeof MyGenericTestClass) { - ~~~~~~~~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. //type of 'this' in static accessor body is constructor function type var p = this; var p: typeof MyGenericTestClass; @@ -215,19 +191,19 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 this.spaaaaace = 4; } - //type of 'this' in a fat arrow expression param list is Any + //type of 'this' in a fat arrow expression param list is typeof globalThis var q2 = (s = this) => { - var s: any; + var s: typeof globalThis; s.spaaaaaaace = 4; - //type of 'this' in a fat arrow expression body is Any - var t: any; + //type of 'this' in a fat arrow expression body is typeof globalThis + var t: typeof globalThis; var t = this; this.spaaaaace = 4; } - //type of 'this' in global module is Any - var t: any; + //type of 'this' in global module is GlobalThis + var t: typeof globalThis; var t = this; this.spaaaaace = 4; diff --git a/tests/baselines/reference/typeOfThis.js b/tests/baselines/reference/typeOfThis.js index 42593bd3d2ae3..0ea8fc2f93541 100644 --- a/tests/baselines/reference/typeOfThis.js +++ b/tests/baselines/reference/typeOfThis.js @@ -159,32 +159,30 @@ var q1 = function (s = this) { this.spaaaaace = 4; } -//type of 'this' in a fat arrow expression param list is Any +//type of 'this' in a fat arrow expression param list is typeof globalThis var q2 = (s = this) => { - var s: any; + var s: typeof globalThis; s.spaaaaaaace = 4; - //type of 'this' in a fat arrow expression body is Any - var t: any; + //type of 'this' in a fat arrow expression body is typeof globalThis + var t: typeof globalThis; var t = this; this.spaaaaace = 4; } -//type of 'this' in global module is Any -var t: any; +//type of 'this' in global module is GlobalThis +var t: typeof globalThis; var t = this; this.spaaaaace = 4; //// [typeOfThis.js] -var _this = this; -var MyTestClass = /** @class */ (function () { - function MyTestClass() { - var _this = this; - this.someFunc = function () { +class MyTestClass { + constructor() { + this.someFunc = () => { //type of 'this' in member variable initializer is the class instance type - var t = _this; + var t = this; var t; }; //type of 'this' in constructor body is the class instance type @@ -193,32 +191,26 @@ var MyTestClass = /** @class */ (function () { this.canary = 3; } //type of 'this' in member function param list is the class instance type - MyTestClass.prototype.memberFunc = function (t) { - if (t === void 0) { t = this; } + memberFunc(t = this) { var t; //type of 'this' in member function body is the class instance type var p = this; var p; - }; - Object.defineProperty(MyTestClass.prototype, "prop", { - //type of 'this' in member accessor(get and set) body is the class instance type - get: function () { - var p = this; - var p; - return this; - }, - set: function (v) { - var p = this; - var p; - p = v; - v = p; - }, - enumerable: true, - configurable: true - }); + } + //type of 'this' in member accessor(get and set) body is the class instance type + get prop() { + var p = this; + var p; + return this; + } + set prop(v) { + var p = this; + var p; + p = v; + v = p; + } //type of 'this' in static function param list is constructor function type - MyTestClass.staticFn = function (t) { - if (t === void 0) { t = this; } + static staticFn(t = this) { var t; var t = MyTestClass; t.staticCanary; @@ -227,34 +219,28 @@ var MyTestClass = /** @class */ (function () { var p; var p = MyTestClass; p.staticCanary; - }; - Object.defineProperty(MyTestClass, "staticProp", { - get: function () { - //type of 'this' in static accessor body is constructor function type - var p = this; - var p; - var p = MyTestClass; - p.staticCanary; - return this; - }, - set: function (v) { - //type of 'this' in static accessor body is constructor function type - var p = this; - var p; - var p = MyTestClass; - p.staticCanary; - }, - enumerable: true, - configurable: true - }); - return MyTestClass; -}()); -var MyGenericTestClass = /** @class */ (function () { - function MyGenericTestClass() { - var _this = this; - this.someFunc = function () { + } + static get staticProp() { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p; + var p = MyTestClass; + p.staticCanary; + return this; + } + static set staticProp(v) { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p; + var p = MyTestClass; + p.staticCanary; + } +} +class MyGenericTestClass { + constructor() { + this.someFunc = () => { //type of 'this' in member variable initializer is the class instance type - var t = _this; + var t = this; var t; }; //type of 'this' in constructor body is the class instance type @@ -263,32 +249,26 @@ var MyGenericTestClass = /** @class */ (function () { this.canary = 3; } //type of 'this' in member function param list is the class instance type - MyGenericTestClass.prototype.memberFunc = function (t) { - if (t === void 0) { t = this; } + memberFunc(t = this) { var t; //type of 'this' in member function body is the class instance type var p = this; var p; - }; - Object.defineProperty(MyGenericTestClass.prototype, "prop", { - //type of 'this' in member accessor(get and set) body is the class instance type - get: function () { - var p = this; - var p; - return this; - }, - set: function (v) { - var p = this; - var p; - p = v; - v = p; - }, - enumerable: true, - configurable: true - }); + } + //type of 'this' in member accessor(get and set) body is the class instance type + get prop() { + var p = this; + var p; + return this; + } + set prop(v) { + var p = this; + var p; + p = v; + v = p; + } //type of 'this' in static function param list is constructor function type - MyGenericTestClass.staticFn = function (t) { - if (t === void 0) { t = this; } + static staticFn(t = this) { var t; var t = MyGenericTestClass; t.staticCanary; @@ -297,31 +277,25 @@ var MyGenericTestClass = /** @class */ (function () { var p; var p = MyGenericTestClass; p.staticCanary; - }; - Object.defineProperty(MyGenericTestClass, "staticProp", { - get: function () { - //type of 'this' in static accessor body is constructor function type - var p = this; - var p; - var p = MyGenericTestClass; - p.staticCanary; - return this; - }, - set: function (v) { - //type of 'this' in static accessor body is constructor function type - var p = this; - var p; - var p = MyGenericTestClass; - p.staticCanary; - }, - enumerable: true, - configurable: true - }); - return MyGenericTestClass; -}()); + } + static get staticProp() { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p; + var p = MyGenericTestClass; + p.staticCanary; + return this; + } + static set staticProp(v) { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p; + var p = MyGenericTestClass; + p.staticCanary; + } +} //type of 'this' in a function declaration param list is Any -function fn(s) { - if (s === void 0) { s = this; } +function fn(s = this) { var s; s.spaaaaaaace = 4; //type of 'this' in a function declaration body is Any @@ -330,8 +304,7 @@ function fn(s) { this.spaaaaace = 4; } //type of 'this' in a function expression param list list is Any -var q1 = function (s) { - if (s === void 0) { s = this; } +var q1 = function (s = this) { var s; s.spaaaaaaace = 4; //type of 'this' in a function expression body is Any @@ -339,17 +312,16 @@ var q1 = function (s) { var t = this; this.spaaaaace = 4; }; -//type of 'this' in a fat arrow expression param list is Any -var q2 = function (s) { - if (s === void 0) { s = _this; } +//type of 'this' in a fat arrow expression param list is typeof globalThis +var q2 = (s = this) => { var s; s.spaaaaaaace = 4; - //type of 'this' in a fat arrow expression body is Any + //type of 'this' in a fat arrow expression body is typeof globalThis var t; - var t = _this; - _this.spaaaaace = 4; + var t = this; + this.spaaaaace = 4; }; -//type of 'this' in global module is Any +//type of 'this' in global module is GlobalThis var t; var t = this; this.spaaaaace = 4; diff --git a/tests/baselines/reference/typeOfThis.symbols b/tests/baselines/reference/typeOfThis.symbols index c89796f81577f..e7803be78f6a6 100644 --- a/tests/baselines/reference/typeOfThis.symbols +++ b/tests/baselines/reference/typeOfThis.symbols @@ -419,34 +419,39 @@ var q1 = function (s = this) { this.spaaaaace = 4; } -//type of 'this' in a fat arrow expression param list is Any +//type of 'this' in a fat arrow expression param list is typeof globalThis var q2 = (s = this) => { >q2 : Symbol(q2, Decl(typeOfThis.ts, 161, 3)) >s : Symbol(s, Decl(typeOfThis.ts, 161, 10), Decl(typeOfThis.ts, 162, 7)) +>this : Symbol(typeof globalThis) - var s: any; + var s: typeof globalThis; >s : Symbol(s, Decl(typeOfThis.ts, 161, 10), Decl(typeOfThis.ts, 162, 7)) s.spaaaaaaace = 4; >s : Symbol(s, Decl(typeOfThis.ts, 161, 10), Decl(typeOfThis.ts, 162, 7)) - //type of 'this' in a fat arrow expression body is Any - var t: any; + //type of 'this' in a fat arrow expression body is typeof globalThis + var t: typeof globalThis; >t : Symbol(t, Decl(typeOfThis.ts, 166, 7), Decl(typeOfThis.ts, 167, 7)) var t = this; >t : Symbol(t, Decl(typeOfThis.ts, 166, 7), Decl(typeOfThis.ts, 167, 7)) +>this : Symbol(typeof globalThis) this.spaaaaace = 4; +>this : Symbol(typeof globalThis) } -//type of 'this' in global module is Any -var t: any; +//type of 'this' in global module is GlobalThis +var t: typeof globalThis; >t : Symbol(t, Decl(typeOfThis.ts, 172, 3), Decl(typeOfThis.ts, 173, 3)) var t = this; >t : Symbol(t, Decl(typeOfThis.ts, 172, 3), Decl(typeOfThis.ts, 173, 3)) +>this : Symbol(typeof globalThis) this.spaaaaace = 4; +>this : Symbol(typeof globalThis) diff --git a/tests/baselines/reference/typeOfThis.types b/tests/baselines/reference/typeOfThis.types index 0d27690a49aa8..797d7b2e2263d 100644 --- a/tests/baselines/reference/typeOfThis.types +++ b/tests/baselines/reference/typeOfThis.types @@ -430,51 +430,51 @@ var q1 = function (s = this) { >4 : 4 } -//type of 'this' in a fat arrow expression param list is Any +//type of 'this' in a fat arrow expression param list is typeof globalThis var q2 = (s = this) => { ->q2 : (s?: any) => void ->(s = this) => { var s: any; s.spaaaaaaace = 4; //type of 'this' in a fat arrow expression body is Any var t: any; var t = this; this.spaaaaace = 4;} : (s?: any) => void ->s : any ->this : any +>q2 : (s?: typeof globalThis) => void +>(s = this) => { var s: typeof globalThis; s.spaaaaaaace = 4; //type of 'this' in a fat arrow expression body is typeof globalThis var t: typeof globalThis; var t = this; this.spaaaaace = 4;} : (s?: typeof globalThis) => void +>s : typeof globalThis +>this : typeof globalThis - var s: any; ->s : any + var s: typeof globalThis; +>s : typeof globalThis s.spaaaaaaace = 4; >s.spaaaaaaace = 4 : 4 >s.spaaaaaaace : any ->s : any +>s : typeof globalThis >spaaaaaaace : any >4 : 4 - //type of 'this' in a fat arrow expression body is Any - var t: any; ->t : any + //type of 'this' in a fat arrow expression body is typeof globalThis + var t: typeof globalThis; +>t : typeof globalThis var t = this; ->t : any ->this : any +>t : typeof globalThis +>this : typeof globalThis this.spaaaaace = 4; >this.spaaaaace = 4 : 4 >this.spaaaaace : any ->this : any +>this : typeof globalThis >spaaaaace : any >4 : 4 } -//type of 'this' in global module is Any -var t: any; ->t : any +//type of 'this' in global module is GlobalThis +var t: typeof globalThis; +>t : typeof globalThis var t = this; ->t : any ->this : any +>t : typeof globalThis +>this : typeof globalThis this.spaaaaace = 4; >this.spaaaaace = 4 : 4 >this.spaaaaace : any ->this : any +>this : typeof globalThis >spaaaaace : any >4 : 4 diff --git a/tests/baselines/reference/unknownSymbols1.symbols b/tests/baselines/reference/unknownSymbols1.symbols index b61235aad9ea8..23f838f405e6a 100644 --- a/tests/baselines/reference/unknownSymbols1.symbols +++ b/tests/baselines/reference/unknownSymbols1.symbols @@ -54,7 +54,7 @@ class C4 extends C3 { var x2 = this.asdf; // no error, this is any >x2 : Symbol(x2, Decl(unknownSymbols1.ts, 25, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) class C5 { >C5 : Symbol(C5, Decl(unknownSymbols1.ts, 25, 19)) diff --git a/tests/baselines/reference/unknownSymbols1.types b/tests/baselines/reference/unknownSymbols1.types index 8eccd2bcdf690..9fced36d703a9 100644 --- a/tests/baselines/reference/unknownSymbols1.types +++ b/tests/baselines/reference/unknownSymbols1.types @@ -57,7 +57,7 @@ class C4 extends C3 { var x2 = this.asdf; // no error, this is any >x2 : any >this.asdf : any ->this : GlobalThis +>this : typeof globalThis >asdf : any class C5 { diff --git a/tests/baselines/reference/wrappedIncovations1.symbols b/tests/baselines/reference/wrappedIncovations1.symbols index 0c988bf0909c4..00618918c102d 100644 --- a/tests/baselines/reference/wrappedIncovations1.symbols +++ b/tests/baselines/reference/wrappedIncovations1.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/wrappedIncovations1.ts === var v = this >v : Symbol(v, Decl(wrappedIncovations1.ts, 0, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) .foo() .bar() diff --git a/tests/baselines/reference/wrappedIncovations1.types b/tests/baselines/reference/wrappedIncovations1.types index 4a41fb7430123..92adf203aa920 100644 --- a/tests/baselines/reference/wrappedIncovations1.types +++ b/tests/baselines/reference/wrappedIncovations1.types @@ -7,7 +7,7 @@ var v = this >this .foo() .bar : any >this .foo() : any >this .foo : any ->this : GlobalThis +>this : typeof globalThis .foo() >foo : any diff --git a/tests/baselines/reference/wrappedIncovations2.symbols b/tests/baselines/reference/wrappedIncovations2.symbols index 3b7c7e6ac76de..14c2c9e52802a 100644 --- a/tests/baselines/reference/wrappedIncovations2.symbols +++ b/tests/baselines/reference/wrappedIncovations2.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/wrappedIncovations2.ts === var v = this. >v : Symbol(v, Decl(wrappedIncovations2.ts, 0, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) foo(). bar(). diff --git a/tests/baselines/reference/wrappedIncovations2.types b/tests/baselines/reference/wrappedIncovations2.types index 629a9d2224313..71317c3f9c26d 100644 --- a/tests/baselines/reference/wrappedIncovations2.types +++ b/tests/baselines/reference/wrappedIncovations2.types @@ -7,7 +7,7 @@ var v = this. >this. foo(). bar : any >this. foo() : any >this. foo : any ->this : GlobalThis +>this : typeof globalThis foo(). >foo : any diff --git a/tests/cases/conformance/es2019/globalThisVarDeclaration.ts b/tests/cases/conformance/es2019/globalThisVarDeclaration.ts new file mode 100644 index 0000000000000..5508b4de06e18 --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisVarDeclaration.ts @@ -0,0 +1,14 @@ +// @out: output.js +// @target: esnext +// @lib: esnext +// @Filename: b.js +// @allowJs: true +// @checkJs: true +var a = 10; +this.a; +this.b; + +// @Filename: actual.ts +var b = 10; +this.a; +this.b; diff --git a/tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts b/tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts index 64f6288ef2e50..3a793f1f39131 100644 --- a/tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts +++ b/tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts @@ -1,3 +1,4 @@ +// @target: esnext class MyTestClass { private canary: number; static staticCanary: number; @@ -158,19 +159,19 @@ var q1 = function (s = this) { this.spaaaaace = 4; } -//type of 'this' in a fat arrow expression param list is GlobalThis +//type of 'this' in a fat arrow expression param list is typeof globalThis var q2 = (s = this) => { - var s: GlobalThis; + var s: typeof globalThis; s.spaaaaaaace = 4; - //type of 'this' in a fat arrow expression body is GlobalThis - var t: GlobalThis; + //type of 'this' in a fat arrow expression body is typeof globalThis + var t: typeof globalThis; var t = this; this.spaaaaace = 4; } //type of 'this' in global module is GlobalThis -var t: GlobalThis; +var t: typeof globalThis; var t = this; this.spaaaaace = 4; From 80558a4428305f335d8a224e0b0db8def823b93f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 9 Jan 2019 08:55:04 -0800 Subject: [PATCH 06/19] Restore former behaviour of implicitThis errors I left the noImplicitThis rule for captured use of global this in an arrow function, even though technically it isn't `any` any more -- it's typeof globalThis. However, you should still use some other method to access globals inside an arrow, because captured-global-this is super confusing there. --- src/compiler/checker.ts | 24 ++++++++++--------- src/compiler/diagnosticMessages.json | 2 +- .../noImplicitThisFunctions.errors.txt | 8 +++---- .../reference/noImplicitThisFunctions.symbols | 4 ++-- .../reference/noImplicitThisFunctions.types | 10 ++++---- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c3f9d436dca3b..98dc9ff7242db 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16709,17 +16709,19 @@ namespace ts { } const type = tryGetThisTypeAt(node, container); - if (!type && noImplicitThis) { - // With noImplicitThis, functions may not reference 'this' if it has type 'any' - const diag = error( - node, - capturedByArrowFunction && container.kind === SyntaxKind.SourceFile ? - Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any : - Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); - if (!isSourceFile(container)) { - const outsideThis = tryGetThisTypeAt(container); - if (outsideThis) { - addRelatedInfo(diag, createDiagnosticForNode(container, Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container)); + const globalThisType = getGlobalThisType(); + if (noImplicitThis) { + if (type === globalThisType && capturedByArrowFunction) { + error(node, Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this); + } + if (!type) { + // With noImplicitThis, functions may not reference 'this' if it has type 'any' + const diag = error(node, Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); + if (!isSourceFile(container)) { + const outsideThis = tryGetThisTypeAt(container); + if (outsideThis && outsideThis !== globalThisType) { + addRelatedInfo(diag, createDiagnosticForNode(container, Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container)); + } } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 57f4c4c561117..8cf7c9e2e1a8e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4097,7 +4097,7 @@ "category": "Error", "code": 7040 }, - "The containing arrow function captures the global value of 'this' which implicitly has type 'any'.": { + "The containing arrow function captures the global value of 'this'.": { "category": "Error", "code": 7041 }, diff --git a/tests/baselines/reference/noImplicitThisFunctions.errors.txt b/tests/baselines/reference/noImplicitThisFunctions.errors.txt index aac8faa566ca7..8fb99eb27242d 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.errors.txt +++ b/tests/baselines/reference/noImplicitThisFunctions.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/noImplicitThisFunctions.ts(13,12): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -tests/cases/compiler/noImplicitThisFunctions.ts(17,38): error TS7041: The containing arrow function captures the global value of 'this' which implicitly has type 'any'. -tests/cases/compiler/noImplicitThisFunctions.ts(18,22): error TS7041: The containing arrow function captures the global value of 'this' which implicitly has type 'any'. +tests/cases/compiler/noImplicitThisFunctions.ts(17,38): error TS7041: The containing arrow function captures the global value of 'this'. +tests/cases/compiler/noImplicitThisFunctions.ts(18,22): error TS7041: The containing arrow function captures the global value of 'this'. tests/cases/compiler/noImplicitThisFunctions.ts(20,36): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. tests/cases/compiler/noImplicitThisFunctions.ts(21,50): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. @@ -26,10 +26,10 @@ tests/cases/compiler/noImplicitThisFunctions.ts(21,50): error TS2683: 'this' imp // error: `this` is `window`, but is still of type `any` let f4: (b: number) => number = b => this.c + b; ~~~~ -!!! error TS7041: The containing arrow function captures the global value of 'this' which implicitly has type 'any'. +!!! error TS7041: The containing arrow function captures the global value of 'this'. let f5 = () => () => this; ~~~~ -!!! error TS7041: The containing arrow function captures the global value of 'this' which implicitly has type 'any'. +!!! error TS7041: The containing arrow function captures the global value of 'this'. let f6 = function() { return () => this; }; ~~~~ diff --git a/tests/baselines/reference/noImplicitThisFunctions.symbols b/tests/baselines/reference/noImplicitThisFunctions.symbols index f0e21a6bacc50..447ab11a994ef 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.symbols +++ b/tests/baselines/reference/noImplicitThisFunctions.symbols @@ -31,12 +31,12 @@ let f4: (b: number) => number = b => this.c + b; >f4 : Symbol(f4, Decl(noImplicitThisFunctions.ts, 16, 3)) >b : Symbol(b, Decl(noImplicitThisFunctions.ts, 16, 9)) >b : Symbol(b, Decl(noImplicitThisFunctions.ts, 16, 31)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) >b : Symbol(b, Decl(noImplicitThisFunctions.ts, 16, 31)) let f5 = () => () => this; >f5 : Symbol(f5, Decl(noImplicitThisFunctions.ts, 17, 3)) ->this : Symbol(GlobalThis) +>this : Symbol(typeof globalThis) let f6 = function() { return () => this; }; >f6 : Symbol(f6, Decl(noImplicitThisFunctions.ts, 19, 3)) diff --git a/tests/baselines/reference/noImplicitThisFunctions.types b/tests/baselines/reference/noImplicitThisFunctions.types index 712928e3261f9..639e84f650b27 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.types +++ b/tests/baselines/reference/noImplicitThisFunctions.types @@ -42,15 +42,15 @@ let f4: (b: number) => number = b => this.c + b; >b : number >this.c + b : any >this.c : any ->this : GlobalThis +>this : typeof globalThis >c : any >b : number let f5 = () => () => this; ->f5 : () => () => GlobalThis ->() => () => this : () => () => GlobalThis ->() => this : () => GlobalThis ->this : GlobalThis +>f5 : () => () => typeof globalThis +>() => () => this : () => () => typeof globalThis +>() => this : () => typeof globalThis +>this : typeof globalThis let f6 = function() { return () => this; }; >f6 : () => () => any From e3fbe5c5625f5e97bea6696c0b5c390be6e436d8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 9 Jan 2019 09:16:41 -0800 Subject: [PATCH 07/19] Test values with type globalThis I ran into a problem with intersecting `Window & typeof globalThis`: 1. This adds a new index signature to Window, which is probably not desired. In fact, with noImplicitAny, it's not desired on globalThis either I think. 2. Adding this type requires editing TSJS-lib-generator, not this repo. So I added the test cases and will probably update them later, when those two problems are fixed. --- src/compiler/checker.ts | 2 +- .../globalThisVarDeclaration.errors.txt | 49 +++++++++++++++ .../reference/globalThisVarDeclaration.js | 25 ++++++++ .../globalThisVarDeclaration.symbols | 45 ++++++++++++++ .../reference/globalThisVarDeclaration.types | 61 +++++++++++++++++++ .../es2019/globalThisVarDeclaration.ts | 23 ++++++- 6 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/globalThisVarDeclaration.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 98dc9ff7242db..a55c75336fb84 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16714,7 +16714,7 @@ namespace ts { if (type === globalThisType && capturedByArrowFunction) { error(node, Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this); } - if (!type) { + else if (!type) { // With noImplicitThis, functions may not reference 'this' if it has type 'any' const diag = error(node, Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); if (!isSourceFile(container)) { diff --git a/tests/baselines/reference/globalThisVarDeclaration.errors.txt b/tests/baselines/reference/globalThisVarDeclaration.errors.txt new file mode 100644 index 0000000000000..70693098a43f9 --- /dev/null +++ b/tests/baselines/reference/globalThisVarDeclaration.errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/es2019/actual.ts(6,6): error TS2339: Property 'a' does not exist on type 'Window'. +tests/cases/conformance/es2019/actual.ts(7,6): error TS2339: Property 'b' does not exist on type 'Window'. +tests/cases/conformance/es2019/actual.ts(8,8): error TS2339: Property 'a' does not exist on type 'Window'. +tests/cases/conformance/es2019/actual.ts(9,8): error TS2339: Property 'b' does not exist on type 'Window'. +tests/cases/conformance/es2019/b.js(6,6): error TS2339: Property 'a' does not exist on type 'Window'. +tests/cases/conformance/es2019/b.js(7,6): error TS2339: Property 'b' does not exist on type 'Window'. +tests/cases/conformance/es2019/b.js(8,8): error TS2339: Property 'a' does not exist on type 'Window'. +tests/cases/conformance/es2019/b.js(9,8): error TS2339: Property 'b' does not exist on type 'Window'. + + +==== tests/cases/conformance/es2019/b.js (4 errors) ==== + var a = 10; + this.a; + this.b; + globalThis.a; + globalThis.b; + self.a; + ~ +!!! error TS2339: Property 'a' does not exist on type 'Window'. + self.b; + ~ +!!! error TS2339: Property 'b' does not exist on type 'Window'. + window.a; + ~ +!!! error TS2339: Property 'a' does not exist on type 'Window'. + window.b; + ~ +!!! error TS2339: Property 'b' does not exist on type 'Window'. + +==== tests/cases/conformance/es2019/actual.ts (4 errors) ==== + var b = 10; + this.a; + this.b; + globalThis.a; + globalThis.b; + self.a; + ~ +!!! error TS2339: Property 'a' does not exist on type 'Window'. + self.b; + ~ +!!! error TS2339: Property 'b' does not exist on type 'Window'. + window.a; + ~ +!!! error TS2339: Property 'a' does not exist on type 'Window'. + window.b; + ~ +!!! error TS2339: Property 'b' does not exist on type 'Window'. + + \ No newline at end of file diff --git a/tests/baselines/reference/globalThisVarDeclaration.js b/tests/baselines/reference/globalThisVarDeclaration.js index 60f52490c0154..a192b671a41d9 100644 --- a/tests/baselines/reference/globalThisVarDeclaration.js +++ b/tests/baselines/reference/globalThisVarDeclaration.js @@ -4,17 +4,42 @@ var a = 10; this.a; this.b; +globalThis.a; +globalThis.b; +self.a; +self.b; +window.a; +window.b; //// [actual.ts] var b = 10; this.a; this.b; +globalThis.a; +globalThis.b; +self.a; +self.b; +window.a; +window.b; + //// [output.js] var a = 10; this.a; this.b; +globalThis.a; +globalThis.b; +self.a; +self.b; +window.a; +window.b; var b = 10; this.a; this.b; +globalThis.a; +globalThis.b; +self.a; +self.b; +window.a; +window.b; diff --git a/tests/baselines/reference/globalThisVarDeclaration.symbols b/tests/baselines/reference/globalThisVarDeclaration.symbols index 18e012062e102..e7b089e7c9a83 100644 --- a/tests/baselines/reference/globalThisVarDeclaration.symbols +++ b/tests/baselines/reference/globalThisVarDeclaration.symbols @@ -12,6 +12,28 @@ this.b; >this : Symbol(typeof globalThis) >b : Symbol(b, Decl(actual.ts, 0, 3)) +globalThis.a; +>globalThis.a : Symbol(a, Decl(b.js, 0, 3)) +>globalThis : Symbol(globalThis, Decl(lib.esnext.globalthis.d.ts, --, --)) +>a : Symbol(a, Decl(b.js, 0, 3)) + +globalThis.b; +>globalThis.b : Symbol(b, Decl(actual.ts, 0, 3)) +>globalThis : Symbol(globalThis, Decl(lib.esnext.globalthis.d.ts, --, --)) +>b : Symbol(b, Decl(actual.ts, 0, 3)) + +self.a; +>self : Symbol(self, Decl(lib.dom.d.ts, --, --)) + +self.b; +>self : Symbol(self, Decl(lib.dom.d.ts, --, --)) + +window.a; +>window : Symbol(window, Decl(lib.dom.d.ts, --, --)) + +window.b; +>window : Symbol(window, Decl(lib.dom.d.ts, --, --)) + === tests/cases/conformance/es2019/actual.ts === var b = 10; >b : Symbol(b, Decl(actual.ts, 0, 3)) @@ -26,3 +48,26 @@ this.b; >this : Symbol(typeof globalThis) >b : Symbol(b, Decl(actual.ts, 0, 3)) +globalThis.a; +>globalThis.a : Symbol(a, Decl(b.js, 0, 3)) +>globalThis : Symbol(globalThis, Decl(lib.esnext.globalthis.d.ts, --, --)) +>a : Symbol(a, Decl(b.js, 0, 3)) + +globalThis.b; +>globalThis.b : Symbol(b, Decl(actual.ts, 0, 3)) +>globalThis : Symbol(globalThis, Decl(lib.esnext.globalthis.d.ts, --, --)) +>b : Symbol(b, Decl(actual.ts, 0, 3)) + +self.a; +>self : Symbol(self, Decl(lib.dom.d.ts, --, --)) + +self.b; +>self : Symbol(self, Decl(lib.dom.d.ts, --, --)) + +window.a; +>window : Symbol(window, Decl(lib.dom.d.ts, --, --)) + +window.b; +>window : Symbol(window, Decl(lib.dom.d.ts, --, --)) + + diff --git a/tests/baselines/reference/globalThisVarDeclaration.types b/tests/baselines/reference/globalThisVarDeclaration.types index d24c057e1ef0d..0921e404ad592 100644 --- a/tests/baselines/reference/globalThisVarDeclaration.types +++ b/tests/baselines/reference/globalThisVarDeclaration.types @@ -13,6 +13,36 @@ this.b; >this : typeof globalThis >b : number +globalThis.a; +>globalThis.a : number +>globalThis : typeof globalThis +>a : number + +globalThis.b; +>globalThis.b : number +>globalThis : typeof globalThis +>b : number + +self.a; +>self.a : any +>self : Window +>a : any + +self.b; +>self.b : any +>self : Window +>b : any + +window.a; +>window.a : any +>window : Window +>a : any + +window.b; +>window.b : any +>window : Window +>b : any + === tests/cases/conformance/es2019/actual.ts === var b = 10; >b : number @@ -28,3 +58,34 @@ this.b; >this : typeof globalThis >b : number +globalThis.a; +>globalThis.a : number +>globalThis : typeof globalThis +>a : number + +globalThis.b; +>globalThis.b : number +>globalThis : typeof globalThis +>b : number + +self.a; +>self.a : any +>self : Window +>a : any + +self.b; +>self.b : any +>self : Window +>b : any + +window.a; +>window.a : any +>window : Window +>a : any + +window.b; +>window.b : any +>window : Window +>b : any + + diff --git a/tests/cases/conformance/es2019/globalThisVarDeclaration.ts b/tests/cases/conformance/es2019/globalThisVarDeclaration.ts index 5508b4de06e18..5b75d1095a687 100644 --- a/tests/cases/conformance/es2019/globalThisVarDeclaration.ts +++ b/tests/cases/conformance/es2019/globalThisVarDeclaration.ts @@ -1,14 +1,35 @@ // @out: output.js // @target: esnext -// @lib: esnext +// @lib: esnext, dom // @Filename: b.js // @allowJs: true // @checkJs: true var a = 10; this.a; this.b; +globalThis.a; +globalThis.b; + +// DOM access is not supported until the index signature is handled more strictly +self.a; +self.b; +window.a; +window.b; +top.a; +top.b; // @Filename: actual.ts var b = 10; this.a; this.b; +globalThis.a; +globalThis.b; + +// same here -- no DOM access to globalThis yet +self.a; +self.b; +window.a; +window.b; +top.a; +top.b; + From 88c6f7d231fa6242bbe89dedc0c4096a12cab00c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 9 Jan 2019 09:19:01 -0800 Subject: [PATCH 08/19] Add esnext declaration for globalThis --- src/lib/esnext.d.ts | 1 + src/lib/esnext.globalthis.d.ts | 1 + src/lib/libs.json | 1 + 3 files changed, 3 insertions(+) create mode 100644 src/lib/esnext.globalthis.d.ts diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index 45d7e1d96c9cf..d89e10a92940a 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,5 +1,6 @@ /// /// +/// /// /// /// diff --git a/src/lib/esnext.globalthis.d.ts b/src/lib/esnext.globalthis.d.ts new file mode 100644 index 0000000000000..4698cdb3181ff --- /dev/null +++ b/src/lib/esnext.globalthis.d.ts @@ -0,0 +1 @@ +declare var globalThis: typeof globalThis; diff --git a/src/lib/libs.json b/src/lib/libs.json index 3077181af6eeb..2b6ac43f00881 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -35,6 +35,7 @@ "esnext.asynciterable", "esnext.array", "esnext.bigint", + "esnext.globalthis", "esnext.symbol", "esnext.intl", // Default libraries From 4215a7665990fbaee7ad9129a72cc928d100782a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 9 Jan 2019 10:59:49 -0800 Subject: [PATCH 09/19] Switch to symbol-based approach I decided I didn't like the import-type-based approach. Update baselines to reflect the difference. --- src/compiler/checker.ts | 32 +- src/compiler/commandLineParser.ts | 1 - src/compiler/parser.ts | 6 +- src/compiler/scanner.ts | 1 - src/compiler/types.ts | 3 - src/lib/esnext.d.ts | 1 - src/lib/libs.json | 1 - .../reference/api/tsserverlibrary.d.ts | 394 +++++++++--------- tests/baselines/reference/api/typescript.d.ts | 394 +++++++++--------- .../reference/assignmentLHSIsValue.symbols | 4 +- .../castExpressionParentheses.symbols | 4 +- ...sionThisExpressionAndAliasInGlobal.symbols | 2 +- ...sExpressionAndAmbientClassInGlobal.symbols | 2 +- ...hisExpressionAndAmbientVarInGlobal.symbols | 2 +- ...sionThisExpressionAndClassInGlobal.symbols | 2 +- ...isionThisExpressionAndEnumInGlobal.symbols | 2 +- ...nThisExpressionAndFunctionInGlobal.symbols | 2 +- ...nThisExpressionAndLocalVarInLambda.symbols | 2 +- ...ionThisExpressionAndModuleInGlobal.symbols | 2 +- ...lisionThisExpressionAndVarInGlobal.symbols | 2 +- .../reference/commentsInterface.symbols | 12 +- .../compoundAssignmentLHSIsValue.symbols | 8 +- ...ExponentiationAssignmentLHSIsValue.symbols | 4 +- .../computedPropertyNames20_ES5.symbols | 2 +- .../computedPropertyNames20_ES6.symbols | 2 +- ...ructorWithIncompleteTypeAnnotation.symbols | 2 +- .../emitArrowFunctionThisCapturing.symbols | 6 +- .../emitArrowFunctionThisCapturingES6.symbols | 6 +- ...CapturingThisInTupleDestructuring1.symbols | 6 +- .../reference/globalThisCapture.symbols | 2 +- .../globalThisVarDeclaration.errors.txt | 40 +- .../reference/globalThisVarDeclaration.js | 14 + .../globalThisVarDeclaration.symbols | 30 +- .../reference/globalThisVarDeclaration.types | 22 + .../reference/implicitAnyInCatch.symbols | 2 +- ...neJsxFactoryDeclarationsLocalTypes.symbols | 2 +- ...jsxAttributeWithoutExpressionReact.symbols | 2 +- .../reference/jsxReactTestSuite.symbols | 6 +- ...pertyAccessAndArrowFunctionIndent1.symbols | 4 +- .../reference/noImplicitThisFunctions.symbols | 4 +- .../parserCommaInTypeMemberList2.symbols | 2 +- .../parserConditionalExpression1.symbols | 6 +- .../reference/parserForStatement8.symbols | 2 +- .../parserModifierOnStatementInBlock2.symbols | 2 +- .../reference/parserStrictMode16.symbols | 2 +- .../reference/parserUnaryExpression1.symbols | 2 +- .../reference/propertyWrappedInTry.symbols | 2 +- .../reference/thisInInvalidContexts.symbols | 2 +- ...hisInInvalidContextsExternalModule.symbols | 2 +- .../reference/thisTypeInFunctions.symbols | 10 +- .../thisTypeInFunctionsNegative.symbols | 12 +- .../reference/topLevelLambda2.symbols | 2 +- .../reference/topLevelLambda3.symbols | 2 +- .../reference/topLevelLambda4.symbols | 2 +- .../reference/topLevelThisAssignment.symbols | 6 +- .../tsxAttributeResolution15.errors.txt | 5 +- .../tsxAttributeResolution15.symbols | 2 +- .../tsxSpreadAttributesResolution4.symbols | 2 +- .../typeFromPropertyAssignment23.symbols | 2 +- .../typeFromPropertyAssignment9.symbols | 2 +- tests/baselines/reference/typeOfThis.symbols | 13 +- tests/baselines/reference/typeOfThis.types | 3 + .../reference/unknownSymbols1.symbols | 2 +- .../reference/wrappedIncovations1.symbols | 2 +- .../reference/wrappedIncovations2.symbols | 2 +- .../cases/fourslash/findAllRefsThisKeyword.ts | 2 +- .../findAllRefsThisKeywordMultipleFiles.ts | 2 +- 67 files changed, 600 insertions(+), 530 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 01f9d527142bb..95e105942a41d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -519,7 +519,7 @@ namespace ts { let deferredGlobalExcludeSymbol: Symbol; let deferredGlobalPickSymbol: Symbol; let deferredGlobalBigIntType: ObjectType; - let deferredGlobalThisType: ObjectType; // (unbound) `window` has type Window & globalThis; `this` and `globalThis` and `global` have type GlobalThis + let deferredGlobalThisSymbol: Symbol | undefined; const allPotentiallyUnusedIdentifiers = createMap(); // key is file name @@ -1502,6 +1502,9 @@ namespace ts { } if (!excludeGlobals) { + if (name === "globalThis" as __String) { + return getGlobalThisSymbol(); + } result = lookup(globals, name, meaning); } } @@ -8977,13 +8980,14 @@ namespace ts { return symbol && getTypeOfGlobalSymbol(symbol, arity); } - function getGlobalThisType() { - if (!deferredGlobalThisType) { - const t = createObjectType(ObjectFlags.Interface, createSymbol(SymbolFlags.Type, "typeof globalThis" as __String)); - setStructuredTypeMembers(t, globals, emptyArray, emptyArray, createIndexInfo(anyType, /*isReadonly*/ false), undefined); - deferredGlobalThisType = t; + function getGlobalThisSymbol() { + if (!deferredGlobalThisSymbol) { + const s = createSymbol(SymbolFlags.ValueModule | SymbolFlags.NamespaceModule, "globalThis" as __String); + s.exports = globals; + s.valueDeclaration = createNode(SyntaxKind.Identifier) as Identifier; + deferredGlobalThisSymbol = s; } - return deferredGlobalThisType; + return deferredGlobalThisSymbol; } function getGlobalExtractSymbol(): Symbol { @@ -10117,10 +10121,6 @@ namespace ts { function getTypeFromImportTypeNode(node: ImportTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { - if (node.isGlobalThis) { - Debug.assert(!!node.isTypeOf); - return links.resolvedType = getGlobalThisType(); - } if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments error(node, Diagnostics.Type_arguments_cannot_be_used_here); links.resolvedSymbol = unknownSymbol; @@ -16709,7 +16709,7 @@ namespace ts { } const type = tryGetThisTypeAt(node, container); - const globalThisType = getGlobalThisType(); + const globalThisType = getTypeOfSymbol(getGlobalThisSymbol()); if (noImplicitThis) { if (type === globalThisType && capturedByArrowFunction) { error(node, Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this); @@ -16782,7 +16782,7 @@ namespace ts { return fileSymbol && getTypeOfSymbol(fileSymbol); } else { - return getGlobalThisType(); + return getTypeOfSymbol(getGlobalThisSymbol()); } } } @@ -19043,6 +19043,12 @@ namespace ts { if (isJSLiteralType(leftType)) { return anyType; } + if (leftType.symbol === getGlobalThisSymbol()) { + if (noImplicitAny) { + error(right, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType)); + } + return anyType; + } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, leftType.flags & TypeFlags.TypeParameter && (leftType as TypeParameter).isThisType ? apparentType : leftType); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 53bbb14776b1b..43275605e2390 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -42,7 +42,6 @@ namespace ts { ["es2018.promise", "lib.es2018.promise.d.ts"], ["es2018.regexp", "lib.es2018.regexp.d.ts"], ["esnext.array", "lib.esnext.array.d.ts"], - ["esnext.globalthis", "lib.esnext.globalthis.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7986c58575369..f976f77ea985a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2869,7 +2869,7 @@ namespace ts { function isStartOfTypeOfImportType() { nextToken(); - return token() === SyntaxKind.ImportKeyword || token() === SyntaxKind.GlobalThisKeyword; + return token() === SyntaxKind.ImportKeyword; } function parseImportType(): ImportTypeNode { @@ -2877,10 +2877,6 @@ namespace ts { const node = createNode(SyntaxKind.ImportType) as ImportTypeNode; if (parseOptional(SyntaxKind.TypeOfKeyword)) { node.isTypeOf = true; - node.isGlobalThis = parseOptional(SyntaxKind.GlobalThisKeyword); - if (node.isGlobalThis) { - return finishNode(node); - } } parseExpected(SyntaxKind.ImportKeyword); parseExpected(SyntaxKind.OpenParenToken); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 045349ae99df6..d59be9758656c 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -88,7 +88,6 @@ namespace ts { from: SyntaxKind.FromKeyword, function: SyntaxKind.FunctionKeyword, get: SyntaxKind.GetKeyword, - globalThis: SyntaxKind.GlobalThisKeyword, if: SyntaxKind.IfKeyword, implements: SyntaxKind.ImplementsKeyword, import: SyntaxKind.ImportKeyword, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8917bef9d3f0a..5c42d3eb5104c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -55,7 +55,6 @@ namespace ts { | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword - | SyntaxKind.GlobalThisKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword @@ -255,7 +254,6 @@ namespace ts { ConstructorKeyword, DeclareKeyword, GetKeyword, - GlobalThisKeyword, InferKeyword, IsKeyword, KeyOfKeyword, @@ -1127,7 +1125,6 @@ namespace ts { export interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; - isGlobalThis: boolean; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index d89e10a92940a..45d7e1d96c9cf 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,6 +1,5 @@ /// /// -/// /// /// /// diff --git a/src/lib/libs.json b/src/lib/libs.json index 2b6ac43f00881..3077181af6eeb 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -35,7 +35,6 @@ "esnext.asynciterable", "esnext.array", "esnext.bigint", - "esnext.globalthis", "esnext.symbol", "esnext.intl", // Default libraries diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 20886502c37c9..91f492ddd1d52 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -73,7 +73,7 @@ declare namespace ts { end: number; } type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalThisKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { Unknown = 0, @@ -203,193 +203,192 @@ declare namespace ts { ConstructorKeyword = 124, DeclareKeyword = 125, GetKeyword = 126, - GlobalThisKeyword = 127, - InferKeyword = 128, - IsKeyword = 129, - KeyOfKeyword = 130, - ModuleKeyword = 131, - NamespaceKeyword = 132, - NeverKeyword = 133, - ReadonlyKeyword = 134, - RequireKeyword = 135, - NumberKeyword = 136, - ObjectKeyword = 137, - SetKeyword = 138, - StringKeyword = 139, - SymbolKeyword = 140, - TypeKeyword = 141, - UndefinedKeyword = 142, - UniqueKeyword = 143, - UnknownKeyword = 144, - FromKeyword = 145, - GlobalKeyword = 146, - BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - SourceFile = 280, - Bundle = 281, - UnparsedSource = 282, - InputFiles = 283, - JSDocTypeExpression = 284, - JSDocAllType = 285, - JSDocUnknownType = 286, - JSDocNullableType = 287, - JSDocNonNullableType = 288, - JSDocOptionalType = 289, - JSDocFunctionType = 290, - JSDocVariadicType = 291, - JSDocComment = 292, - JSDocTypeLiteral = 293, - JSDocSignature = 294, - JSDocTag = 295, - JSDocAugmentsTag = 296, - JSDocClassTag = 297, - JSDocCallbackTag = 298, - JSDocEnumTag = 299, - JSDocParameterTag = 300, - JSDocReturnTag = 301, - JSDocThisTag = 302, - JSDocTypeTag = 303, - JSDocTemplateTag = 304, - JSDocTypedefTag = 305, - JSDocPropertyTag = 306, - SyntaxList = 307, - NotEmittedStatement = 308, - PartiallyEmittedExpression = 309, - CommaListExpression = 310, - MergeDeclarationMarker = 311, - EndOfDeclarationMarker = 312, - Count = 313, + InferKeyword = 127, + IsKeyword = 128, + KeyOfKeyword = 129, + ModuleKeyword = 130, + NamespaceKeyword = 131, + NeverKeyword = 132, + ReadonlyKeyword = 133, + RequireKeyword = 134, + NumberKeyword = 135, + ObjectKeyword = 136, + SetKeyword = 137, + StringKeyword = 138, + SymbolKeyword = 139, + TypeKeyword = 140, + UndefinedKeyword = 141, + UniqueKeyword = 142, + UnknownKeyword = 143, + FromKeyword = 144, + GlobalKeyword = 145, + BigIntKeyword = 146, + OfKeyword = 147, + QualifiedName = 148, + ComputedPropertyName = 149, + TypeParameter = 150, + Parameter = 151, + Decorator = 152, + PropertySignature = 153, + PropertyDeclaration = 154, + MethodSignature = 155, + MethodDeclaration = 156, + Constructor = 157, + GetAccessor = 158, + SetAccessor = 159, + CallSignature = 160, + ConstructSignature = 161, + IndexSignature = 162, + TypePredicate = 163, + TypeReference = 164, + FunctionType = 165, + ConstructorType = 166, + TypeQuery = 167, + TypeLiteral = 168, + ArrayType = 169, + TupleType = 170, + OptionalType = 171, + RestType = 172, + UnionType = 173, + IntersectionType = 174, + ConditionalType = 175, + InferType = 176, + ParenthesizedType = 177, + ThisType = 178, + TypeOperator = 179, + IndexedAccessType = 180, + MappedType = 181, + LiteralType = 182, + ImportType = 183, + ObjectBindingPattern = 184, + ArrayBindingPattern = 185, + BindingElement = 186, + ArrayLiteralExpression = 187, + ObjectLiteralExpression = 188, + PropertyAccessExpression = 189, + ElementAccessExpression = 190, + CallExpression = 191, + NewExpression = 192, + TaggedTemplateExpression = 193, + TypeAssertionExpression = 194, + ParenthesizedExpression = 195, + FunctionExpression = 196, + ArrowFunction = 197, + DeleteExpression = 198, + TypeOfExpression = 199, + VoidExpression = 200, + AwaitExpression = 201, + PrefixUnaryExpression = 202, + PostfixUnaryExpression = 203, + BinaryExpression = 204, + ConditionalExpression = 205, + TemplateExpression = 206, + YieldExpression = 207, + SpreadElement = 208, + ClassExpression = 209, + OmittedExpression = 210, + ExpressionWithTypeArguments = 211, + AsExpression = 212, + NonNullExpression = 213, + MetaProperty = 214, + SyntheticExpression = 215, + TemplateSpan = 216, + SemicolonClassElement = 217, + Block = 218, + VariableStatement = 219, + EmptyStatement = 220, + ExpressionStatement = 221, + IfStatement = 222, + DoStatement = 223, + WhileStatement = 224, + ForStatement = 225, + ForInStatement = 226, + ForOfStatement = 227, + ContinueStatement = 228, + BreakStatement = 229, + ReturnStatement = 230, + WithStatement = 231, + SwitchStatement = 232, + LabeledStatement = 233, + ThrowStatement = 234, + TryStatement = 235, + DebuggerStatement = 236, + VariableDeclaration = 237, + VariableDeclarationList = 238, + FunctionDeclaration = 239, + ClassDeclaration = 240, + InterfaceDeclaration = 241, + TypeAliasDeclaration = 242, + EnumDeclaration = 243, + ModuleDeclaration = 244, + ModuleBlock = 245, + CaseBlock = 246, + NamespaceExportDeclaration = 247, + ImportEqualsDeclaration = 248, + ImportDeclaration = 249, + ImportClause = 250, + NamespaceImport = 251, + NamedImports = 252, + ImportSpecifier = 253, + ExportAssignment = 254, + ExportDeclaration = 255, + NamedExports = 256, + ExportSpecifier = 257, + MissingDeclaration = 258, + ExternalModuleReference = 259, + JsxElement = 260, + JsxSelfClosingElement = 261, + JsxOpeningElement = 262, + JsxClosingElement = 263, + JsxFragment = 264, + JsxOpeningFragment = 265, + JsxClosingFragment = 266, + JsxAttribute = 267, + JsxAttributes = 268, + JsxSpreadAttribute = 269, + JsxExpression = 270, + CaseClause = 271, + DefaultClause = 272, + HeritageClause = 273, + CatchClause = 274, + PropertyAssignment = 275, + ShorthandPropertyAssignment = 276, + SpreadAssignment = 277, + EnumMember = 278, + SourceFile = 279, + Bundle = 280, + UnparsedSource = 281, + InputFiles = 282, + JSDocTypeExpression = 283, + JSDocAllType = 284, + JSDocUnknownType = 285, + JSDocNullableType = 286, + JSDocNonNullableType = 287, + JSDocOptionalType = 288, + JSDocFunctionType = 289, + JSDocVariadicType = 290, + JSDocComment = 291, + JSDocTypeLiteral = 292, + JSDocSignature = 293, + JSDocTag = 294, + JSDocAugmentsTag = 295, + JSDocClassTag = 296, + JSDocCallbackTag = 297, + JSDocEnumTag = 298, + JSDocParameterTag = 299, + JSDocReturnTag = 300, + JSDocThisTag = 301, + JSDocTypeTag = 302, + JSDocTemplateTag = 303, + JSDocTypedefTag = 304, + JSDocPropertyTag = 305, + SyntaxList = 306, + NotEmittedStatement = 307, + PartiallyEmittedExpression = 308, + CommaListExpression = 309, + MergeDeclarationMarker = 310, + EndOfDeclarationMarker = 311, + Count = 312, FirstAssignment = 59, LastAssignment = 71, FirstCompoundAssignment = 60, @@ -397,15 +396,15 @@ declare namespace ts { FirstReservedWord = 73, LastReservedWord = 108, FirstKeyword = 73, - LastKeyword = 148, + LastKeyword = 147, FirstFutureReservedWord = 109, LastFutureReservedWord = 117, - FirstTypeNode = 164, - LastTypeNode = 184, + FirstTypeNode = 163, + LastTypeNode = 183, FirstPunctuation = 18, LastPunctuation = 71, FirstToken = 0, - LastToken = 148, + LastToken = 147, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -414,11 +413,11 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 71, - FirstNode = 149, - FirstJSDocNode = 284, - LastJSDocNode = 306, - FirstJSDocTagNode = 295, - LastJSDocTagNode = 306 + FirstNode = 148, + FirstJSDocNode = 283, + LastJSDocNode = 305, + FirstJSDocTagNode = 294, + LastJSDocTagNode = 305 } enum NodeFlags { None = 0, @@ -733,7 +732,6 @@ declare namespace ts { } interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; - isGlobalThis: boolean; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index c747edf0e95ba..0e693f698f253 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -73,7 +73,7 @@ declare namespace ts { end: number; } type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalThisKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { Unknown = 0, @@ -203,193 +203,192 @@ declare namespace ts { ConstructorKeyword = 124, DeclareKeyword = 125, GetKeyword = 126, - GlobalThisKeyword = 127, - InferKeyword = 128, - IsKeyword = 129, - KeyOfKeyword = 130, - ModuleKeyword = 131, - NamespaceKeyword = 132, - NeverKeyword = 133, - ReadonlyKeyword = 134, - RequireKeyword = 135, - NumberKeyword = 136, - ObjectKeyword = 137, - SetKeyword = 138, - StringKeyword = 139, - SymbolKeyword = 140, - TypeKeyword = 141, - UndefinedKeyword = 142, - UniqueKeyword = 143, - UnknownKeyword = 144, - FromKeyword = 145, - GlobalKeyword = 146, - BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - SourceFile = 280, - Bundle = 281, - UnparsedSource = 282, - InputFiles = 283, - JSDocTypeExpression = 284, - JSDocAllType = 285, - JSDocUnknownType = 286, - JSDocNullableType = 287, - JSDocNonNullableType = 288, - JSDocOptionalType = 289, - JSDocFunctionType = 290, - JSDocVariadicType = 291, - JSDocComment = 292, - JSDocTypeLiteral = 293, - JSDocSignature = 294, - JSDocTag = 295, - JSDocAugmentsTag = 296, - JSDocClassTag = 297, - JSDocCallbackTag = 298, - JSDocEnumTag = 299, - JSDocParameterTag = 300, - JSDocReturnTag = 301, - JSDocThisTag = 302, - JSDocTypeTag = 303, - JSDocTemplateTag = 304, - JSDocTypedefTag = 305, - JSDocPropertyTag = 306, - SyntaxList = 307, - NotEmittedStatement = 308, - PartiallyEmittedExpression = 309, - CommaListExpression = 310, - MergeDeclarationMarker = 311, - EndOfDeclarationMarker = 312, - Count = 313, + InferKeyword = 127, + IsKeyword = 128, + KeyOfKeyword = 129, + ModuleKeyword = 130, + NamespaceKeyword = 131, + NeverKeyword = 132, + ReadonlyKeyword = 133, + RequireKeyword = 134, + NumberKeyword = 135, + ObjectKeyword = 136, + SetKeyword = 137, + StringKeyword = 138, + SymbolKeyword = 139, + TypeKeyword = 140, + UndefinedKeyword = 141, + UniqueKeyword = 142, + UnknownKeyword = 143, + FromKeyword = 144, + GlobalKeyword = 145, + BigIntKeyword = 146, + OfKeyword = 147, + QualifiedName = 148, + ComputedPropertyName = 149, + TypeParameter = 150, + Parameter = 151, + Decorator = 152, + PropertySignature = 153, + PropertyDeclaration = 154, + MethodSignature = 155, + MethodDeclaration = 156, + Constructor = 157, + GetAccessor = 158, + SetAccessor = 159, + CallSignature = 160, + ConstructSignature = 161, + IndexSignature = 162, + TypePredicate = 163, + TypeReference = 164, + FunctionType = 165, + ConstructorType = 166, + TypeQuery = 167, + TypeLiteral = 168, + ArrayType = 169, + TupleType = 170, + OptionalType = 171, + RestType = 172, + UnionType = 173, + IntersectionType = 174, + ConditionalType = 175, + InferType = 176, + ParenthesizedType = 177, + ThisType = 178, + TypeOperator = 179, + IndexedAccessType = 180, + MappedType = 181, + LiteralType = 182, + ImportType = 183, + ObjectBindingPattern = 184, + ArrayBindingPattern = 185, + BindingElement = 186, + ArrayLiteralExpression = 187, + ObjectLiteralExpression = 188, + PropertyAccessExpression = 189, + ElementAccessExpression = 190, + CallExpression = 191, + NewExpression = 192, + TaggedTemplateExpression = 193, + TypeAssertionExpression = 194, + ParenthesizedExpression = 195, + FunctionExpression = 196, + ArrowFunction = 197, + DeleteExpression = 198, + TypeOfExpression = 199, + VoidExpression = 200, + AwaitExpression = 201, + PrefixUnaryExpression = 202, + PostfixUnaryExpression = 203, + BinaryExpression = 204, + ConditionalExpression = 205, + TemplateExpression = 206, + YieldExpression = 207, + SpreadElement = 208, + ClassExpression = 209, + OmittedExpression = 210, + ExpressionWithTypeArguments = 211, + AsExpression = 212, + NonNullExpression = 213, + MetaProperty = 214, + SyntheticExpression = 215, + TemplateSpan = 216, + SemicolonClassElement = 217, + Block = 218, + VariableStatement = 219, + EmptyStatement = 220, + ExpressionStatement = 221, + IfStatement = 222, + DoStatement = 223, + WhileStatement = 224, + ForStatement = 225, + ForInStatement = 226, + ForOfStatement = 227, + ContinueStatement = 228, + BreakStatement = 229, + ReturnStatement = 230, + WithStatement = 231, + SwitchStatement = 232, + LabeledStatement = 233, + ThrowStatement = 234, + TryStatement = 235, + DebuggerStatement = 236, + VariableDeclaration = 237, + VariableDeclarationList = 238, + FunctionDeclaration = 239, + ClassDeclaration = 240, + InterfaceDeclaration = 241, + TypeAliasDeclaration = 242, + EnumDeclaration = 243, + ModuleDeclaration = 244, + ModuleBlock = 245, + CaseBlock = 246, + NamespaceExportDeclaration = 247, + ImportEqualsDeclaration = 248, + ImportDeclaration = 249, + ImportClause = 250, + NamespaceImport = 251, + NamedImports = 252, + ImportSpecifier = 253, + ExportAssignment = 254, + ExportDeclaration = 255, + NamedExports = 256, + ExportSpecifier = 257, + MissingDeclaration = 258, + ExternalModuleReference = 259, + JsxElement = 260, + JsxSelfClosingElement = 261, + JsxOpeningElement = 262, + JsxClosingElement = 263, + JsxFragment = 264, + JsxOpeningFragment = 265, + JsxClosingFragment = 266, + JsxAttribute = 267, + JsxAttributes = 268, + JsxSpreadAttribute = 269, + JsxExpression = 270, + CaseClause = 271, + DefaultClause = 272, + HeritageClause = 273, + CatchClause = 274, + PropertyAssignment = 275, + ShorthandPropertyAssignment = 276, + SpreadAssignment = 277, + EnumMember = 278, + SourceFile = 279, + Bundle = 280, + UnparsedSource = 281, + InputFiles = 282, + JSDocTypeExpression = 283, + JSDocAllType = 284, + JSDocUnknownType = 285, + JSDocNullableType = 286, + JSDocNonNullableType = 287, + JSDocOptionalType = 288, + JSDocFunctionType = 289, + JSDocVariadicType = 290, + JSDocComment = 291, + JSDocTypeLiteral = 292, + JSDocSignature = 293, + JSDocTag = 294, + JSDocAugmentsTag = 295, + JSDocClassTag = 296, + JSDocCallbackTag = 297, + JSDocEnumTag = 298, + JSDocParameterTag = 299, + JSDocReturnTag = 300, + JSDocThisTag = 301, + JSDocTypeTag = 302, + JSDocTemplateTag = 303, + JSDocTypedefTag = 304, + JSDocPropertyTag = 305, + SyntaxList = 306, + NotEmittedStatement = 307, + PartiallyEmittedExpression = 308, + CommaListExpression = 309, + MergeDeclarationMarker = 310, + EndOfDeclarationMarker = 311, + Count = 312, FirstAssignment = 59, LastAssignment = 71, FirstCompoundAssignment = 60, @@ -397,15 +396,15 @@ declare namespace ts { FirstReservedWord = 73, LastReservedWord = 108, FirstKeyword = 73, - LastKeyword = 148, + LastKeyword = 147, FirstFutureReservedWord = 109, LastFutureReservedWord = 117, - FirstTypeNode = 164, - LastTypeNode = 184, + FirstTypeNode = 163, + LastTypeNode = 183, FirstPunctuation = 18, LastPunctuation = 71, FirstToken = 0, - LastToken = 148, + LastToken = 147, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -414,11 +413,11 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 71, - FirstNode = 149, - FirstJSDocNode = 284, - LastJSDocNode = 306, - FirstJSDocTagNode = 295, - LastJSDocTagNode = 306 + FirstNode = 148, + FirstJSDocNode = 283, + LastJSDocNode = 305, + FirstJSDocTagNode = 294, + LastJSDocTagNode = 305 } enum NodeFlags { None = 0, @@ -733,7 +732,6 @@ declare namespace ts { } interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; - isGlobalThis: boolean; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; diff --git a/tests/baselines/reference/assignmentLHSIsValue.symbols b/tests/baselines/reference/assignmentLHSIsValue.symbols index 4af81616834b7..aad2ec2ed95ef 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.symbols +++ b/tests/baselines/reference/assignmentLHSIsValue.symbols @@ -27,7 +27,7 @@ function foo() { this = value; } >value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) this = value; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) // identifiers: module, class, enum, function @@ -117,7 +117,7 @@ foo() = value; // parentheses, the containted expression is value (this) = value; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) (M) = value; diff --git a/tests/baselines/reference/castExpressionParentheses.symbols b/tests/baselines/reference/castExpressionParentheses.symbols index 40434e49351c2..ebc326e0a854b 100644 --- a/tests/baselines/reference/castExpressionParentheses.symbols +++ b/tests/baselines/reference/castExpressionParentheses.symbols @@ -21,10 +21,10 @@ declare var a; (null); // names and dotted names (this); ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) (this.x); ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) ((a).x); >a : Symbol(a, Decl(castExpressionParentheses.ts, 0, 11)) diff --git a/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols index a09cbf16ccd63..29cb9d44b4998 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndAliasInGlobal.symbols @@ -7,7 +7,7 @@ module a { } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndAliasInGlobal.ts, 3, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) import _this = a; // Error >_this : Symbol(_this, Decl(collisionThisExpressionAndAliasInGlobal.ts, 3, 19)) diff --git a/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols index a2f376ae1b29f..ba225612d7383 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndAmbientClassInGlobal.symbols @@ -4,7 +4,7 @@ declare class _this { // no error - as no code generation } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndAmbientClassInGlobal.ts, 2, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) var a = new _this(); // Error >a : Symbol(a, Decl(collisionThisExpressionAndAmbientClassInGlobal.ts, 3, 3)) diff --git a/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols index 3bc464d2e2aa0..702a8300c3687 100644 --- a/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndAmbientVarInGlobal.symbols @@ -4,7 +4,7 @@ declare var _this: number; // no error as no code gen var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndAmbientVarInGlobal.ts, 1, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) _this = 10; // Error >_this : Symbol(_this, Decl(collisionThisExpressionAndAmbientVarInGlobal.ts, 0, 11)) diff --git a/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols index 170b62d9ad770..ba749b89ad089 100644 --- a/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndClassInGlobal.symbols @@ -4,5 +4,5 @@ class _this { } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndClassInGlobal.ts, 2, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols index 5b1530d1e40f4..88723692ffdd8 100644 --- a/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndEnumInGlobal.symbols @@ -10,5 +10,5 @@ enum _this { // Error } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndEnumInGlobal.ts, 4, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols index 63e067f573ad0..5461d86a0fcbb 100644 --- a/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndFunctionInGlobal.symbols @@ -6,5 +6,5 @@ function _this() { //Error } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndFunctionInGlobal.ts, 3, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols b/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols index 8c78af6cef5ee..79bfda70d2887 100644 --- a/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarInLambda.symbols @@ -15,7 +15,7 @@ var x = { return callback(this); >callback : Symbol(callback, Decl(collisionThisExpressionAndLocalVarInLambda.ts, 3, 14)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) } } alert(x.doStuff(x => alert(x))); diff --git a/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols index aaa8818b13b59..8cd392ac2687c 100644 --- a/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndModuleInGlobal.symbols @@ -8,5 +8,5 @@ module _this { //Error } var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndModuleInGlobal.ts, 4, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) diff --git a/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols b/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols index 9ab40210b9a10..9554f0013f942 100644 --- a/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols +++ b/tests/baselines/reference/collisionThisExpressionAndVarInGlobal.symbols @@ -4,5 +4,5 @@ var _this = 1; var f = () => this; >f : Symbol(f, Decl(collisionThisExpressionAndVarInGlobal.ts, 1, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) diff --git a/tests/baselines/reference/commentsInterface.symbols b/tests/baselines/reference/commentsInterface.symbols index 6e0d02acaa4e6..d98dae0c8938d 100644 --- a/tests/baselines/reference/commentsInterface.symbols +++ b/tests/baselines/reference/commentsInterface.symbols @@ -187,25 +187,25 @@ i3_i = { l: this.f, >l : Symbol(l, Decl(commentsInterface.ts, 56, 56)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) /** own x*/ x: this.f(10), >x : Symbol(x, Decl(commentsInterface.ts, 57, 14)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) nc_x: this.l(this.x), >nc_x : Symbol(nc_x, Decl(commentsInterface.ts, 59, 18)) ->this : Symbol(typeof globalThis) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) +>this : Symbol(globalThis) nc_f: this.f, >nc_f : Symbol(nc_f, Decl(commentsInterface.ts, 60, 25)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) nc_l: this.l >nc_l : Symbol(nc_l, Decl(commentsInterface.ts, 61, 17)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) }; i3_i.f(10); diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols b/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols index f546c65034b7c..891127c32cc2b 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.symbols @@ -51,11 +51,11 @@ function foo() { } this *= value; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) this += value; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) // identifiers: module, class, enum, function @@ -218,11 +218,11 @@ foo() += value; // parentheses, the containted expression is value (this) *= value; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) (this) += value; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >value : Symbol(value, Decl(compoundAssignmentLHSIsValue.ts, 1, 3)) (M) *= value; diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols index c7daff9a0530d..5596f648979e3 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.symbols @@ -36,7 +36,7 @@ function foo() { } this **= value; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >value : Symbol(value, Decl(compoundExponentiationAssignmentLHSIsValue.ts, 1, 3)) // identifiers: module, class, enum, function @@ -136,7 +136,7 @@ foo() **= value; // parentheses, the containted expression is value (this) **= value; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >value : Symbol(value, Decl(compoundExponentiationAssignmentLHSIsValue.ts, 1, 3)) (M) **= value; diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.symbols b/tests/baselines/reference/computedPropertyNames20_ES5.symbols index 15a9f9865b320..3ac422d6e73c0 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames20_ES5.symbols @@ -4,5 +4,5 @@ var obj = { [this.bar]: 0 >[this.bar] : Symbol([this.bar], Decl(computedPropertyNames20_ES5.ts, 0, 11)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) } diff --git a/tests/baselines/reference/computedPropertyNames20_ES6.symbols b/tests/baselines/reference/computedPropertyNames20_ES6.symbols index 5895a1aec8191..62c934426fdb1 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames20_ES6.symbols @@ -4,5 +4,5 @@ var obj = { [this.bar]: 0 >[this.bar] : Symbol([this.bar], Decl(computedPropertyNames20_ES6.ts, 0, 11)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols index 8581326f8ec0d..f7e719e39d3e3 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols @@ -579,7 +579,7 @@ module TypeScriptAllInOne { } public method2() { return 2 * this.method1(2); ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) } } diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols b/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols index 0083b96821072..e130eafd77095 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols @@ -3,7 +3,7 @@ var f1 = () => { >f1 : Symbol(f1, Decl(emitArrowFunctionThisCapturing.ts, 0, 3)) this.age = 10 ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) }; @@ -13,7 +13,7 @@ var f2 = (x: string) => { this.name = x >this.name : Symbol(name, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(emitArrowFunctionThisCapturing.ts, 4, 10)) } @@ -26,7 +26,7 @@ foo(() => { >foo : Symbol(foo, Decl(emitArrowFunctionThisCapturing.ts, 6, 1)) this.age = 100; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) return true; }); diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols index 61e65b7b4cabb..d370a207de69d 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols @@ -3,7 +3,7 @@ var f1 = () => { >f1 : Symbol(f1, Decl(emitArrowFunctionThisCapturingES6.ts, 0, 3)) this.age = 10 ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) }; @@ -13,7 +13,7 @@ var f2 = (x: string) => { this.name = x >this.name : Symbol(name, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(emitArrowFunctionThisCapturingES6.ts, 4, 10)) } @@ -26,7 +26,7 @@ foo(() => { >foo : Symbol(foo, Decl(emitArrowFunctionThisCapturingES6.ts, 6, 1)) this.age = 100; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) return true; }); diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols index 18f7cbb401980..bfef6d5b3e3a1 100644 --- a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.symbols @@ -8,9 +8,9 @@ wrapper((array: [any]) => { >array : Symbol(array, Decl(emitCapturingThisInTupleDestructuring1.ts, 1, 9)) [this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this" ->this : Symbol(typeof globalThis) ->this : Symbol(typeof globalThis) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) +>this : Symbol(globalThis) +>this : Symbol(globalThis) >array : Symbol(array, Decl(emitCapturingThisInTupleDestructuring1.ts, 1, 9)) }); diff --git a/tests/baselines/reference/globalThisCapture.symbols b/tests/baselines/reference/globalThisCapture.symbols index 43b291a1ba972..9ece286c98f29 100644 --- a/tests/baselines/reference/globalThisCapture.symbols +++ b/tests/baselines/reference/globalThisCapture.symbols @@ -2,7 +2,7 @@ // Add a lambda to ensure global 'this' capture is triggered (()=>this.window); >this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) var parts = []; diff --git a/tests/baselines/reference/globalThisVarDeclaration.errors.txt b/tests/baselines/reference/globalThisVarDeclaration.errors.txt index 70693098a43f9..daf2349c6b0a3 100644 --- a/tests/baselines/reference/globalThisVarDeclaration.errors.txt +++ b/tests/baselines/reference/globalThisVarDeclaration.errors.txt @@ -1,19 +1,25 @@ -tests/cases/conformance/es2019/actual.ts(6,6): error TS2339: Property 'a' does not exist on type 'Window'. -tests/cases/conformance/es2019/actual.ts(7,6): error TS2339: Property 'b' does not exist on type 'Window'. -tests/cases/conformance/es2019/actual.ts(8,8): error TS2339: Property 'a' does not exist on type 'Window'. -tests/cases/conformance/es2019/actual.ts(9,8): error TS2339: Property 'b' does not exist on type 'Window'. -tests/cases/conformance/es2019/b.js(6,6): error TS2339: Property 'a' does not exist on type 'Window'. -tests/cases/conformance/es2019/b.js(7,6): error TS2339: Property 'b' does not exist on type 'Window'. -tests/cases/conformance/es2019/b.js(8,8): error TS2339: Property 'a' does not exist on type 'Window'. -tests/cases/conformance/es2019/b.js(9,8): error TS2339: Property 'b' does not exist on type 'Window'. +tests/cases/conformance/es2019/actual.ts(8,6): error TS2339: Property 'a' does not exist on type 'Window'. +tests/cases/conformance/es2019/actual.ts(9,6): error TS2339: Property 'b' does not exist on type 'Window'. +tests/cases/conformance/es2019/actual.ts(10,8): error TS2339: Property 'a' does not exist on type 'Window'. +tests/cases/conformance/es2019/actual.ts(11,8): error TS2339: Property 'b' does not exist on type 'Window'. +tests/cases/conformance/es2019/actual.ts(12,5): error TS2339: Property 'a' does not exist on type 'Window'. +tests/cases/conformance/es2019/actual.ts(13,5): error TS2339: Property 'b' does not exist on type 'Window'. +tests/cases/conformance/es2019/b.js(8,6): error TS2339: Property 'a' does not exist on type 'Window'. +tests/cases/conformance/es2019/b.js(9,6): error TS2339: Property 'b' does not exist on type 'Window'. +tests/cases/conformance/es2019/b.js(10,8): error TS2339: Property 'a' does not exist on type 'Window'. +tests/cases/conformance/es2019/b.js(11,8): error TS2339: Property 'b' does not exist on type 'Window'. +tests/cases/conformance/es2019/b.js(12,5): error TS2339: Property 'a' does not exist on type 'Window'. +tests/cases/conformance/es2019/b.js(13,5): error TS2339: Property 'b' does not exist on type 'Window'. -==== tests/cases/conformance/es2019/b.js (4 errors) ==== +==== tests/cases/conformance/es2019/b.js (6 errors) ==== var a = 10; this.a; this.b; globalThis.a; globalThis.b; + + // DOM access is not supported until the index signature is handled more strictly self.a; ~ !!! error TS2339: Property 'a' does not exist on type 'Window'. @@ -26,13 +32,21 @@ tests/cases/conformance/es2019/b.js(9,8): error TS2339: Property 'b' does not ex window.b; ~ !!! error TS2339: Property 'b' does not exist on type 'Window'. + top.a; + ~ +!!! error TS2339: Property 'a' does not exist on type 'Window'. + top.b; + ~ +!!! error TS2339: Property 'b' does not exist on type 'Window'. -==== tests/cases/conformance/es2019/actual.ts (4 errors) ==== +==== tests/cases/conformance/es2019/actual.ts (6 errors) ==== var b = 10; this.a; this.b; globalThis.a; globalThis.b; + + // same here -- no DOM access to globalThis yet self.a; ~ !!! error TS2339: Property 'a' does not exist on type 'Window'. @@ -45,5 +59,11 @@ tests/cases/conformance/es2019/b.js(9,8): error TS2339: Property 'b' does not ex window.b; ~ !!! error TS2339: Property 'b' does not exist on type 'Window'. + top.a; + ~ +!!! error TS2339: Property 'a' does not exist on type 'Window'. + top.b; + ~ +!!! error TS2339: Property 'b' does not exist on type 'Window'. \ No newline at end of file diff --git a/tests/baselines/reference/globalThisVarDeclaration.js b/tests/baselines/reference/globalThisVarDeclaration.js index a192b671a41d9..2ae75af703ebc 100644 --- a/tests/baselines/reference/globalThisVarDeclaration.js +++ b/tests/baselines/reference/globalThisVarDeclaration.js @@ -6,10 +6,14 @@ this.a; this.b; globalThis.a; globalThis.b; + +// DOM access is not supported until the index signature is handled more strictly self.a; self.b; window.a; window.b; +top.a; +top.b; //// [actual.ts] var b = 10; @@ -17,10 +21,14 @@ this.a; this.b; globalThis.a; globalThis.b; + +// same here -- no DOM access to globalThis yet self.a; self.b; window.a; window.b; +top.a; +top.b; @@ -30,16 +38,22 @@ this.a; this.b; globalThis.a; globalThis.b; +// DOM access is not supported until the index signature is handled more strictly self.a; self.b; window.a; window.b; +top.a; +top.b; var b = 10; this.a; this.b; globalThis.a; globalThis.b; +// same here -- no DOM access to globalThis yet self.a; self.b; window.a; window.b; +top.a; +top.b; diff --git a/tests/baselines/reference/globalThisVarDeclaration.symbols b/tests/baselines/reference/globalThisVarDeclaration.symbols index e7b089e7c9a83..b2d7feb37fd75 100644 --- a/tests/baselines/reference/globalThisVarDeclaration.symbols +++ b/tests/baselines/reference/globalThisVarDeclaration.symbols @@ -4,24 +4,25 @@ var a = 10; this.a; >this.a : Symbol(a, Decl(b.js, 0, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >a : Symbol(a, Decl(b.js, 0, 3)) this.b; >this.b : Symbol(b, Decl(actual.ts, 0, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >b : Symbol(b, Decl(actual.ts, 0, 3)) globalThis.a; >globalThis.a : Symbol(a, Decl(b.js, 0, 3)) ->globalThis : Symbol(globalThis, Decl(lib.esnext.globalthis.d.ts, --, --)) +>globalThis : Symbol(globalThis) >a : Symbol(a, Decl(b.js, 0, 3)) globalThis.b; >globalThis.b : Symbol(b, Decl(actual.ts, 0, 3)) ->globalThis : Symbol(globalThis, Decl(lib.esnext.globalthis.d.ts, --, --)) +>globalThis : Symbol(globalThis) >b : Symbol(b, Decl(actual.ts, 0, 3)) +// DOM access is not supported until the index signature is handled more strictly self.a; >self : Symbol(self, Decl(lib.dom.d.ts, --, --)) @@ -34,30 +35,37 @@ window.a; window.b; >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) +top.a; +>top : Symbol(top, Decl(lib.dom.d.ts, --, --)) + +top.b; +>top : Symbol(top, Decl(lib.dom.d.ts, --, --)) + === tests/cases/conformance/es2019/actual.ts === var b = 10; >b : Symbol(b, Decl(actual.ts, 0, 3)) this.a; >this.a : Symbol(a, Decl(b.js, 0, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >a : Symbol(a, Decl(b.js, 0, 3)) this.b; >this.b : Symbol(b, Decl(actual.ts, 0, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >b : Symbol(b, Decl(actual.ts, 0, 3)) globalThis.a; >globalThis.a : Symbol(a, Decl(b.js, 0, 3)) ->globalThis : Symbol(globalThis, Decl(lib.esnext.globalthis.d.ts, --, --)) +>globalThis : Symbol(globalThis) >a : Symbol(a, Decl(b.js, 0, 3)) globalThis.b; >globalThis.b : Symbol(b, Decl(actual.ts, 0, 3)) ->globalThis : Symbol(globalThis, Decl(lib.esnext.globalthis.d.ts, --, --)) +>globalThis : Symbol(globalThis) >b : Symbol(b, Decl(actual.ts, 0, 3)) +// same here -- no DOM access to globalThis yet self.a; >self : Symbol(self, Decl(lib.dom.d.ts, --, --)) @@ -70,4 +78,10 @@ window.a; window.b; >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) +top.a; +>top : Symbol(top, Decl(lib.dom.d.ts, --, --)) + +top.b; +>top : Symbol(top, Decl(lib.dom.d.ts, --, --)) + diff --git a/tests/baselines/reference/globalThisVarDeclaration.types b/tests/baselines/reference/globalThisVarDeclaration.types index 0921e404ad592..9c520f667dcf2 100644 --- a/tests/baselines/reference/globalThisVarDeclaration.types +++ b/tests/baselines/reference/globalThisVarDeclaration.types @@ -23,6 +23,7 @@ globalThis.b; >globalThis : typeof globalThis >b : number +// DOM access is not supported until the index signature is handled more strictly self.a; >self.a : any >self : Window @@ -43,6 +44,16 @@ window.b; >window : Window >b : any +top.a; +>top.a : any +>top : Window +>a : any + +top.b; +>top.b : any +>top : Window +>b : any + === tests/cases/conformance/es2019/actual.ts === var b = 10; >b : number @@ -68,6 +79,7 @@ globalThis.b; >globalThis : typeof globalThis >b : number +// same here -- no DOM access to globalThis yet self.a; >self.a : any >self : Window @@ -88,4 +100,14 @@ window.b; >window : Window >b : any +top.a; +>top.a : any +>top : Window +>a : any + +top.b; +>top.b : any +>top : Window +>b : any + diff --git a/tests/baselines/reference/implicitAnyInCatch.symbols b/tests/baselines/reference/implicitAnyInCatch.symbols index b0353c7d5ea64..4f09ecdcbe5c8 100644 --- a/tests/baselines/reference/implicitAnyInCatch.symbols +++ b/tests/baselines/reference/implicitAnyInCatch.symbols @@ -8,7 +8,7 @@ try { } catch (error) { } for (var key in this) { } >key : Symbol(key, Decl(implicitAnyInCatch.ts, 4, 8)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) class C { >C : Symbol(C, Decl(implicitAnyInCatch.ts, 4, 25)) diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols index a111187bc51e0..c53ac6b194883 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols +++ b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols @@ -127,7 +127,7 @@ export const MySFC = (props: {x: number, y: number, children?: predom.JSX.Elemen >props.y : Symbol(y, Decl(component.tsx, 3, 40)) >props : Symbol(props, Decl(component.tsx, 3, 22)) >y : Symbol(y, Decl(component.tsx, 3, 40)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >p : Symbol(predom.JSX.IntrinsicElements, Decl(renderer2.d.ts, 1, 19)) export class MyClass implements predom.JSX.Element { diff --git a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols index c11267dc6d452..a12ac0b1c929e 100644 --- a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols +++ b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.symbols @@ -12,7 +12,7 @@ declare var React: any; } dataSource={this.state.ds} renderRow={}> >dataSource : Symbol(dataSource, Decl(jsxAttributeWithoutExpressionReact.tsx, 4, 5)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >renderRow : Symbol(renderRow, Decl(jsxAttributeWithoutExpressionReact.tsx, 4, 32)) diff --git a/tests/baselines/reference/jsxReactTestSuite.symbols b/tests/baselines/reference/jsxReactTestSuite.symbols index d6c03dcc18648..8d656a8ecb120 100644 --- a/tests/baselines/reference/jsxReactTestSuite.symbols +++ b/tests/baselines/reference/jsxReactTestSuite.symbols @@ -39,7 +39,7 @@ declare var hasOwnProperty:any;
{this.props.children} ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis)
; @@ -59,7 +59,7 @@ declare var hasOwnProperty:any; >Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 2, 11)) {this.props.children} ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) ; >Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 2, 11)) @@ -158,7 +158,7 @@ var x = >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 1, 11)) {...this.props} sound="moo" />; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >sound : Symbol(sound, Decl(jsxReactTestSuite.tsx, 93, 19)) ; diff --git a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols index 60f7820addf39..e906195f9b187 100644 --- a/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols +++ b/tests/baselines/reference/multiLinePropertyAccessAndArrowFunctionIndent1.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts === return this.edit(role) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) .then((role: Role) => >role : Symbol(role, Decl(multiLinePropertyAccessAndArrowFunctionIndent1.ts, 1, 11)) this.roleService.add(role) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >role : Symbol(role, Decl(multiLinePropertyAccessAndArrowFunctionIndent1.ts, 1, 11)) .then((data: ng.IHttpPromiseCallbackArg) => data.data)); diff --git a/tests/baselines/reference/noImplicitThisFunctions.symbols b/tests/baselines/reference/noImplicitThisFunctions.symbols index 447ab11a994ef..a86b117f910fc 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.symbols +++ b/tests/baselines/reference/noImplicitThisFunctions.symbols @@ -31,12 +31,12 @@ let f4: (b: number) => number = b => this.c + b; >f4 : Symbol(f4, Decl(noImplicitThisFunctions.ts, 16, 3)) >b : Symbol(b, Decl(noImplicitThisFunctions.ts, 16, 9)) >b : Symbol(b, Decl(noImplicitThisFunctions.ts, 16, 31)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >b : Symbol(b, Decl(noImplicitThisFunctions.ts, 16, 31)) let f5 = () => () => this; >f5 : Symbol(f5, Decl(noImplicitThisFunctions.ts, 17, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) let f6 = function() { return () => this; }; >f6 : Symbol(f6, Decl(noImplicitThisFunctions.ts, 19, 3)) diff --git a/tests/baselines/reference/parserCommaInTypeMemberList2.symbols b/tests/baselines/reference/parserCommaInTypeMemberList2.symbols index ccd3f23ff58cc..9bc7a392292ca 100644 --- a/tests/baselines/reference/parserCommaInTypeMemberList2.symbols +++ b/tests/baselines/reference/parserCommaInTypeMemberList2.symbols @@ -5,5 +5,5 @@ var s = $.extend< { workItem: any }, { workItem: any, width: string }>({ workIte >workItem : Symbol(workItem, Decl(parserCommaInTypeMemberList2.ts, 0, 38)) >width : Symbol(width, Decl(parserCommaInTypeMemberList2.ts, 0, 53)) >workItem : Symbol(workItem, Decl(parserCommaInTypeMemberList2.ts, 0, 72)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) diff --git a/tests/baselines/reference/parserConditionalExpression1.symbols b/tests/baselines/reference/parserConditionalExpression1.symbols index 7847ae5e8c653..91453101af13a 100644 --- a/tests/baselines/reference/parserConditionalExpression1.symbols +++ b/tests/baselines/reference/parserConditionalExpression1.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/Expressions/parserConditionalExpression1.ts === (a=this.R[c])?a.JW||(a.e5(this,c),a.JW=_.l):this.A ->this : Symbol(typeof globalThis) ->this : Symbol(typeof globalThis) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) +>this : Symbol(globalThis) +>this : Symbol(globalThis) diff --git a/tests/baselines/reference/parserForStatement8.symbols b/tests/baselines/reference/parserForStatement8.symbols index 977d399f63962..2133f54f57ca8 100644 --- a/tests/baselines/reference/parserForStatement8.symbols +++ b/tests/baselines/reference/parserForStatement8.symbols @@ -1,4 +1,4 @@ === tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement8.ts === for (this in b) { ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) } diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols b/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols index bf1c42fb899e6..daf115443ae17 100644 --- a/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols +++ b/tests/baselines/reference/parserModifierOnStatementInBlock2.symbols @@ -2,6 +2,6 @@ { declare var x = this; >x : Symbol(x, Decl(parserModifierOnStatementInBlock2.ts, 1, 14)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) } diff --git a/tests/baselines/reference/parserStrictMode16.symbols b/tests/baselines/reference/parserStrictMode16.symbols index 892a0b069d1f6..bef54a8af998b 100644 --- a/tests/baselines/reference/parserStrictMode16.symbols +++ b/tests/baselines/reference/parserStrictMode16.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts === "use strict"; delete this; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) delete 1; delete null; diff --git a/tests/baselines/reference/parserUnaryExpression1.symbols b/tests/baselines/reference/parserUnaryExpression1.symbols index e617530f2e38a..053c922f947ec 100644 --- a/tests/baselines/reference/parserUnaryExpression1.symbols +++ b/tests/baselines/reference/parserUnaryExpression1.symbols @@ -1,4 +1,4 @@ === tests/cases/conformance/parser/ecmascript5/Expressions/parserUnaryExpression1.ts === ++this; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) diff --git a/tests/baselines/reference/propertyWrappedInTry.symbols b/tests/baselines/reference/propertyWrappedInTry.symbols index 3bb84efe8cfc6..4d570fee1bbcf 100644 --- a/tests/baselines/reference/propertyWrappedInTry.symbols +++ b/tests/baselines/reference/propertyWrappedInTry.symbols @@ -14,7 +14,7 @@ class Foo { public baz() { return this.bar; // doesn't get rewritten to Foo.bar. ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) } diff --git a/tests/baselines/reference/thisInInvalidContexts.symbols b/tests/baselines/reference/thisInInvalidContexts.symbols index a73229c751bd0..7fecdf73f4397 100644 --- a/tests/baselines/reference/thisInInvalidContexts.symbols +++ b/tests/baselines/reference/thisInInvalidContexts.symbols @@ -69,7 +69,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContexts.ts, 35, 29)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols b/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols index 235aa34ce875b..ad52fbdabeb70 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols @@ -69,7 +69,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContextsExternalModule.ts, 35, 29)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) } diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index 796eda3668d95..c1dcdb9829dc3 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -126,7 +126,7 @@ let impl: I = { explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) >explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 38, 10)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) explicitVoid1() { return 12; }, >explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 39, 32)) @@ -366,7 +366,7 @@ let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + th >x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 45)) >x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 68)) >x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 68)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; >specifiedToSpecified : Symbol(specifiedToSpecified, Decl(thisTypeInFunctions.ts, 93, 3)) @@ -498,7 +498,7 @@ c.explicitC = m => m + this.n; >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) >this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) c.explicitThis = m => m + this.n; @@ -508,7 +508,7 @@ c.explicitThis = m => m + this.n; >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) >this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) c.explicitProperty = m => m + this.n; @@ -518,7 +518,7 @@ c.explicitProperty = m => m + this.n; >m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) >this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) //NOTE: this=C here, I guess? diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.symbols b/tests/baselines/reference/thisTypeInFunctionsNegative.symbols index f44d8bb83e741..14566bbf946c9 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.symbols +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.symbols @@ -134,7 +134,7 @@ let impl: I = { }, explicitVoid2: () => this.a, // ok, `this:any` because it refers to an outer object >explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctionsNegative.ts, 39, 6)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) explicitStructural: () => 12, >explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctionsNegative.ts, 40, 32)) @@ -656,7 +656,7 @@ function initializer(this: C = new C()): number { return this.n; } >C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 171, 30)) >C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 171, 34)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; @@ -666,7 +666,7 @@ c.explicitProperty = (this, m) => m + this.n; >this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 174, 22)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 174, 27)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 174, 27)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) const f2 = (this: {n: number}, m: number) => m + this.n; >f2 : Symbol(f2, Decl(thisTypeInFunctionsNegative.ts, 175, 5)) @@ -675,7 +675,7 @@ const f2 = (this: {n: number}, m: number) => m + this.n; >n : Symbol(n, Decl(thisTypeInFunctionsNegative.ts, 175, 22)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 175, 33)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 175, 33)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) const f3 = async (this: {n: number}, m: number) => m + this.n; >f3 : Symbol(f3, Decl(thisTypeInFunctionsNegative.ts, 176, 5)) @@ -683,7 +683,7 @@ const f3 = async (this: {n: number}, m: number) => m + this.n; >n : Symbol(n, Decl(thisTypeInFunctionsNegative.ts, 176, 25)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 176, 36)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 176, 36)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) const f4 = async (this: {n: number}, m: number) => m + this.n; >f4 : Symbol(f4, Decl(thisTypeInFunctionsNegative.ts, 177, 5)) @@ -692,5 +692,5 @@ const f4 = async (this: {n: number}, m: number) => m + this.n; >n : Symbol(n, Decl(thisTypeInFunctionsNegative.ts, 177, 28)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 177, 39)) >m : Symbol(m, Decl(thisTypeInFunctionsNegative.ts, 177, 39)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) diff --git a/tests/baselines/reference/topLevelLambda2.symbols b/tests/baselines/reference/topLevelLambda2.symbols index 501ffcba88e61..412a7c8a547bf 100644 --- a/tests/baselines/reference/topLevelLambda2.symbols +++ b/tests/baselines/reference/topLevelLambda2.symbols @@ -6,6 +6,6 @@ function foo(x:any) {} foo(()=>this.window); >foo : Symbol(foo, Decl(topLevelLambda2.ts, 0, 0)) >this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) diff --git a/tests/baselines/reference/topLevelLambda3.symbols b/tests/baselines/reference/topLevelLambda3.symbols index 0250c07b94355..7dd41958b7f06 100644 --- a/tests/baselines/reference/topLevelLambda3.symbols +++ b/tests/baselines/reference/topLevelLambda3.symbols @@ -2,6 +2,6 @@ var f = () => {this.window;} >f : Symbol(f, Decl(topLevelLambda3.ts, 0, 3)) >this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) diff --git a/tests/baselines/reference/topLevelLambda4.symbols b/tests/baselines/reference/topLevelLambda4.symbols index 096958b869c40..202d1bf90d551 100644 --- a/tests/baselines/reference/topLevelLambda4.symbols +++ b/tests/baselines/reference/topLevelLambda4.symbols @@ -2,6 +2,6 @@ export var x = () => this.window; >x : Symbol(x, Decl(topLevelLambda4.ts, 0, 10)) >this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) diff --git a/tests/baselines/reference/topLevelThisAssignment.symbols b/tests/baselines/reference/topLevelThisAssignment.symbols index d0747b4a3be4f..4ac7e79984861 100644 --- a/tests/baselines/reference/topLevelThisAssignment.symbols +++ b/tests/baselines/reference/topLevelThisAssignment.symbols @@ -1,12 +1,12 @@ === tests/cases/conformance/salsa/a.js === this.a = 10; >this.a : Symbol(a, Decl(a.js, 0, 0)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >a : Symbol(a, Decl(a.js, 0, 0)) this.a; >this.a : Symbol(a, Decl(a.js, 0, 0)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >a : Symbol(a, Decl(a.js, 0, 0)) a; @@ -15,7 +15,7 @@ a; === tests/cases/conformance/salsa/b.js === this.a; >this.a : Symbol(a, Decl(a.js, 0, 0)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >a : Symbol(a, Decl(a.js, 0, 0)) a; diff --git a/tests/baselines/reference/tsxAttributeResolution15.errors.txt b/tests/baselines/reference/tsxAttributeResolution15.errors.txt index f4c9c14deb5a9..ca86178b57863 100644 --- a/tests/baselines/reference/tsxAttributeResolution15.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution15.errors.txt @@ -1,8 +1,9 @@ tests/cases/conformance/jsx/file.tsx(11,10): error TS2322: Type '{ prop1: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & { children?: ReactNode; }'. Property 'prop1' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & { children?: ReactNode; }'. +tests/cases/conformance/jsx/file.tsx(14,44): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. -==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== +==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== import React = require('react'); class BigGreeter extends React.Component<{ }, {}> { @@ -20,4 +21,6 @@ tests/cases/conformance/jsx/file.tsx(11,10): error TS2322: Type '{ prop1: string // OK let b = { this.textInput = input; }} /> + ~~~~~~~~~ +!!! error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. let c = \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution15.symbols b/tests/baselines/reference/tsxAttributeResolution15.symbols index c4dac3f82be13..c366c93cef1cc 100644 --- a/tests/baselines/reference/tsxAttributeResolution15.symbols +++ b/tests/baselines/reference/tsxAttributeResolution15.symbols @@ -31,7 +31,7 @@ let b = { this.textInput = input; }} /> >BigGreeter : Symbol(BigGreeter, Decl(file.tsx, 0, 32)) >ref : Symbol(ref, Decl(file.tsx, 13, 19)) >input : Symbol(input, Decl(file.tsx, 13, 26)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >input : Symbol(input, Decl(file.tsx, 13, 26)) let c = diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols index 898581d35f69f..cb357c8a20da9 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols @@ -79,7 +79,7 @@ let e3 = { this.textInput = input; } }} /> >EmptyProp : Symbol(EmptyProp, Decl(file.tsx, 19, 30)) >ref : Symbol(ref, Decl(file.tsx, 31, 25)) >input : Symbol(input, Decl(file.tsx, 31, 32)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >input : Symbol(input, Decl(file.tsx, 31, 32)) let e4 = diff --git a/tests/baselines/reference/typeFromPropertyAssignment23.symbols b/tests/baselines/reference/typeFromPropertyAssignment23.symbols index c3267bcf8363e..f28bf54ac7a02 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment23.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment23.symbols @@ -38,7 +38,7 @@ D.prototype.foo = () => { >foo : Symbol(D.foo, Decl(a.js, 14, 21)) this.n = 'not checked, so no error' ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >n : Symbol(n, Decl(a.js, 15, 26)) } diff --git a/tests/baselines/reference/typeFromPropertyAssignment9.symbols b/tests/baselines/reference/typeFromPropertyAssignment9.symbols index 8f5ff83ce2191..2ebec8f5204ee 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment9.symbols +++ b/tests/baselines/reference/typeFromPropertyAssignment9.symbols @@ -120,7 +120,7 @@ min.nest = this.min.nest || function () { }; >nest : Symbol(min.nest, Decl(a.js, 29, 27), Decl(a.js, 31, 4)) >this.min.nest : Symbol(min.nest, Decl(a.js, 29, 27), Decl(a.js, 31, 4)) >this.min : Symbol(min, Decl(a.js, 29, 3), Decl(a.js, 29, 27), Decl(a.js, 30, 44)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) >min : Symbol(min, Decl(a.js, 29, 3), Decl(a.js, 29, 27), Decl(a.js, 30, 44)) >nest : Symbol(min.nest, Decl(a.js, 29, 27), Decl(a.js, 31, 4)) diff --git a/tests/baselines/reference/typeOfThis.symbols b/tests/baselines/reference/typeOfThis.symbols index e7803be78f6a6..11c2ae273c4a1 100644 --- a/tests/baselines/reference/typeOfThis.symbols +++ b/tests/baselines/reference/typeOfThis.symbols @@ -423,10 +423,11 @@ var q1 = function (s = this) { var q2 = (s = this) => { >q2 : Symbol(q2, Decl(typeOfThis.ts, 161, 3)) >s : Symbol(s, Decl(typeOfThis.ts, 161, 10), Decl(typeOfThis.ts, 162, 7)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) var s: typeof globalThis; >s : Symbol(s, Decl(typeOfThis.ts, 161, 10), Decl(typeOfThis.ts, 162, 7)) +>globalThis : Symbol(globalThis) s.spaaaaaaace = 4; >s : Symbol(s, Decl(typeOfThis.ts, 161, 10), Decl(typeOfThis.ts, 162, 7)) @@ -434,24 +435,26 @@ var q2 = (s = this) => { //type of 'this' in a fat arrow expression body is typeof globalThis var t: typeof globalThis; >t : Symbol(t, Decl(typeOfThis.ts, 166, 7), Decl(typeOfThis.ts, 167, 7)) +>globalThis : Symbol(globalThis) var t = this; >t : Symbol(t, Decl(typeOfThis.ts, 166, 7), Decl(typeOfThis.ts, 167, 7)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) this.spaaaaace = 4; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) } //type of 'this' in global module is GlobalThis var t: typeof globalThis; >t : Symbol(t, Decl(typeOfThis.ts, 172, 3), Decl(typeOfThis.ts, 173, 3)) +>globalThis : Symbol(globalThis) var t = this; >t : Symbol(t, Decl(typeOfThis.ts, 172, 3), Decl(typeOfThis.ts, 173, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) this.spaaaaace = 4; ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) diff --git a/tests/baselines/reference/typeOfThis.types b/tests/baselines/reference/typeOfThis.types index 797d7b2e2263d..9f10153eb97bf 100644 --- a/tests/baselines/reference/typeOfThis.types +++ b/tests/baselines/reference/typeOfThis.types @@ -439,6 +439,7 @@ var q2 = (s = this) => { var s: typeof globalThis; >s : typeof globalThis +>globalThis : typeof globalThis s.spaaaaaaace = 4; >s.spaaaaaaace = 4 : 4 @@ -450,6 +451,7 @@ var q2 = (s = this) => { //type of 'this' in a fat arrow expression body is typeof globalThis var t: typeof globalThis; >t : typeof globalThis +>globalThis : typeof globalThis var t = this; >t : typeof globalThis @@ -466,6 +468,7 @@ var q2 = (s = this) => { //type of 'this' in global module is GlobalThis var t: typeof globalThis; >t : typeof globalThis +>globalThis : typeof globalThis var t = this; >t : typeof globalThis diff --git a/tests/baselines/reference/unknownSymbols1.symbols b/tests/baselines/reference/unknownSymbols1.symbols index 23f838f405e6a..c6f67db4a1ddd 100644 --- a/tests/baselines/reference/unknownSymbols1.symbols +++ b/tests/baselines/reference/unknownSymbols1.symbols @@ -54,7 +54,7 @@ class C4 extends C3 { var x2 = this.asdf; // no error, this is any >x2 : Symbol(x2, Decl(unknownSymbols1.ts, 25, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) class C5 { >C5 : Symbol(C5, Decl(unknownSymbols1.ts, 25, 19)) diff --git a/tests/baselines/reference/wrappedIncovations1.symbols b/tests/baselines/reference/wrappedIncovations1.symbols index 00618918c102d..0949334104019 100644 --- a/tests/baselines/reference/wrappedIncovations1.symbols +++ b/tests/baselines/reference/wrappedIncovations1.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/wrappedIncovations1.ts === var v = this >v : Symbol(v, Decl(wrappedIncovations1.ts, 0, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) .foo() .bar() diff --git a/tests/baselines/reference/wrappedIncovations2.symbols b/tests/baselines/reference/wrappedIncovations2.symbols index 14c2c9e52802a..6e5dcf7aae22e 100644 --- a/tests/baselines/reference/wrappedIncovations2.symbols +++ b/tests/baselines/reference/wrappedIncovations2.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/wrappedIncovations2.ts === var v = this. >v : Symbol(v, Decl(wrappedIncovations2.ts, 0, 3)) ->this : Symbol(typeof globalThis) +>this : Symbol(globalThis) foo(). bar(). diff --git a/tests/cases/fourslash/findAllRefsThisKeyword.ts b/tests/cases/fourslash/findAllRefsThisKeyword.ts index 34995467a2783..6140654c8427b 100644 --- a/tests/cases/fourslash/findAllRefsThisKeyword.ts +++ b/tests/cases/fourslash/findAllRefsThisKeyword.ts @@ -25,7 +25,7 @@ ////x.[|this|]; const [global, f0, f1, g0, g1, x, y, constructor, method, propDef, propUse] = test.ranges(); -verify.singleReferenceGroup("this", [global]); +verify.singleReferenceGroup("module globalThis\nthis: typeof globalThis", [global]); verify.singleReferenceGroup("(parameter) this: any", [f0, f1]); verify.singleReferenceGroup("(parameter) this: any", [g0, g1]); verify.singleReferenceGroup("this: typeof C", [x, y]); diff --git a/tests/cases/fourslash/findAllRefsThisKeywordMultipleFiles.ts b/tests/cases/fourslash/findAllRefsThisKeywordMultipleFiles.ts index d94f2993d1df8..1ec1680dfb724 100644 --- a/tests/cases/fourslash/findAllRefsThisKeywordMultipleFiles.ts +++ b/tests/cases/fourslash/findAllRefsThisKeywordMultipleFiles.ts @@ -12,4 +12,4 @@ //// // different 'this' //// function f(this) { return this; } -verify.singleReferenceGroup("this"); +verify.singleReferenceGroup("module globalThis\nthis: typeof globalThis"); From d48cc4c628c23467b7c342c7d11b3d8cc2b86339 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 9 Jan 2019 11:25:30 -0800 Subject: [PATCH 10/19] Do not suggest globals for completions at toplevel --- src/services/completions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index bbcee4dd47e91..c5d1e63b8529b 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1029,7 +1029,7 @@ namespace ts.Completions { // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== SyntaxKind.SourceFile) { const thisType = typeChecker.tryGetThisTypeAt(scopeNode); - if (thisType) { + if (thisType && thisType.symbol.name !== "globalThis") { for (const symbol of getPropertiesForCompletion(thisType, typeChecker)) { symbolToOriginInfoMap[getSymbolId(symbol)] = { kind: SymbolOriginInfoKind.ThisType }; symbols.push(symbol); From 719cc35312bc0d7736d21cc146613804afa33fdb Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 9 Jan 2019 12:41:40 -0800 Subject: [PATCH 11/19] Add tests of element and property access --- .../reference/globalThisUnknown.errors.txt | 20 ++++++++++ .../baselines/reference/globalThisUnknown.js | 26 +++++++++++++ .../reference/globalThisUnknown.symbols | 28 +++++++++++++ .../reference/globalThisUnknown.types | 39 +++++++++++++++++++ .../globalThisUnknownNoImplicitAny.errors.txt | 32 +++++++++++++++ .../globalThisUnknownNoImplicitAny.js | 21 ++++++++++ .../globalThisUnknownNoImplicitAny.symbols | 25 ++++++++++++ .../globalThisUnknownNoImplicitAny.types | 36 +++++++++++++++++ .../conformance/es2019/globalThisUnknown.ts | 13 +++++++ .../es2019/globalThisUnknownNoImplicitAny.ts | 11 ++++++ 10 files changed, 251 insertions(+) create mode 100644 tests/baselines/reference/globalThisUnknown.errors.txt create mode 100644 tests/baselines/reference/globalThisUnknown.js create mode 100644 tests/baselines/reference/globalThisUnknown.symbols create mode 100644 tests/baselines/reference/globalThisUnknown.types create mode 100644 tests/baselines/reference/globalThisUnknownNoImplicitAny.errors.txt create mode 100644 tests/baselines/reference/globalThisUnknownNoImplicitAny.js create mode 100644 tests/baselines/reference/globalThisUnknownNoImplicitAny.symbols create mode 100644 tests/baselines/reference/globalThisUnknownNoImplicitAny.types create mode 100644 tests/cases/conformance/es2019/globalThisUnknown.ts create mode 100644 tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts diff --git a/tests/baselines/reference/globalThisUnknown.errors.txt b/tests/baselines/reference/globalThisUnknown.errors.txt new file mode 100644 index 0000000000000..fc9a8485b6479 --- /dev/null +++ b/tests/baselines/reference/globalThisUnknown.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/es2019/globalThisUnknown.ts(4,5): error TS2339: Property 'hi' does not exist on type 'Window & typeof globalThis'. + + +==== tests/cases/conformance/es2019/globalThisUnknown.ts (1 errors) ==== + declare let win: Window & typeof globalThis; + + // this access should be an error + win.hi + ~~ +!!! error TS2339: Property 'hi' does not exist on type 'Window & typeof globalThis'. + // these two should be fine, with type any + this.hi + globalThis.hi + + // element access is always ok without noImplicitAny + win['hi'] + this['hi'] + globalThis['hi'] + + \ No newline at end of file diff --git a/tests/baselines/reference/globalThisUnknown.js b/tests/baselines/reference/globalThisUnknown.js new file mode 100644 index 0000000000000..9763100c1291b --- /dev/null +++ b/tests/baselines/reference/globalThisUnknown.js @@ -0,0 +1,26 @@ +//// [globalThisUnknown.ts] +declare let win: Window & typeof globalThis; + +// this access should be an error +win.hi +// these two should be fine, with type any +this.hi +globalThis.hi + +// element access is always ok without noImplicitAny +win['hi'] +this['hi'] +globalThis['hi'] + + + +//// [globalThisUnknown.js] +// this access should be an error +win.hi; +// these two should be fine, with type any +this.hi; +globalThis.hi; +// element access is always ok without noImplicitAny +win['hi']; +this['hi']; +globalThis['hi']; diff --git a/tests/baselines/reference/globalThisUnknown.symbols b/tests/baselines/reference/globalThisUnknown.symbols new file mode 100644 index 0000000000000..4f8437bf244fd --- /dev/null +++ b/tests/baselines/reference/globalThisUnknown.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/es2019/globalThisUnknown.ts === +declare let win: Window & typeof globalThis; +>win : Symbol(win, Decl(globalThisUnknown.ts, 0, 11)) +>Window : Symbol(Window, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>globalThis : Symbol(globalThis) + +// this access should be an error +win.hi +>win : Symbol(win, Decl(globalThisUnknown.ts, 0, 11)) + +// these two should be fine, with type any +this.hi +>this : Symbol(globalThis) + +globalThis.hi +>globalThis : Symbol(globalThis) + +// element access is always ok without noImplicitAny +win['hi'] +>win : Symbol(win, Decl(globalThisUnknown.ts, 0, 11)) + +this['hi'] +>this : Symbol(globalThis) + +globalThis['hi'] +>globalThis : Symbol(globalThis) + + diff --git a/tests/baselines/reference/globalThisUnknown.types b/tests/baselines/reference/globalThisUnknown.types new file mode 100644 index 0000000000000..42ac606ec549b --- /dev/null +++ b/tests/baselines/reference/globalThisUnknown.types @@ -0,0 +1,39 @@ +=== tests/cases/conformance/es2019/globalThisUnknown.ts === +declare let win: Window & typeof globalThis; +>win : Window & typeof globalThis +>globalThis : typeof globalThis + +// this access should be an error +win.hi +>win.hi : any +>win : Window & typeof globalThis +>hi : any + +// these two should be fine, with type any +this.hi +>this.hi : any +>this : typeof globalThis +>hi : any + +globalThis.hi +>globalThis.hi : any +>globalThis : typeof globalThis +>hi : any + +// element access is always ok without noImplicitAny +win['hi'] +>win['hi'] : any +>win : Window & typeof globalThis +>'hi' : "hi" + +this['hi'] +>this['hi'] : any +>this : typeof globalThis +>'hi' : "hi" + +globalThis['hi'] +>globalThis['hi'] : any +>globalThis : typeof globalThis +>'hi' : "hi" + + diff --git a/tests/baselines/reference/globalThisUnknownNoImplicitAny.errors.txt b/tests/baselines/reference/globalThisUnknownNoImplicitAny.errors.txt new file mode 100644 index 0000000000000..fc5e91de594be --- /dev/null +++ b/tests/baselines/reference/globalThisUnknownNoImplicitAny.errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts(4,5): error TS2339: Property 'hi' does not exist on type 'Window & typeof globalThis'. +tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts(5,6): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. +tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts(6,12): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. +tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts(8,1): error TS7017: Element implicitly has an 'any' type because type 'Window & typeof globalThis' has no index signature. +tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts(9,1): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. +tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts(10,1): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. + + +==== tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts (6 errors) ==== + declare let win: Window & typeof globalThis; + + // all accesses should be errors + win.hi + ~~ +!!! error TS2339: Property 'hi' does not exist on type 'Window & typeof globalThis'. + this.hi + ~~ +!!! error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. + globalThis.hi + ~~ +!!! error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. + + win['hi'] + ~~~~~~~~~ +!!! error TS7017: Element implicitly has an 'any' type because type 'Window & typeof globalThis' has no index signature. + this['hi'] + ~~~~~~~~~~ +!!! error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. + globalThis['hi'] + ~~~~~~~~~~~~~~~~ +!!! error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. + \ No newline at end of file diff --git a/tests/baselines/reference/globalThisUnknownNoImplicitAny.js b/tests/baselines/reference/globalThisUnknownNoImplicitAny.js new file mode 100644 index 0000000000000..cc1952e0afc19 --- /dev/null +++ b/tests/baselines/reference/globalThisUnknownNoImplicitAny.js @@ -0,0 +1,21 @@ +//// [globalThisUnknownNoImplicitAny.ts] +declare let win: Window & typeof globalThis; + +// all accesses should be errors +win.hi +this.hi +globalThis.hi + +win['hi'] +this['hi'] +globalThis['hi'] + + +//// [globalThisUnknownNoImplicitAny.js] +// all accesses should be errors +win.hi; +this.hi; +globalThis.hi; +win['hi']; +this['hi']; +globalThis['hi']; diff --git a/tests/baselines/reference/globalThisUnknownNoImplicitAny.symbols b/tests/baselines/reference/globalThisUnknownNoImplicitAny.symbols new file mode 100644 index 0000000000000..6aee6d6051c61 --- /dev/null +++ b/tests/baselines/reference/globalThisUnknownNoImplicitAny.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts === +declare let win: Window & typeof globalThis; +>win : Symbol(win, Decl(globalThisUnknownNoImplicitAny.ts, 0, 11)) +>Window : Symbol(Window, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>globalThis : Symbol(globalThis) + +// all accesses should be errors +win.hi +>win : Symbol(win, Decl(globalThisUnknownNoImplicitAny.ts, 0, 11)) + +this.hi +>this : Symbol(globalThis) + +globalThis.hi +>globalThis : Symbol(globalThis) + +win['hi'] +>win : Symbol(win, Decl(globalThisUnknownNoImplicitAny.ts, 0, 11)) + +this['hi'] +>this : Symbol(globalThis) + +globalThis['hi'] +>globalThis : Symbol(globalThis) + diff --git a/tests/baselines/reference/globalThisUnknownNoImplicitAny.types b/tests/baselines/reference/globalThisUnknownNoImplicitAny.types new file mode 100644 index 0000000000000..19611a785b462 --- /dev/null +++ b/tests/baselines/reference/globalThisUnknownNoImplicitAny.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts === +declare let win: Window & typeof globalThis; +>win : Window & typeof globalThis +>globalThis : typeof globalThis + +// all accesses should be errors +win.hi +>win.hi : any +>win : Window & typeof globalThis +>hi : any + +this.hi +>this.hi : any +>this : typeof globalThis +>hi : any + +globalThis.hi +>globalThis.hi : any +>globalThis : typeof globalThis +>hi : any + +win['hi'] +>win['hi'] : any +>win : Window & typeof globalThis +>'hi' : "hi" + +this['hi'] +>this['hi'] : any +>this : typeof globalThis +>'hi' : "hi" + +globalThis['hi'] +>globalThis['hi'] : any +>globalThis : typeof globalThis +>'hi' : "hi" + diff --git a/tests/cases/conformance/es2019/globalThisUnknown.ts b/tests/cases/conformance/es2019/globalThisUnknown.ts new file mode 100644 index 0000000000000..b1ae4224e1e29 --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisUnknown.ts @@ -0,0 +1,13 @@ +declare let win: Window & typeof globalThis; + +// this access should be an error +win.hi +// these two should be fine, with type any +this.hi +globalThis.hi + +// element access is always ok without noImplicitAny +win['hi'] +this['hi'] +globalThis['hi'] + diff --git a/tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts b/tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts new file mode 100644 index 0000000000000..53fb9a98edba0 --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisUnknownNoImplicitAny.ts @@ -0,0 +1,11 @@ +// @noImplicitAny: true +declare let win: Window & typeof globalThis; + +// all accesses should be errors +win.hi +this.hi +globalThis.hi + +win['hi'] +this['hi'] +globalThis['hi'] From 6b18334e7a11672b2d4f6391f184ea312ddd0acd Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 15 Jan 2019 17:46:09 -0800 Subject: [PATCH 12/19] Look up globalThis using normal resolution globalThis is no longer constructed lazily. Its synthetic Identifier node is also now more realistic. --- src/compiler/checker.ts | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9d86784ef57ad..49ce86ecfd9b2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -87,8 +87,14 @@ namespace ts { const emitResolver = createResolver(); const nodeBuilder = createNodeBuilder(); + const globals = createSymbolTable(); const undefinedSymbol = createSymbol(SymbolFlags.Property, "undefined" as __String); undefinedSymbol.declarations = []; + + const globalThisSymbol = createSymbol(SymbolFlags.ValueModule | SymbolFlags.NamespaceModule, "globalThis" as __String); + globalThisSymbol.exports = globals; + globalThisSymbol.valueDeclaration = createNode(SyntaxKind.Identifier) as Identifier; + (globalThisSymbol.valueDeclaration as Identifier).escapedText = "globalThis" as __String; const argumentsSymbol = createSymbol(SymbolFlags.Property, "arguments" as __String); const requireSymbol = createSymbol(SymbolFlags.Property, "require" as __String); @@ -458,7 +464,6 @@ namespace ts { const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); - const globals = createSymbolTable(); interface DuplicateInfoForSymbol { readonly firstFileLocations: Node[]; readonly secondFileLocations: Node[]; @@ -519,7 +524,6 @@ namespace ts { let deferredGlobalExcludeSymbol: Symbol; let deferredGlobalPickSymbol: Symbol; let deferredGlobalBigIntType: ObjectType; - let deferredGlobalThisSymbol: Symbol | undefined; const allPotentiallyUnusedIdentifiers = createMap(); // key is file name @@ -722,6 +726,7 @@ namespace ts { const builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); + builtinGlobals.set(globalThisSymbol.escapedName, globalThisSymbol); const isNotOverloadAndNotAccessor = and(isNotOverload, isNotAccessor); @@ -1502,9 +1507,6 @@ namespace ts { } if (!excludeGlobals) { - if (name === "globalThis" as __String) { - return getGlobalThisSymbol(); - } result = lookup(globals, name, meaning); } } @@ -8980,16 +8982,6 @@ namespace ts { return symbol && getTypeOfGlobalSymbol(symbol, arity); } - function getGlobalThisSymbol() { - if (!deferredGlobalThisSymbol) { - const s = createSymbol(SymbolFlags.ValueModule | SymbolFlags.NamespaceModule, "globalThis" as __String); - s.exports = globals; - s.valueDeclaration = createNode(SyntaxKind.Identifier) as Identifier; - deferredGlobalThisSymbol = s; - } - return deferredGlobalThisSymbol; - } - function getGlobalExtractSymbol(): Symbol { return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract" as __String, SymbolFlags.TypeAlias, Diagnostics.Cannot_find_global_type_0)!); // TODO: GH#18217 } @@ -9632,7 +9624,7 @@ namespace ts { } function getLiteralTypeFromProperties(type: Type, include: TypeFlags) { - return getUnionType(map(getPropertiesOfType(type), t => getLiteralTypeFromProperty(t, include))); + return getUnionType(map(getPropertiesOfType(type), p => getLiteralTypeFromProperty(p, include))); } function getNonEnumNumberIndexInfo(type: Type) { @@ -16709,7 +16701,7 @@ namespace ts { } const type = tryGetThisTypeAt(node, container); - const globalThisType = getTypeOfSymbol(getGlobalThisSymbol()); + const globalThisType = getTypeOfSymbol(globalThisSymbol); if (noImplicitThis) { if (type === globalThisType && capturedByArrowFunction) { error(node, Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this); @@ -16782,7 +16774,7 @@ namespace ts { return fileSymbol && getTypeOfSymbol(fileSymbol); } else { - return getTypeOfSymbol(getGlobalThisSymbol()); + return getTypeOfSymbol(globalThisSymbol); } } } @@ -19043,7 +19035,7 @@ namespace ts { if (isJSLiteralType(leftType)) { return anyType; } - if (leftType.symbol === getGlobalThisSymbol()) { + if (leftType.symbol === globalThisSymbol) { if (noImplicitAny) { error(right, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType)); } From 7a3d7145efe1fcdcf59d81caa5b538bf6090071b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 15 Jan 2019 20:21:29 -0800 Subject: [PATCH 13/19] Update fourslash tests --- src/harness/fourslash.ts | 10 +++++++++- .../cases/fourslash/completionEntryForClassMembers.ts | 1 + .../fourslash/completionListIsGlobalCompletion.ts | 2 +- tests/cases/fourslash/completionListKeywords.ts | 2 +- tests/cases/fourslash/completionListWithMeanings.ts | 2 ++ .../fourslash/completionListWithModulesFromModule.ts | 4 ++++ .../fourslash/completionsImport_default_anonymous.ts | 2 +- tests/cases/fourslash/completionsImport_keywords.ts | 2 +- .../completionsImport_multipleWithSameName.ts | 1 + .../completionsImport_named_didNotExistBefore.ts | 1 + .../completionsImport_ofAlias_preferShortPath.ts | 1 + .../fourslash/completionsImport_reExportDefault.ts | 1 + .../fourslash/completionsImport_shadowedByLocal.ts | 2 +- tests/cases/fourslash/completionsTypeKeywords.ts | 2 +- .../fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts | 2 +- 15 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index db1c326a50440..1a64652a7bdae 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -4545,6 +4545,7 @@ namespace FourSlashInterface { return [ ...globalTypeDecls, ...plus, + { name: "globalThis", kind: "module" }, ...typeKeywords, ]; } @@ -4786,6 +4787,7 @@ namespace FourSlashInterface { ...plus, ...globalsVars, { name: "undefined", kind: "var" }, + { name: "globalThis", kind: "module" }, ...globalKeywordsInsideFunction, ]; @@ -4921,11 +4923,17 @@ namespace FourSlashInterface { export const globals: ReadonlyArray = [ ...globalsVars, { name: "undefined", kind: "var" }, + { name: "globalThis", kind: "module" }, ...globalKeywords ]; export function globalsPlus(plus: ReadonlyArray): ReadonlyArray { - return [...globalsVars, ...plus, { name: "undefined", kind: "var" }, ...globalKeywords]; + return [ + ...globalsVars, + ...plus, + { name: "undefined", kind: "var" }, + { name: "globalThis", kind: "module" }, + ...globalKeywords]; } } diff --git a/tests/cases/fourslash/completionEntryForClassMembers.ts b/tests/cases/fourslash/completionEntryForClassMembers.ts index 9da74be0bb1bd..da40a28bad6d0 100644 --- a/tests/cases/fourslash/completionEntryForClassMembers.ts +++ b/tests/cases/fourslash/completionEntryForClassMembers.ts @@ -132,6 +132,7 @@ verify.completions( "arguments", "B", "C", "D", "D1", "D2", "D3", "D4", "D5", "D6", "E", "F", "F2", "G", "G2", "H", "I", "J", "K", "L", "L2", "M", "N", "O", "undefined", + "globalThis", ...completion.insideMethodKeywords, ], }, diff --git a/tests/cases/fourslash/completionListIsGlobalCompletion.ts b/tests/cases/fourslash/completionListIsGlobalCompletion.ts index f8ee943053781..2f9d85f396a64 100644 --- a/tests/cases/fourslash/completionListIsGlobalCompletion.ts +++ b/tests/cases/fourslash/completionListIsGlobalCompletion.ts @@ -47,6 +47,6 @@ verify.completions( { marker: "10", exact: completion.classElementKeywords, isGlobalCompletion: false, isNewIdentifierLocation: true }, { marker: "13", exact: globals, isGlobalCompletion: false }, { marker: "15", exact: globals, isGlobalCompletion: true, isNewIdentifierLocation: true }, - { marker: "16", exact: [...x, ...completion.globalsVars, "undefined"], isGlobalCompletion: false }, + { marker: "16", exact: [...x, ...completion.globalsVars, "undefined", "globalThis"], isGlobalCompletion: false }, { marker: "17", exact: completion.globalKeywordsPlusUndefined, isGlobalCompletion: false }, ); diff --git a/tests/cases/fourslash/completionListKeywords.ts b/tests/cases/fourslash/completionListKeywords.ts index 660099d3188a0..c55d11ab9d53c 100644 --- a/tests/cases/fourslash/completionListKeywords.ts +++ b/tests/cases/fourslash/completionListKeywords.ts @@ -4,4 +4,4 @@ /////**/ -verify.completions({ marker: "", exact: ["undefined", ...completion.statementKeywordsWithTypes] }); +verify.completions({ marker: "", exact: ["undefined", "globalThis", ...completion.statementKeywordsWithTypes] }); diff --git a/tests/cases/fourslash/completionListWithMeanings.ts b/tests/cases/fourslash/completionListWithMeanings.ts index 8c3498ebda5a7..07941b9d68668 100644 --- a/tests/cases/fourslash/completionListWithMeanings.ts +++ b/tests/cases/fourslash/completionListWithMeanings.ts @@ -24,6 +24,7 @@ const values: ReadonlyArray = [ { name: "kk", text: "var kk: m3.point3" }, { name: "zz", text: "var zz: point" }, "undefined", + "globalThis", ...completion.statementKeywordsWithTypes, ]; @@ -31,6 +32,7 @@ const types: ReadonlyArray = [ { name: "m", text: "namespace m" }, { name: "m3", text: "namespace m3" }, { name: "point", text: "interface point" }, + "globalThis", ...completion.typeKeywords, ]; diff --git a/tests/cases/fourslash/completionListWithModulesFromModule.ts b/tests/cases/fourslash/completionListWithModulesFromModule.ts index d08e26a8d504e..f9f1e388a7f7f 100644 --- a/tests/cases/fourslash/completionListWithModulesFromModule.ts +++ b/tests/cases/fourslash/completionListWithModulesFromModule.ts @@ -265,6 +265,7 @@ verify.completions( "tmp", ...commonValues, "undefined", + "globalThis", ...completion.statementKeywordsWithTypes, ], }, { @@ -273,6 +274,7 @@ verify.completions( { name: "shwcls", text: "class shwcls" }, { name: "shwint", text: "interface shwint" }, ...commonTypes, + "globalThis", ...completion.typeKeywords, ] }, @@ -287,6 +289,7 @@ verify.completions( { name: "shwcls", text: "class shwcls" }, { name: "shwvar", text: "var shwvar: number" }, "undefined", + "globalThis", ...completion.statementKeywordsWithTypes, ], }, @@ -298,6 +301,7 @@ verify.completions( ...commonTypes, { name: "shwcls", text: "class shwcls" }, { name: "shwint", text: "interface shwint" }, + "globalThis", ...completion.typeKeywords, ], } diff --git a/tests/cases/fourslash/completionsImport_default_anonymous.ts b/tests/cases/fourslash/completionsImport_default_anonymous.ts index 8aa9dfb5af63b..ac21bc5f09e8d 100644 --- a/tests/cases/fourslash/completionsImport_default_anonymous.ts +++ b/tests/cases/fourslash/completionsImport_default_anonymous.ts @@ -14,7 +14,7 @@ goTo.marker("0"); const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true }; verify.completions( - { marker: "0", exact: ["undefined", ...completion.statementKeywordsWithTypes], preferences }, + { marker: "0", exact: ["undefined", "globalThis", ...completion.statementKeywordsWithTypes], preferences }, { marker: "1", includes: { name: "fooBar", source: "/src/foo-bar", sourceDisplay: "./foo-bar", text: "(property) default: 0", kind: "property", hasAction: true }, diff --git a/tests/cases/fourslash/completionsImport_keywords.ts b/tests/cases/fourslash/completionsImport_keywords.ts index 6d4edd83b36ae..54ad8e090d60e 100644 --- a/tests/cases/fourslash/completionsImport_keywords.ts +++ b/tests/cases/fourslash/completionsImport_keywords.ts @@ -34,7 +34,7 @@ verify.completions( { marker: "unique", exact: [ - ...completion.globalsVars, "undefined", + ...completion.globalsVars, "undefined", "globalThis", { name: "unique", source: "/a", sourceDisplay: "./a", text: "(alias) const unique: 0\nexport unique", hasAction: true }, ...completion.globalKeywords.filter(e => e.name !== "unique"), ], diff --git a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts index ae552f437fee9..7bb33107ec213 100644 --- a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts +++ b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts @@ -22,6 +22,7 @@ verify.completions({ exact: [ { name: "foo", text: "var foo: number", kind: "var", kindModifiers: "declare" }, "undefined", + "globalThis", { name: "foo", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts index 10a0c124e4d48..5de309626cd9a 100644 --- a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts @@ -15,6 +15,7 @@ verify.completions({ exact: [ { name: "Test2", text: "(alias) function Test2(): void\nimport Test2", kind: "alias" }, "undefined", + "globalThis", { name: "Test1", source: "/a", sourceDisplay: "./a", text: "function Test1(): void", kind: "function", kindModifiers: "export", hasAction: true }, ...completion.statementKeywordsWithTypes, ], diff --git a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts index f5efa9cd912ab..f6ed2897ca412 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts @@ -20,6 +20,7 @@ verify.completions({ marker: "", exact: [ "undefined", + "globalThis", { name: "foo", source: "/foo/lib/foo", sourceDisplay: "./foo", text: "const foo: 0", kind: "const", kindModifiers: "export", hasAction: true }, ...completion.statementKeywordsWithTypes, ], diff --git a/tests/cases/fourslash/completionsImport_reExportDefault.ts b/tests/cases/fourslash/completionsImport_reExportDefault.ts index 8e38faa0b052c..c02211b5829bf 100644 --- a/tests/cases/fourslash/completionsImport_reExportDefault.ts +++ b/tests/cases/fourslash/completionsImport_reExportDefault.ts @@ -17,6 +17,7 @@ verify.completions({ exact: [ ...completion.globalsVars, "undefined", + "globalThis", { name: "foo", source: "/a/b/impl", diff --git a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts index afe88fa6da893..d24940e689877 100644 --- a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts +++ b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts @@ -11,6 +11,6 @@ verify.completions({ marker: "", - exact: [{ name: "foo", text: "const foo: 1" }, "undefined", ...completion.statementKeywordsWithTypes], + exact: [{ name: "foo", text: "const foo: 1" }, "undefined", "globalThis", ...completion.statementKeywordsWithTypes], preferences: { includeCompletionsForModuleExports: true }, }); diff --git a/tests/cases/fourslash/completionsTypeKeywords.ts b/tests/cases/fourslash/completionsTypeKeywords.ts index 10a6d4537594f..d0b0028c81712 100644 --- a/tests/cases/fourslash/completionsTypeKeywords.ts +++ b/tests/cases/fourslash/completionsTypeKeywords.ts @@ -6,5 +6,5 @@ verify.completions({ marker: "", - exact: ["T", ...completion.typeKeywords], + exact: ["T", "globalThis", ...completion.typeKeywords], }); diff --git a/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts b/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts index 7a577cfbcce36..d3a23a8434f64 100644 --- a/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts +++ b/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts @@ -3,4 +3,4 @@ //@Filename: file.tsx //// var x = Date: Wed, 16 Jan 2019 12:07:29 -0800 Subject: [PATCH 14/19] Add missed fourslash test update --- .../fourslash/completionsImport_exportEquals_anonymous.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts b/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts index c5e87877cfb90..e70653c0b3fdc 100644 --- a/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts +++ b/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts @@ -14,7 +14,7 @@ goTo.marker("0"); const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true }; const exportEntry: FourSlashInterface.ExpectedCompletionEntryObject = { name: "fooBar", source: "/src/foo-bar", sourceDisplay: "./foo-bar", text: "(property) export=: 0", kind: "property", hasAction: true }; verify.completions( - { marker: "0", exact: ["undefined", exportEntry, ...completion.statementKeywordsWithTypes], preferences }, + { marker: "0", exact: ["undefined", "globalThis", exportEntry, ...completion.statementKeywordsWithTypes], preferences }, { marker: "1", includes: exportEntry, preferences } ); verify.applyCodeActionFromCompletion("0", { @@ -25,4 +25,4 @@ verify.applyCodeActionFromCompletion("0", { exp fooB`, -}); \ No newline at end of file +}); From 9db574a0775c685b4c6fa14ce9cde8a5053e2847 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 17 Jan 2019 15:41:29 -0800 Subject: [PATCH 15/19] Remove esnext.globalthis.d.ts too --- src/lib/esnext.globalthis.d.ts | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/lib/esnext.globalthis.d.ts diff --git a/src/lib/esnext.globalthis.d.ts b/src/lib/esnext.globalthis.d.ts deleted file mode 100644 index 4698cdb3181ff..0000000000000 --- a/src/lib/esnext.globalthis.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare var globalThis: typeof globalThis; From 3b27dc4157a75b24f6c8608501efcf89c082135e Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 18 Jan 2019 08:28:12 -0800 Subject: [PATCH 16/19] Add chained globalThis self-lookup test --- tests/baselines/reference/globalThisTypeIndexAccess.js | 5 +++++ tests/baselines/reference/globalThisTypeIndexAccess.symbols | 5 +++++ tests/baselines/reference/globalThisTypeIndexAccess.types | 5 +++++ tests/cases/conformance/es2019/globalThisTypeIndexAccess.ts | 2 ++ 4 files changed, 17 insertions(+) create mode 100644 tests/baselines/reference/globalThisTypeIndexAccess.js create mode 100644 tests/baselines/reference/globalThisTypeIndexAccess.symbols create mode 100644 tests/baselines/reference/globalThisTypeIndexAccess.types create mode 100644 tests/cases/conformance/es2019/globalThisTypeIndexAccess.ts diff --git a/tests/baselines/reference/globalThisTypeIndexAccess.js b/tests/baselines/reference/globalThisTypeIndexAccess.js new file mode 100644 index 0000000000000..aef5c97ed9a91 --- /dev/null +++ b/tests/baselines/reference/globalThisTypeIndexAccess.js @@ -0,0 +1,5 @@ +//// [globalThisTypeIndexAccess.ts] +declare const w_e: (typeof globalThis)["globalThis"] + + +//// [globalThisTypeIndexAccess.js] diff --git a/tests/baselines/reference/globalThisTypeIndexAccess.symbols b/tests/baselines/reference/globalThisTypeIndexAccess.symbols new file mode 100644 index 0000000000000..460867fb1f133 --- /dev/null +++ b/tests/baselines/reference/globalThisTypeIndexAccess.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es2019/globalThisTypeIndexAccess.ts === +declare const w_e: (typeof globalThis)["globalThis"] +>w_e : Symbol(w_e, Decl(globalThisTypeIndexAccess.ts, 0, 13)) +>globalThis : Symbol(globalThis) + diff --git a/tests/baselines/reference/globalThisTypeIndexAccess.types b/tests/baselines/reference/globalThisTypeIndexAccess.types new file mode 100644 index 0000000000000..c290b74407185 --- /dev/null +++ b/tests/baselines/reference/globalThisTypeIndexAccess.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es2019/globalThisTypeIndexAccess.ts === +declare const w_e: (typeof globalThis)["globalThis"] +>w_e : typeof globalThis +>globalThis : typeof globalThis + diff --git a/tests/cases/conformance/es2019/globalThisTypeIndexAccess.ts b/tests/cases/conformance/es2019/globalThisTypeIndexAccess.ts new file mode 100644 index 0000000000000..88f68f8f88405 --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisTypeIndexAccess.ts @@ -0,0 +1,2 @@ + +declare const w_e: (typeof globalThis)["globalThis"] From d4d5be4fa50c490bc82109096403192b548336cd Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 29 Jan 2019 09:15:45 -0800 Subject: [PATCH 17/19] Attempt at making globalThis readonly In progress, had to interrupt for other work. --- src/compiler/checker.ts | 2 +- tests/cases/conformance/es2019/globalThisPolyfill.ts | 5 +++++ tests/cases/conformance/es2019/globalThisPolyfill2.ts | 5 +++++ tests/cases/conformance/es2019/globalThisPolyfill3.ts | 4 ++++ tests/cases/conformance/es2019/globalThisPolyfill4.ts | 4 ++++ .../cases/conformance/es2019/globalThisPropertyAssignment.ts | 4 ++++ .../cases/conformance/es2019/globalThisReadonlyProperties.ts | 5 +++++ 7 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/cases/conformance/es2019/globalThisPolyfill.ts create mode 100644 tests/cases/conformance/es2019/globalThisPolyfill2.ts create mode 100644 tests/cases/conformance/es2019/globalThisPolyfill3.ts create mode 100644 tests/cases/conformance/es2019/globalThisPolyfill4.ts create mode 100644 tests/cases/conformance/es2019/globalThisPropertyAssignment.ts create mode 100644 tests/cases/conformance/es2019/globalThisReadonlyProperties.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 93d3f64dacb5a..68c8658f22caf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -91,7 +91,7 @@ namespace ts { const undefinedSymbol = createSymbol(SymbolFlags.Property, "undefined" as __String); undefinedSymbol.declarations = []; - const globalThisSymbol = createSymbol(SymbolFlags.ValueModule | SymbolFlags.NamespaceModule, "globalThis" as __String); + const globalThisSymbol = createSymbol(SymbolFlags.ValueModule | SymbolFlags.NamespaceModule, "globalThis" as __String, CheckFlags.Readonly); globalThisSymbol.exports = globals; globalThisSymbol.valueDeclaration = createNode(SyntaxKind.Identifier) as Identifier; (globalThisSymbol.valueDeclaration as Identifier).escapedText = "globalThis" as __String; diff --git a/tests/cases/conformance/es2019/globalThisPolyfill.ts b/tests/cases/conformance/es2019/globalThisPolyfill.ts new file mode 100644 index 0000000000000..0e85ec485a44d --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisPolyfill.ts @@ -0,0 +1,5 @@ +// manual polyfill of globalThis + +var globalThis = this; +var a = 1; +var x = globalThis.a + a; diff --git a/tests/cases/conformance/es2019/globalThisPolyfill2.ts b/tests/cases/conformance/es2019/globalThisPolyfill2.ts new file mode 100644 index 0000000000000..ffe87299a82fe --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisPolyfill2.ts @@ -0,0 +1,5 @@ +// manual polyfill of globalThis +var globalThis = global; +var a = 1 +var b = 2 +var x = globalThis.a + global.b diff --git a/tests/cases/conformance/es2019/globalThisPolyfill3.ts b/tests/cases/conformance/es2019/globalThisPolyfill3.ts new file mode 100644 index 0000000000000..0e4353bbe5972 --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisPolyfill3.ts @@ -0,0 +1,4 @@ +// @lib: es5, dom +var globalThis = window; +var a = 1; +var x = globalThis.a + window.a; diff --git a/tests/cases/conformance/es2019/globalThisPolyfill4.ts b/tests/cases/conformance/es2019/globalThisPolyfill4.ts new file mode 100644 index 0000000000000..0cb8e067c89c9 --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisPolyfill4.ts @@ -0,0 +1,4 @@ +// @lib: es5, dom +var globalThis = self; +var a = 1; +var x = globalThis.a + self.a; diff --git a/tests/cases/conformance/es2019/globalThisPropertyAssignment.ts b/tests/cases/conformance/es2019/globalThisPropertyAssignment.ts new file mode 100644 index 0000000000000..a510f9ed4b878 --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisPropertyAssignment.ts @@ -0,0 +1,4 @@ +this.x = 1 +var y = 2 +window.z = 3 +globalThis.alpha = 4 diff --git a/tests/cases/conformance/es2019/globalThisReadonlyProperties.ts b/tests/cases/conformance/es2019/globalThisReadonlyProperties.ts new file mode 100644 index 0000000000000..f641fe8d0da51 --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisReadonlyProperties.ts @@ -0,0 +1,5 @@ +globalThis.globalThis = 1 as any // should error +var x = 1 +const y = 2 +globalThis.x = 3 +globalThis.y = 4 // should error From 00312cd654705528af82551a580d10f35576a286 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 19 Feb 2019 14:59:28 -0800 Subject: [PATCH 18/19] Add/update tests --- src/compiler/checker.ts | 3 +- src/harness/fourslash.ts | 16 +++++----- src/testRunner/unittests/tsserver/projects.ts | 2 +- .../globalThisPropertyAssignment.errors.txt | 13 ++++++++ .../globalThisPropertyAssignment.symbols | 19 ++++++++++++ .../globalThisPropertyAssignment.types | 28 +++++++++++++++++ .../globalThisReadonlyProperties.errors.txt | 15 +++++++++ .../reference/globalThisReadonlyProperties.js | 14 +++++++++ .../globalThisReadonlyProperties.symbols | 22 +++++++++++++ .../globalThisReadonlyProperties.types | 31 +++++++++++++++++++ .../conformance/es2019/globalThisPolyfill.ts | 5 --- .../conformance/es2019/globalThisPolyfill2.ts | 5 --- .../conformance/es2019/globalThisPolyfill3.ts | 4 --- .../conformance/es2019/globalThisPolyfill4.ts | 4 --- .../es2019/globalThisPropertyAssignment.ts | 6 ++++ .../completionEntryForClassMembers.ts | 2 +- .../completionListIsGlobalCompletion.ts | 2 +- .../cases/fourslash/completionListKeywords.ts | 2 +- .../fourslash/completionListWithMeanings.ts | 4 +-- .../completionListWithModulesFromModule.ts | 8 ++--- .../completionsImport_default_anonymous.ts | 2 +- ...ompletionsImport_exportEquals_anonymous.ts | 2 +- .../fourslash/completionsImport_keywords.ts | 2 +- .../completionsImport_multipleWithSameName.ts | 2 +- ...mpletionsImport_named_didNotExistBefore.ts | 2 +- ...mpletionsImport_ofAlias_preferShortPath.ts | 2 +- .../completionsImport_reExportDefault.ts | 2 +- .../completionsImport_shadowedByLocal.ts | 2 +- .../fourslash/completionsTypeKeywords.ts | 2 +- .../tsxCompletionOnOpeningTagWithoutJSX1.ts | 2 +- 30 files changed, 178 insertions(+), 47 deletions(-) create mode 100644 tests/baselines/reference/globalThisPropertyAssignment.errors.txt create mode 100644 tests/baselines/reference/globalThisPropertyAssignment.symbols create mode 100644 tests/baselines/reference/globalThisPropertyAssignment.types create mode 100644 tests/baselines/reference/globalThisReadonlyProperties.errors.txt create mode 100644 tests/baselines/reference/globalThisReadonlyProperties.js create mode 100644 tests/baselines/reference/globalThisReadonlyProperties.symbols create mode 100644 tests/baselines/reference/globalThisReadonlyProperties.types delete mode 100644 tests/cases/conformance/es2019/globalThisPolyfill.ts delete mode 100644 tests/cases/conformance/es2019/globalThisPolyfill2.ts delete mode 100644 tests/cases/conformance/es2019/globalThisPolyfill3.ts delete mode 100644 tests/cases/conformance/es2019/globalThisPolyfill4.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ba1791bb386a5..6f51467e53db2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -96,6 +96,8 @@ namespace ts { globalThisSymbol.exports = globals; globalThisSymbol.valueDeclaration = createNode(SyntaxKind.Identifier) as Identifier; (globalThisSymbol.valueDeclaration as Identifier).escapedText = "globalThis" as __String; + globals.set(globalThisSymbol.escapedName, globalThisSymbol); + const argumentsSymbol = createSymbol(SymbolFlags.Property, "arguments" as __String); const requireSymbol = createSymbol(SymbolFlags.Property, "require" as __String); @@ -726,7 +728,6 @@ namespace ts { const builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - builtinGlobals.set(globalThisSymbol.escapedName, globalThisSymbol); const isNotOverloadAndNotAccessor = and(isNotOverload, isNotAccessor); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 6d6805f7e412b..16f1a37ae83fa 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -774,7 +774,7 @@ namespace FourSlash { if ("exact" in options) { ts.Debug.assert(!("includes" in options) && !("excludes" in options)); if (options.exact === undefined) throw this.raiseError("Expected no completions"); - this.verifyCompletionsAreExactly(actualCompletions.entries, toArray(options.exact)); + this.verifyCompletionsAreExactly(actualCompletions.entries, toArray(options.exact), options.marker); } else { if (options.includes) { @@ -841,14 +841,14 @@ namespace FourSlash { } } - private verifyCompletionsAreExactly(actual: ReadonlyArray, expected: ReadonlyArray) { + private verifyCompletionsAreExactly(actual: ReadonlyArray, expected: ReadonlyArray, marker?: ArrayOrSingle) { // First pass: test that names are right. Then we'll test details. - assert.deepEqual(actual.map(a => a.name), expected.map(e => typeof e === "string" ? e : e.name)); + assert.deepEqual(actual.map(a => a.name), expected.map(e => typeof e === "string" ? e : e.name), marker ? "At marker " + JSON.stringify(marker) : undefined); ts.zipWith(actual, expected, (completion, expectedCompletion, index) => { const name = typeof expectedCompletion === "string" ? expectedCompletion : expectedCompletion.name; if (completion.name !== name) { - this.raiseError(`Expected completion at index ${index} to be ${name}, got ${completion.name}`); + this.raiseError(`${marker ? JSON.stringify(marker) : "" } Expected completion at index ${index} to be ${name}, got ${completion.name}`); } this.verifyCompletionEntry(completion, expectedCompletion); }); @@ -4545,9 +4545,9 @@ namespace FourSlashInterface { export function globalTypesPlus(plus: ReadonlyArray): ReadonlyArray { return [ + { name: "globalThis", kind: "module" }, ...globalTypeDecls, ...plus, - { name: "globalThis", kind: "module" }, ...typeKeywords, ]; } @@ -4787,9 +4787,9 @@ namespace FourSlashInterface { export const globalsInsideFunction = (plus: ReadonlyArray): ReadonlyArray => [ { name: "arguments", kind: "local var" }, ...plus, + { name: "globalThis", kind: "module" }, ...globalsVars, { name: "undefined", kind: "var" }, - { name: "globalThis", kind: "module" }, ...globalKeywordsInsideFunction, ]; @@ -4923,18 +4923,18 @@ namespace FourSlashInterface { })(); export const globals: ReadonlyArray = [ + { name: "globalThis", kind: "module" }, ...globalsVars, { name: "undefined", kind: "var" }, - { name: "globalThis", kind: "module" }, ...globalKeywords ]; export function globalsPlus(plus: ReadonlyArray): ReadonlyArray { return [ + { name: "globalThis", kind: "module" }, ...globalsVars, ...plus, { name: "undefined", kind: "var" }, - { name: "globalThis", kind: "module" }, ...globalKeywords]; } } diff --git a/src/testRunner/unittests/tsserver/projects.ts b/src/testRunner/unittests/tsserver/projects.ts index 3a648c9189e40..dd568a082d9d2 100644 --- a/src/testRunner/unittests/tsserver/projects.ts +++ b/src/testRunner/unittests/tsserver/projects.ts @@ -708,7 +708,7 @@ namespace ts.projectSystem { // Check identifiers defined in HTML content are available in .ts file const project = configuredProjectAt(projectService, 0); let completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 1, emptyOptions); - assert(completions && completions.entries[0].name === "hello", `expected entry hello to be in completion list`); + assert(completions && completions.entries[1].name === "hello", `expected entry hello to be in completion list`); // Close HTML file projectService.applyChangesInOpenFiles( diff --git a/tests/baselines/reference/globalThisPropertyAssignment.errors.txt b/tests/baselines/reference/globalThisPropertyAssignment.errors.txt new file mode 100644 index 0000000000000..a02824415ae34 --- /dev/null +++ b/tests/baselines/reference/globalThisPropertyAssignment.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/es2019/globalThisPropertyAssignment.js(4,8): error TS2339: Property 'z' does not exist on type 'Window'. + + +==== tests/cases/conformance/es2019/globalThisPropertyAssignment.js (1 errors) ==== + this.x = 1 + var y = 2 + // should work in JS + window.z = 3 + ~ +!!! error TS2339: Property 'z' does not exist on type 'Window'. + // should work in JS (even though it's a secondary declaration) + globalThis.alpha = 4 + \ No newline at end of file diff --git a/tests/baselines/reference/globalThisPropertyAssignment.symbols b/tests/baselines/reference/globalThisPropertyAssignment.symbols new file mode 100644 index 0000000000000..1ae4dd5af6387 --- /dev/null +++ b/tests/baselines/reference/globalThisPropertyAssignment.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es2019/globalThisPropertyAssignment.js === +this.x = 1 +>this.x : Symbol(x, Decl(globalThisPropertyAssignment.js, 0, 0)) +>this : Symbol(globalThis) +>x : Symbol(x, Decl(globalThisPropertyAssignment.js, 0, 0)) + +var y = 2 +>y : Symbol(y, Decl(globalThisPropertyAssignment.js, 1, 3)) + +// should work in JS +window.z = 3 +>window : Symbol(window, Decl(lib.dom.d.ts, --, --), Decl(globalThisPropertyAssignment.js, 1, 9)) + +// should work in JS (even though it's a secondary declaration) +globalThis.alpha = 4 +>globalThis.alpha : Symbol(alpha, Decl(globalThisPropertyAssignment.js, 3, 12)) +>globalThis : Symbol(globalThis) +>alpha : Symbol(alpha, Decl(globalThisPropertyAssignment.js, 3, 12)) + diff --git a/tests/baselines/reference/globalThisPropertyAssignment.types b/tests/baselines/reference/globalThisPropertyAssignment.types new file mode 100644 index 0000000000000..6be55e136b0b5 --- /dev/null +++ b/tests/baselines/reference/globalThisPropertyAssignment.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/es2019/globalThisPropertyAssignment.js === +this.x = 1 +>this.x = 1 : 1 +>this.x : number +>this : typeof globalThis +>x : number +>1 : 1 + +var y = 2 +>y : number +>2 : 2 + +// should work in JS +window.z = 3 +>window.z = 3 : 3 +>window.z : any +>window : Window +>z : any +>3 : 3 + +// should work in JS (even though it's a secondary declaration) +globalThis.alpha = 4 +>globalThis.alpha = 4 : 4 +>globalThis.alpha : number +>globalThis : typeof globalThis +>alpha : number +>4 : 4 + diff --git a/tests/baselines/reference/globalThisReadonlyProperties.errors.txt b/tests/baselines/reference/globalThisReadonlyProperties.errors.txt new file mode 100644 index 0000000000000..925cf90a10c77 --- /dev/null +++ b/tests/baselines/reference/globalThisReadonlyProperties.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/es2019/globalThisReadonlyProperties.ts(1,12): error TS2540: Cannot assign to 'globalThis' because it is a read-only property. +tests/cases/conformance/es2019/globalThisReadonlyProperties.ts(5,12): error TS2540: Cannot assign to 'y' because it is a read-only property. + + +==== tests/cases/conformance/es2019/globalThisReadonlyProperties.ts (2 errors) ==== + globalThis.globalThis = 1 as any // should error + ~~~~~~~~~~ +!!! error TS2540: Cannot assign to 'globalThis' because it is a read-only property. + var x = 1 + const y = 2 + globalThis.x = 3 + globalThis.y = 4 // should error + ~ +!!! error TS2540: Cannot assign to 'y' because it is a read-only property. + \ No newline at end of file diff --git a/tests/baselines/reference/globalThisReadonlyProperties.js b/tests/baselines/reference/globalThisReadonlyProperties.js new file mode 100644 index 0000000000000..3012608a125c1 --- /dev/null +++ b/tests/baselines/reference/globalThisReadonlyProperties.js @@ -0,0 +1,14 @@ +//// [globalThisReadonlyProperties.ts] +globalThis.globalThis = 1 as any // should error +var x = 1 +const y = 2 +globalThis.x = 3 +globalThis.y = 4 // should error + + +//// [globalThisReadonlyProperties.js] +globalThis.globalThis = 1; // should error +var x = 1; +var y = 2; +globalThis.x = 3; +globalThis.y = 4; // should error diff --git a/tests/baselines/reference/globalThisReadonlyProperties.symbols b/tests/baselines/reference/globalThisReadonlyProperties.symbols new file mode 100644 index 0000000000000..df59ee45ca36a --- /dev/null +++ b/tests/baselines/reference/globalThisReadonlyProperties.symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/es2019/globalThisReadonlyProperties.ts === +globalThis.globalThis = 1 as any // should error +>globalThis.globalThis : Symbol(globalThis) +>globalThis : Symbol(globalThis) +>globalThis : Symbol(globalThis) + +var x = 1 +>x : Symbol(x, Decl(globalThisReadonlyProperties.ts, 1, 3)) + +const y = 2 +>y : Symbol(y, Decl(globalThisReadonlyProperties.ts, 2, 5)) + +globalThis.x = 3 +>globalThis.x : Symbol(x, Decl(globalThisReadonlyProperties.ts, 1, 3)) +>globalThis : Symbol(globalThis) +>x : Symbol(x, Decl(globalThisReadonlyProperties.ts, 1, 3)) + +globalThis.y = 4 // should error +>globalThis.y : Symbol(y, Decl(globalThisReadonlyProperties.ts, 2, 5)) +>globalThis : Symbol(globalThis) +>y : Symbol(y, Decl(globalThisReadonlyProperties.ts, 2, 5)) + diff --git a/tests/baselines/reference/globalThisReadonlyProperties.types b/tests/baselines/reference/globalThisReadonlyProperties.types new file mode 100644 index 0000000000000..05b3d7c84e8f1 --- /dev/null +++ b/tests/baselines/reference/globalThisReadonlyProperties.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/es2019/globalThisReadonlyProperties.ts === +globalThis.globalThis = 1 as any // should error +>globalThis.globalThis = 1 as any : any +>globalThis.globalThis : any +>globalThis : typeof globalThis +>globalThis : any +>1 as any : any +>1 : 1 + +var x = 1 +>x : number +>1 : 1 + +const y = 2 +>y : 2 +>2 : 2 + +globalThis.x = 3 +>globalThis.x = 3 : 3 +>globalThis.x : number +>globalThis : typeof globalThis +>x : number +>3 : 3 + +globalThis.y = 4 // should error +>globalThis.y = 4 : 4 +>globalThis.y : any +>globalThis : typeof globalThis +>y : any +>4 : 4 + diff --git a/tests/cases/conformance/es2019/globalThisPolyfill.ts b/tests/cases/conformance/es2019/globalThisPolyfill.ts deleted file mode 100644 index 0e85ec485a44d..0000000000000 --- a/tests/cases/conformance/es2019/globalThisPolyfill.ts +++ /dev/null @@ -1,5 +0,0 @@ -// manual polyfill of globalThis - -var globalThis = this; -var a = 1; -var x = globalThis.a + a; diff --git a/tests/cases/conformance/es2019/globalThisPolyfill2.ts b/tests/cases/conformance/es2019/globalThisPolyfill2.ts deleted file mode 100644 index ffe87299a82fe..0000000000000 --- a/tests/cases/conformance/es2019/globalThisPolyfill2.ts +++ /dev/null @@ -1,5 +0,0 @@ -// manual polyfill of globalThis -var globalThis = global; -var a = 1 -var b = 2 -var x = globalThis.a + global.b diff --git a/tests/cases/conformance/es2019/globalThisPolyfill3.ts b/tests/cases/conformance/es2019/globalThisPolyfill3.ts deleted file mode 100644 index 0e4353bbe5972..0000000000000 --- a/tests/cases/conformance/es2019/globalThisPolyfill3.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @lib: es5, dom -var globalThis = window; -var a = 1; -var x = globalThis.a + window.a; diff --git a/tests/cases/conformance/es2019/globalThisPolyfill4.ts b/tests/cases/conformance/es2019/globalThisPolyfill4.ts deleted file mode 100644 index 0cb8e067c89c9..0000000000000 --- a/tests/cases/conformance/es2019/globalThisPolyfill4.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @lib: es5, dom -var globalThis = self; -var a = 1; -var x = globalThis.a + self.a; diff --git a/tests/cases/conformance/es2019/globalThisPropertyAssignment.ts b/tests/cases/conformance/es2019/globalThisPropertyAssignment.ts index a510f9ed4b878..fb9638e30fb18 100644 --- a/tests/cases/conformance/es2019/globalThisPropertyAssignment.ts +++ b/tests/cases/conformance/es2019/globalThisPropertyAssignment.ts @@ -1,4 +1,10 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @Filename: globalThisPropertyAssignment.js this.x = 1 var y = 2 +// should work in JS window.z = 3 +// should work in JS (even though it's a secondary declaration) globalThis.alpha = 4 diff --git a/tests/cases/fourslash/completionEntryForClassMembers.ts b/tests/cases/fourslash/completionEntryForClassMembers.ts index da40a28bad6d0..6dcfd059c46f1 100644 --- a/tests/cases/fourslash/completionEntryForClassMembers.ts +++ b/tests/cases/fourslash/completionEntryForClassMembers.ts @@ -130,9 +130,9 @@ verify.completions( marker: "InsideMethod", exact: [ "arguments", + "globalThis", "B", "C", "D", "D1", "D2", "D3", "D4", "D5", "D6", "E", "F", "F2", "G", "G2", "H", "I", "J", "K", "L", "L2", "M", "N", "O", "undefined", - "globalThis", ...completion.insideMethodKeywords, ], }, diff --git a/tests/cases/fourslash/completionListIsGlobalCompletion.ts b/tests/cases/fourslash/completionListIsGlobalCompletion.ts index 2f9d85f396a64..2a37849c2b8ea 100644 --- a/tests/cases/fourslash/completionListIsGlobalCompletion.ts +++ b/tests/cases/fourslash/completionListIsGlobalCompletion.ts @@ -47,6 +47,6 @@ verify.completions( { marker: "10", exact: completion.classElementKeywords, isGlobalCompletion: false, isNewIdentifierLocation: true }, { marker: "13", exact: globals, isGlobalCompletion: false }, { marker: "15", exact: globals, isGlobalCompletion: true, isNewIdentifierLocation: true }, - { marker: "16", exact: [...x, ...completion.globalsVars, "undefined", "globalThis"], isGlobalCompletion: false }, + { marker: "16", exact: [...x, "globalThis", ...completion.globalsVars, "undefined"], isGlobalCompletion: false }, { marker: "17", exact: completion.globalKeywordsPlusUndefined, isGlobalCompletion: false }, ); diff --git a/tests/cases/fourslash/completionListKeywords.ts b/tests/cases/fourslash/completionListKeywords.ts index c55d11ab9d53c..ed489487b3c60 100644 --- a/tests/cases/fourslash/completionListKeywords.ts +++ b/tests/cases/fourslash/completionListKeywords.ts @@ -4,4 +4,4 @@ /////**/ -verify.completions({ marker: "", exact: ["undefined", "globalThis", ...completion.statementKeywordsWithTypes] }); +verify.completions({ marker: "", exact: ["globalThis", "undefined", ...completion.statementKeywordsWithTypes] }); diff --git a/tests/cases/fourslash/completionListWithMeanings.ts b/tests/cases/fourslash/completionListWithMeanings.ts index 07941b9d68668..41df1ed381657 100644 --- a/tests/cases/fourslash/completionListWithMeanings.ts +++ b/tests/cases/fourslash/completionListWithMeanings.ts @@ -16,6 +16,7 @@ ////var zz = { x: 4, y: 3 }; const values: ReadonlyArray = [ + "globalThis", { name: "m2", text: "namespace m2" }, // With no type side, allowed only in value { name: "m3", text: "namespace m3" }, { name: "xx", text: "var xx: number" }, @@ -24,15 +25,14 @@ const values: ReadonlyArray = [ { name: "kk", text: "var kk: m3.point3" }, { name: "zz", text: "var zz: point" }, "undefined", - "globalThis", ...completion.statementKeywordsWithTypes, ]; const types: ReadonlyArray = [ + "globalThis", { name: "m", text: "namespace m" }, { name: "m3", text: "namespace m3" }, { name: "point", text: "interface point" }, - "globalThis", ...completion.typeKeywords, ]; diff --git a/tests/cases/fourslash/completionListWithModulesFromModule.ts b/tests/cases/fourslash/completionListWithModulesFromModule.ts index f9f1e388a7f7f..dbcbdd797835a 100644 --- a/tests/cases/fourslash/completionListWithModulesFromModule.ts +++ b/tests/cases/fourslash/completionListWithModulesFromModule.ts @@ -263,9 +263,9 @@ verify.completions( { name: "shwvar", text: "var shwvar: string" }, { name: "shwcls", text: "class shwcls" }, "tmp", + "globalThis", ...commonValues, "undefined", - "globalThis", ...completion.statementKeywordsWithTypes, ], }, { @@ -273,8 +273,8 @@ verify.completions( exact: [ { name: "shwcls", text: "class shwcls" }, { name: "shwint", text: "interface shwint" }, - ...commonTypes, "globalThis", + ...commonTypes, ...completion.typeKeywords, ] }, @@ -284,12 +284,12 @@ verify.completions( "Mod1", "iMod1", "tmp", + "globalThis", { name: "shwfn", text: "function shwfn(): void" }, ...commonValues, { name: "shwcls", text: "class shwcls" }, { name: "shwvar", text: "var shwvar: number" }, "undefined", - "globalThis", ...completion.statementKeywordsWithTypes, ], }, @@ -298,10 +298,10 @@ verify.completions( exact: [ "Mod1", "iMod1", + "globalThis", ...commonTypes, { name: "shwcls", text: "class shwcls" }, { name: "shwint", text: "interface shwint" }, - "globalThis", ...completion.typeKeywords, ], } diff --git a/tests/cases/fourslash/completionsImport_default_anonymous.ts b/tests/cases/fourslash/completionsImport_default_anonymous.ts index ac21bc5f09e8d..720bb3f1c6bec 100644 --- a/tests/cases/fourslash/completionsImport_default_anonymous.ts +++ b/tests/cases/fourslash/completionsImport_default_anonymous.ts @@ -14,7 +14,7 @@ goTo.marker("0"); const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true }; verify.completions( - { marker: "0", exact: ["undefined", "globalThis", ...completion.statementKeywordsWithTypes], preferences }, + { marker: "0", exact: ["globalThis", "undefined", ...completion.statementKeywordsWithTypes], preferences }, { marker: "1", includes: { name: "fooBar", source: "/src/foo-bar", sourceDisplay: "./foo-bar", text: "(property) default: 0", kind: "property", hasAction: true }, diff --git a/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts b/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts index e70653c0b3fdc..8fc73457117b5 100644 --- a/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts +++ b/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts @@ -14,7 +14,7 @@ goTo.marker("0"); const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true }; const exportEntry: FourSlashInterface.ExpectedCompletionEntryObject = { name: "fooBar", source: "/src/foo-bar", sourceDisplay: "./foo-bar", text: "(property) export=: 0", kind: "property", hasAction: true }; verify.completions( - { marker: "0", exact: ["undefined", "globalThis", exportEntry, ...completion.statementKeywordsWithTypes], preferences }, + { marker: "0", exact: ["globalThis", "undefined", exportEntry, ...completion.statementKeywordsWithTypes], preferences }, { marker: "1", includes: exportEntry, preferences } ); verify.applyCodeActionFromCompletion("0", { diff --git a/tests/cases/fourslash/completionsImport_keywords.ts b/tests/cases/fourslash/completionsImport_keywords.ts index 54ad8e090d60e..64bab64c7a8f5 100644 --- a/tests/cases/fourslash/completionsImport_keywords.ts +++ b/tests/cases/fourslash/completionsImport_keywords.ts @@ -34,7 +34,7 @@ verify.completions( { marker: "unique", exact: [ - ...completion.globalsVars, "undefined", "globalThis", + "globalThis", ...completion.globalsVars, "undefined", { name: "unique", source: "/a", sourceDisplay: "./a", text: "(alias) const unique: 0\nexport unique", hasAction: true }, ...completion.globalKeywords.filter(e => e.name !== "unique"), ], diff --git a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts index 7bb33107ec213..5893f6f0fdc8c 100644 --- a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts +++ b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts @@ -20,9 +20,9 @@ goTo.marker(""); verify.completions({ marker: "", exact: [ + "globalThis", { name: "foo", text: "var foo: number", kind: "var", kindModifiers: "declare" }, "undefined", - "globalThis", { name: "foo", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts index 5de309626cd9a..5f21db1e3763e 100644 --- a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts @@ -14,8 +14,8 @@ verify.completions({ marker: "", exact: [ { name: "Test2", text: "(alias) function Test2(): void\nimport Test2", kind: "alias" }, - "undefined", "globalThis", + "undefined", { name: "Test1", source: "/a", sourceDisplay: "./a", text: "function Test1(): void", kind: "function", kindModifiers: "export", hasAction: true }, ...completion.statementKeywordsWithTypes, ], diff --git a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts index f6ed2897ca412..71242bc240a96 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts @@ -19,8 +19,8 @@ verify.completions({ marker: "", exact: [ - "undefined", "globalThis", + "undefined", { name: "foo", source: "/foo/lib/foo", sourceDisplay: "./foo", text: "const foo: 0", kind: "const", kindModifiers: "export", hasAction: true }, ...completion.statementKeywordsWithTypes, ], diff --git a/tests/cases/fourslash/completionsImport_reExportDefault.ts b/tests/cases/fourslash/completionsImport_reExportDefault.ts index c02211b5829bf..7f6639c3f13d8 100644 --- a/tests/cases/fourslash/completionsImport_reExportDefault.ts +++ b/tests/cases/fourslash/completionsImport_reExportDefault.ts @@ -15,9 +15,9 @@ verify.completions({ marker: "", exact: [ + "globalThis", ...completion.globalsVars, "undefined", - "globalThis", { name: "foo", source: "/a/b/impl", diff --git a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts index d24940e689877..711386816c081 100644 --- a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts +++ b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts @@ -11,6 +11,6 @@ verify.completions({ marker: "", - exact: [{ name: "foo", text: "const foo: 1" }, "undefined", "globalThis", ...completion.statementKeywordsWithTypes], + exact: ["globalThis", { name: "foo", text: "const foo: 1" }, "undefined", ...completion.statementKeywordsWithTypes], preferences: { includeCompletionsForModuleExports: true }, }); diff --git a/tests/cases/fourslash/completionsTypeKeywords.ts b/tests/cases/fourslash/completionsTypeKeywords.ts index d0b0028c81712..4c26e13932ec1 100644 --- a/tests/cases/fourslash/completionsTypeKeywords.ts +++ b/tests/cases/fourslash/completionsTypeKeywords.ts @@ -6,5 +6,5 @@ verify.completions({ marker: "", - exact: ["T", "globalThis", ...completion.typeKeywords], + exact: ["globalThis", "T", ...completion.typeKeywords], }); diff --git a/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts b/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts index d3a23a8434f64..9198f5a857add 100644 --- a/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts +++ b/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts @@ -3,4 +3,4 @@ //@Filename: file.tsx //// var x = Date: Wed, 27 Feb 2019 10:10:19 -0800 Subject: [PATCH 19/19] Addres PR comments: 1. Add parameter to tryGetThisTypeAt to exclude globalThis. 2. Use combined Module flag instead combining them in-place. 3. SymbolDisplay doesn't print 'module globalThis' for this expressions anymore. --- src/compiler/checker.ts | 14 +++++++------- src/compiler/types.ts | 2 +- src/services/completions.ts | 4 ++-- src/services/symbolDisplay.ts | 2 +- src/testRunner/unittests/tsserver/projects.ts | 1 + tests/cases/fourslash/findAllRefsThisKeyword.ts | 4 ++-- .../findAllRefsThisKeywordMultipleFiles.ts | 2 +- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fccfe97d9fbcf..7a4c32ea00113 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -92,7 +92,7 @@ namespace ts { const undefinedSymbol = createSymbol(SymbolFlags.Property, "undefined" as __String); undefinedSymbol.declarations = []; - const globalThisSymbol = createSymbol(SymbolFlags.ValueModule | SymbolFlags.NamespaceModule, "globalThis" as __String, CheckFlags.Readonly); + const globalThisSymbol = createSymbol(SymbolFlags.Module, "globalThis" as __String, CheckFlags.Readonly); globalThisSymbol.exports = globals; globalThisSymbol.valueDeclaration = createNode(SyntaxKind.Identifier) as Identifier; (globalThisSymbol.valueDeclaration as Identifier).escapedText = "globalThis" as __String; @@ -318,9 +318,9 @@ namespace ts { getAccessibleSymbolChain, getTypePredicateOfSignature: getTypePredicateOfSignature as (signature: Signature) => TypePredicate, // TODO: GH#18217 resolveExternalModuleSymbol, - tryGetThisTypeAt: node => { + tryGetThisTypeAt: (node, includeGlobalThis) => { node = getParseTreeNode(node); - return node && tryGetThisTypeAt(node); + return node && tryGetThisTypeAt(node, includeGlobalThis); }, getTypeArgumentConstraint: nodeIn => { const node = getParseTreeNode(nodeIn, isTypeNode); @@ -16988,9 +16988,9 @@ namespace ts { captureLexicalThis(node, container); } - const type = tryGetThisTypeAt(node, container); - const globalThisType = getTypeOfSymbol(globalThisSymbol); + const type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); if (noImplicitThis) { + const globalThisType = getTypeOfSymbol(globalThisSymbol); if (type === globalThisType && capturedByArrowFunction) { error(node, Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this); } @@ -17008,7 +17008,7 @@ namespace ts { return type || anyType; } - function tryGetThisTypeAt(node: Node, container = getThisContainer(node, /*includeArrowFunctions*/ false)): Type | undefined { + function tryGetThisTypeAt(node: Node, includeGlobalThis = true, container = getThisContainer(node, /*includeArrowFunctions*/ false)): Type | undefined { const isInJS = isInJSFile(node); if (isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || getThisParameter(container))) { @@ -17061,7 +17061,7 @@ namespace ts { const fileSymbol = getSymbolOfNode(container); return fileSymbol && getTypeOfSymbol(fileSymbol); } - else { + else if (includeGlobalThis) { return getTypeOfSymbol(globalThisSymbol); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index cce869df44ea1..42fd1126d4cba 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3223,7 +3223,7 @@ namespace ts { */ /* @internal */ resolveExternalModuleSymbol(symbol: Symbol): Symbol; /** @param node A location where we might consider accessing `this`. Not necessarily a ThisExpression. */ - /* @internal */ tryGetThisTypeAt(node: Node): Type | undefined; + /* @internal */ tryGetThisTypeAt(node: Node, includeGlobalThis?: boolean): Type | undefined; /* @internal */ getTypeArgumentConstraint(node: TypeNode): Type | undefined; /** diff --git a/src/services/completions.ts b/src/services/completions.ts index 797ba5580b82e..a070bf8f7c1f0 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1030,8 +1030,8 @@ namespace ts.Completions { // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== SyntaxKind.SourceFile) { - const thisType = typeChecker.tryGetThisTypeAt(scopeNode); - if (thisType && thisType.symbol.name !== "globalThis") { + const thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); + if (thisType) { for (const symbol of getPropertiesForCompletion(thisType, typeChecker)) { symbolToOriginInfoMap[getSymbolId(symbol)] = { kind: SymbolOriginInfoKind.ThisType }; symbols.push(symbol); diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index e0728f98a29ba..1c710b8cd7838 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -310,7 +310,7 @@ namespace ts.SymbolDisplay { displayParts.push(spacePart()); addFullSymbolName(symbol); } - if (symbolFlags & SymbolFlags.Module) { + if (symbolFlags & SymbolFlags.Module && !isThisExpression) { prefixNextMeaning(); const declaration = getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration); const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier; diff --git a/src/testRunner/unittests/tsserver/projects.ts b/src/testRunner/unittests/tsserver/projects.ts index dd568a082d9d2..264dbff285ec5 100644 --- a/src/testRunner/unittests/tsserver/projects.ts +++ b/src/testRunner/unittests/tsserver/projects.ts @@ -709,6 +709,7 @@ namespace ts.projectSystem { const project = configuredProjectAt(projectService, 0); let completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 1, emptyOptions); assert(completions && completions.entries[1].name === "hello", `expected entry hello to be in completion list`); + assert(completions && completions.entries[0].name === "globalThis", `first entry should be globalThis (not strictly relevant for this test).`); // Close HTML file projectService.applyChangesInOpenFiles( diff --git a/tests/cases/fourslash/findAllRefsThisKeyword.ts b/tests/cases/fourslash/findAllRefsThisKeyword.ts index 6140654c8427b..b0045e91bc195 100644 --- a/tests/cases/fourslash/findAllRefsThisKeyword.ts +++ b/tests/cases/fourslash/findAllRefsThisKeyword.ts @@ -24,8 +24,8 @@ ////const x = { [|{| "isWriteAccess": true, "isDefinition": true |}this|]: 0 } ////x.[|this|]; -const [global, f0, f1, g0, g1, x, y, constructor, method, propDef, propUse] = test.ranges(); -verify.singleReferenceGroup("module globalThis\nthis: typeof globalThis", [global]); +const [glob, f0, f1, g0, g1, x, y, constructor, method, propDef, propUse] = test.ranges(); +verify.singleReferenceGroup("this: typeof globalThis", [glob]); verify.singleReferenceGroup("(parameter) this: any", [f0, f1]); verify.singleReferenceGroup("(parameter) this: any", [g0, g1]); verify.singleReferenceGroup("this: typeof C", [x, y]); diff --git a/tests/cases/fourslash/findAllRefsThisKeywordMultipleFiles.ts b/tests/cases/fourslash/findAllRefsThisKeywordMultipleFiles.ts index 1ec1680dfb724..807bc9bf19405 100644 --- a/tests/cases/fourslash/findAllRefsThisKeywordMultipleFiles.ts +++ b/tests/cases/fourslash/findAllRefsThisKeywordMultipleFiles.ts @@ -12,4 +12,4 @@ //// // different 'this' //// function f(this) { return this; } -verify.singleReferenceGroup("module globalThis\nthis: typeof globalThis"); +verify.singleReferenceGroup("this: typeof globalThis");