-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type checking for computed properties in object literals
- Loading branch information
1 parent
ef06879
commit 7192767
Showing
25 changed files
with
120 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,12): error TS2304: Cannot find name 'yield'. | ||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,20): error TS2304: Cannot find name 'foo'. | ||
|
||
|
||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (2 errors) ==== | ||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (3 errors) ==== | ||
var v = { [yield]: foo } | ||
~~~~~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~~~~~ | ||
!!! error TS2304: Cannot find name 'yield'. | ||
~~~ | ||
!!! error TS2304: Cannot find name 'foo'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported. | ||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,14): error TS9000: 'yield' expressions are not currently supported. | ||
|
||
|
||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (2 errors) ==== | ||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (3 errors) ==== | ||
function * foo() { | ||
~ | ||
!!! error TS9001: Generators are not currently supported. | ||
var v = { [yield]: foo } | ||
~~~~~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~~~~~ | ||
!!! error TS9000: 'yield' expressions are not currently supported. | ||
} |
7 changes: 5 additions & 2 deletions
7
tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported. | ||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'. | ||
|
||
|
||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ==== | ||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (3 errors) ==== | ||
var v = { *[foo()]() { } } | ||
~ | ||
!!! error TS9001: Generators are not currently supported. | ||
~~~~~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~~~ | ||
!!! error TS2304: Cannot find name 'foo'. |
5 changes: 4 additions & 1 deletion
5
tests/baselines/reference/parserComputedPropertyName1.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts(1,12): error TS2304: Cannot find name 'e'. | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts(1,15): error TS1005: ':' expected. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts (1 errors) ==== | ||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName1.ts (2 errors) ==== | ||
var v = { [e] }; | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. | ||
~ | ||
!!! error TS1005: ':' expected. |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/parserComputedPropertyName17.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts(1,16): error TS2304: Cannot find name 'e'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts (1 errors) ==== | ||
var v = { set [e](v) { } } | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. |
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/parserComputedPropertyName2.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts(1,12): error TS2304: Cannot find name 'e'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts (1 errors) ==== | ||
var v = { [e]: 1 }; | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. |
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/parserComputedPropertyName3.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts(1,12): error TS2304: Cannot find name 'e'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts (1 errors) ==== | ||
var v = { [e]() { } }; | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. |
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/parserComputedPropertyName37.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts(2,6): error TS2304: Cannot find name 'public'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts (1 errors) ==== | ||
var v = { | ||
[public]: 0 | ||
~~~~~~ | ||
!!! error TS2304: Cannot find name 'public'. | ||
}; |
This file was deleted.
Oops, something went wrong.
7 changes: 5 additions & 2 deletions
7
tests/baselines/reference/parserComputedPropertyName4.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts(1,16): error TS2304: Cannot find name 'e'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts (1 errors) ==== | ||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts (2 errors) ==== | ||
var v = { get [e]() { } }; | ||
~~~ | ||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. | ||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. |
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/parserComputedPropertyName41.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts (1 errors) ==== | ||
var v = { | ||
[0 in []]: true | ||
~~~~~~~~~ | ||
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'. | ||
} |
This file was deleted.
Oops, something went wrong.
7 changes: 5 additions & 2 deletions
7
tests/baselines/reference/parserComputedPropertyName5.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,22): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,23): error TS2304: Cannot find name 'e'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts (1 errors) ==== | ||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts (2 errors) ==== | ||
var v = { public get [e]() { } }; | ||
~~~ | ||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. | ||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. |
13 changes: 13 additions & 0 deletions
13
tests/baselines/reference/parserComputedPropertyName6.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts(1,12): error TS2304: Cannot find name 'e'. | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts(1,20): error TS2304: Cannot find name 'e'. | ||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts(1,24): error TS2304: Cannot find name 'e'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts (3 errors) ==== | ||
var v = { [e]: 1, [e + e]: 2 }; | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. |
This file was deleted.
Oops, something went wrong.
7 changes: 5 additions & 2 deletions
7
tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts(1,12): error TS2304: Cannot find name 'e'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts (1 errors) ==== | ||
==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts (2 errors) ==== | ||
var v = { [e]: 1 }; | ||
~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. |
7 changes: 5 additions & 2 deletions
7
tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts(1,12): error TS2304: Cannot find name 'e'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts (1 errors) ==== | ||
==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts (2 errors) ==== | ||
var v = { [e]() { } }; | ||
~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. |
7 changes: 5 additions & 2 deletions
7
tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,15): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. | ||
tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,16): error TS2304: Cannot find name 'e'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts (2 errors) ==== | ||
==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts (3 errors) ==== | ||
var v = { get [e]() { } }; | ||
~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~~~ | ||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. | ||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. | ||
~ | ||
!!! error TS2304: Cannot find name 'e'. |