mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-05 10:32:08 -05:00
Handle toplevel this-assignment (#22913)
Do nothing now. Someday we might handle it correctly.
This commit is contained in:
committed by
GitHub
parent
2bd66b3292
commit
61aad4c7b8
@@ -2362,6 +2362,10 @@ namespace ts {
|
||||
const symbolTable = hasModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports : containingClass.symbol.members;
|
||||
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.
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.fail(Debug.showSyntaxKind(thisContainer));
|
||||
|
||||
18
tests/baselines/reference/topLevelThisAssignment.js
Normal file
18
tests/baselines/reference/topLevelThisAssignment.js
Normal file
@@ -0,0 +1,18 @@
|
||||
//// [tests/cases/conformance/salsa/topLevelThisAssignment.ts] ////
|
||||
|
||||
//// [a.js]
|
||||
this.a = 10;
|
||||
this.a;
|
||||
a;
|
||||
|
||||
//// [b.js]
|
||||
this.a;
|
||||
a;
|
||||
|
||||
|
||||
//// [output.js]
|
||||
this.a = 10;
|
||||
this.a;
|
||||
a;
|
||||
this.a;
|
||||
a;
|
||||
10
tests/baselines/reference/topLevelThisAssignment.symbols
Normal file
10
tests/baselines/reference/topLevelThisAssignment.symbols
Normal file
@@ -0,0 +1,10 @@
|
||||
=== 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;
|
||||
No type information for this code.a;
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
25
tests/baselines/reference/topLevelThisAssignment.types
Normal file
25
tests/baselines/reference/topLevelThisAssignment.types
Normal file
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/conformance/salsa/a.js ===
|
||||
this.a = 10;
|
||||
>this.a = 10 : 10
|
||||
>this.a : any
|
||||
>this : any
|
||||
>a : any
|
||||
>10 : 10
|
||||
|
||||
this.a;
|
||||
>this.a : any
|
||||
>this : any
|
||||
>a : any
|
||||
|
||||
a;
|
||||
>a : any
|
||||
|
||||
=== tests/cases/conformance/salsa/b.js ===
|
||||
this.a;
|
||||
>this.a : any
|
||||
>this : any
|
||||
>a : any
|
||||
|
||||
a;
|
||||
>a : any
|
||||
|
||||
10
tests/cases/conformance/salsa/topLevelThisAssignment.ts
Normal file
10
tests/cases/conformance/salsa/topLevelThisAssignment.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// @out: output.js
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
this.a = 10;
|
||||
this.a;
|
||||
a;
|
||||
|
||||
// @Filename: b.js
|
||||
this.a;
|
||||
a;
|
||||
Reference in New Issue
Block a user