-
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.
Check that Symbol properties are proper, and support downlevel type c…
…hecking
- Loading branch information
1 parent
3834edd
commit 4c09ccd
Showing
32 changed files
with
457 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
tests/cases/conformance/Symbols/ES5SymbolProperty1.ts(7,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/Symbols/ES5SymbolProperty1.ts(7,6): error TS2471: A computed property name of the form 'Symbol.foo' must be of type 'symbol'. | ||
|
||
|
||
==== tests/cases/conformance/Symbols/ES5SymbolProperty1.ts (2 errors) ==== | ||
interface SymbolConstructor { | ||
foo: string; | ||
} | ||
var Symbol: SymbolConstructor; | ||
|
||
var obj = { | ||
[Symbol.foo]: 0 | ||
~~~~~~~~~~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~~~~~~~~~~ | ||
!!! error TS2471: A computed property name of the form 'Symbol.foo' must be of type 'symbol'. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
JsonFreeman
Author
Contributor
|
||
} | ||
|
||
obj[Symbol.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//// [ES5SymbolProperty1.ts] | ||
interface SymbolConstructor { | ||
foo: string; | ||
} | ||
var Symbol: SymbolConstructor; | ||
|
||
var obj = { | ||
[Symbol.foo]: 0 | ||
} | ||
|
||
obj[Symbol.foo]; | ||
|
||
//// [ES5SymbolProperty1.js] | ||
var Symbol; | ||
var obj = { | ||
[Symbol.foo]: 0 | ||
}; | ||
obj[Symbol.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
tests/cases/conformance/Symbols/ES5SymbolProperty2.ts(5,9): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/Symbols/ES5SymbolProperty2.ts(5,10): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'. | ||
tests/cases/conformance/Symbols/ES5SymbolProperty2.ts(10,11): error TS2304: Cannot find name 'Symbol'. | ||
|
||
|
||
==== tests/cases/conformance/Symbols/ES5SymbolProperty2.ts (3 errors) ==== | ||
module M { | ||
var Symbol; | ||
|
||
export class C { | ||
[Symbol.iterator]() { } | ||
~~~~~~~~~~~~~~~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~~~~~~~~~~~~~~~ | ||
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'. | ||
} | ||
(new C)[Symbol.iterator]; | ||
} | ||
|
||
(new M.C)[Symbol.iterator]; | ||
~~~~~~ | ||
!!! error TS2304: Cannot find name 'Symbol'. |
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,27 @@ | ||
//// [ES5SymbolProperty2.ts] | ||
module M { | ||
var Symbol; | ||
|
||
export class C { | ||
[Symbol.iterator]() { } | ||
} | ||
(new C)[Symbol.iterator]; | ||
} | ||
|
||
(new M.C)[Symbol.iterator]; | ||
|
||
//// [ES5SymbolProperty2.js] | ||
var M; | ||
(function (M) { | ||
var Symbol; | ||
var C = (function () { | ||
function C() { | ||
} | ||
C.prototype[Symbol.iterator] = function () { | ||
}; | ||
return C; | ||
})(); | ||
M.C = C; | ||
(new C)[Symbol.iterator]; | ||
})(M || (M = {})); | ||
(new M.C)[Symbol.iterator]; |
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,16 @@ | ||
tests/cases/conformance/Symbols/ES5SymbolProperty3.ts(4,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/Symbols/ES5SymbolProperty3.ts(4,6): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'. | ||
|
||
|
||
==== tests/cases/conformance/Symbols/ES5SymbolProperty3.ts (2 errors) ==== | ||
var Symbol; | ||
|
||
class C { | ||
[Symbol.iterator]() { } | ||
~~~~~~~~~~~~~~~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~~~~~~~~~~~~~~~ | ||
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'. | ||
} | ||
|
||
(new C)[Symbol.iterator] |
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,19 @@ | ||
//// [ES5SymbolProperty3.ts] | ||
var Symbol; | ||
|
||
class C { | ||
[Symbol.iterator]() { } | ||
} | ||
|
||
(new C)[Symbol.iterator] | ||
|
||
//// [ES5SymbolProperty3.js] | ||
var Symbol; | ||
var C = (function () { | ||
function C() { | ||
} | ||
C.prototype[Symbol.iterator] = function () { | ||
}; | ||
return C; | ||
})(); | ||
(new C)[Symbol.iterator]; |
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,16 @@ | ||
tests/cases/conformance/Symbols/ES5SymbolProperty4.ts(4,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/Symbols/ES5SymbolProperty4.ts(4,6): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'. | ||
|
||
|
||
==== tests/cases/conformance/Symbols/ES5SymbolProperty4.ts (2 errors) ==== | ||
var Symbol: { iterator: string }; | ||
|
||
class C { | ||
[Symbol.iterator]() { } | ||
~~~~~~~~~~~~~~~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~~~~~~~~~~~~~~~ | ||
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'. | ||
} | ||
|
||
(new C)[Symbol.iterator] |
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,19 @@ | ||
//// [ES5SymbolProperty4.ts] | ||
var Symbol: { iterator: string }; | ||
|
||
class C { | ||
[Symbol.iterator]() { } | ||
} | ||
|
||
(new C)[Symbol.iterator] | ||
|
||
//// [ES5SymbolProperty4.js] | ||
var Symbol; | ||
var C = (function () { | ||
function C() { | ||
} | ||
C.prototype[Symbol.iterator] = function () { | ||
}; | ||
return C; | ||
})(); | ||
(new C)[Symbol.iterator]; |
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,16 @@ | ||
tests/cases/conformance/Symbols/ES5SymbolProperty5.ts(4,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/Symbols/ES5SymbolProperty5.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target. | ||
|
||
|
||
==== tests/cases/conformance/Symbols/ES5SymbolProperty5.ts (2 errors) ==== | ||
var Symbol: { iterator: symbol }; | ||
|
||
class C { | ||
[Symbol.iterator]() { } | ||
~~~~~~~~~~~~~~~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
} | ||
|
||
(new C)[Symbol.iterator](0) // Should error | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2346: Supplied parameters do not match any signature of call target. |
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,19 @@ | ||
//// [ES5SymbolProperty5.ts] | ||
var Symbol: { iterator: symbol }; | ||
|
||
class C { | ||
[Symbol.iterator]() { } | ||
} | ||
|
||
(new C)[Symbol.iterator](0) // Should error | ||
|
||
//// [ES5SymbolProperty5.js] | ||
var Symbol; | ||
var C = (function () { | ||
function C() { | ||
} | ||
C.prototype[Symbol.iterator] = function () { | ||
}; | ||
return C; | ||
})(); | ||
(new C)[Symbol.iterator](0); // Should error |
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,17 @@ | ||
tests/cases/conformance/Symbols/ES5SymbolProperty6.ts(2,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
tests/cases/conformance/Symbols/ES5SymbolProperty6.ts(2,6): error TS2304: Cannot find name 'Symbol'. | ||
tests/cases/conformance/Symbols/ES5SymbolProperty6.ts(5,9): error TS2304: Cannot find name 'Symbol'. | ||
|
||
|
||
==== tests/cases/conformance/Symbols/ES5SymbolProperty6.ts (3 errors) ==== | ||
class C { | ||
[Symbol.iterator]() { } | ||
~~~~~~~~~~~~~~~~~ | ||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. | ||
~~~~~~ | ||
!!! error TS2304: Cannot find name 'Symbol'. | ||
} | ||
|
||
(new C)[Symbol.iterator] | ||
~~~~~~ | ||
!!! error TS2304: Cannot find name 'Symbol'. |
Oops, something went wrong.
Why this error still get reported? I thought the above error from grammar check will stop error from propagating down