mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Create global Symbol type
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts(1,5): error TS2304: Cannot find name 'd'.
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts(1,5): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts(1,10): error TS2304: Cannot find name '_'.
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts(1,15): error TS2304: Cannot find name 'a'.
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts(1,18): error TS2304: Cannot find name '_'.
|
||||
@@ -7,12 +6,10 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts(1,2
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts(1,30): error TS2304: Cannot find name 'b'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts (7 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts (6 errors) ====
|
||||
for(d in _.jh[a]=_.jh[a]||[],b);
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'd'.
|
||||
~
|
||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name '_'.
|
||||
~
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement6.ts(1,6): error TS2304: Cannot find name 'foo'.
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement6.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/parserForStatement6.ts(1,6): error TS2406: Invalid left-hand side in 'for...in' statement.
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement6.ts(1,15): error TS2304: Cannot find name 'b'.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement6.ts(1,1
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
~~~~~
|
||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
!!! error TS2406: Invalid left-hand side in 'for...in' statement.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'b'.
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement7.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/parserForStatement7.ts(1,6): error TS2406: Invalid left-hand side in 'for...in' statement.
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement7.ts(1,10): error TS2304: Cannot find name 'foo'.
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement7.ts(1,19): error TS2304: Cannot find name 'b'.
|
||||
|
||||
@@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement7.ts(1,1
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement7.ts (3 errors) ====
|
||||
for (new foo() in b) {
|
||||
~~~~~~~~~
|
||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
!!! error TS2406: Invalid left-hand side in 'for...in' statement.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
~
|
||||
|
||||
20
tests/baselines/reference/symbolProperty1.js
Normal file
20
tests/baselines/reference/symbolProperty1.js
Normal file
@@ -0,0 +1,20 @@
|
||||
//// [symbolProperty1.ts]
|
||||
var s: Symbol;
|
||||
var x = {
|
||||
[s]: 0,
|
||||
[s]() { },
|
||||
get [s]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [symbolProperty1.js]
|
||||
var s;
|
||||
var x = {
|
||||
[s]: 0,
|
||||
[s]() {
|
||||
},
|
||||
get [s]() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
21
tests/baselines/reference/symbolProperty1.types
Normal file
21
tests/baselines/reference/symbolProperty1.types
Normal file
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolProperty1.ts ===
|
||||
var s: Symbol;
|
||||
>s : Symbol
|
||||
>Symbol : Symbol
|
||||
|
||||
var x = {
|
||||
>x : {}
|
||||
>{ [s]: 0, [s]() { }, get [s]() { return 0; }} : {}
|
||||
|
||||
[s]: 0,
|
||||
>s : Symbol
|
||||
|
||||
[s]() { },
|
||||
>s : Symbol
|
||||
|
||||
get [s]() {
|
||||
>s : Symbol
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
20
tests/baselines/reference/symbolProperty2.js
Normal file
20
tests/baselines/reference/symbolProperty2.js
Normal file
@@ -0,0 +1,20 @@
|
||||
//// [symbolProperty2.ts]
|
||||
var s = Symbol();
|
||||
var x = {
|
||||
[s]: 0,
|
||||
[s]() { },
|
||||
get [s]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [symbolProperty2.js]
|
||||
var s = Symbol();
|
||||
var x = {
|
||||
[s]: 0,
|
||||
[s]() {
|
||||
},
|
||||
get [s]() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
22
tests/baselines/reference/symbolProperty2.types
Normal file
22
tests/baselines/reference/symbolProperty2.types
Normal file
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolProperty2.ts ===
|
||||
var s = Symbol();
|
||||
>s : Symbol
|
||||
>Symbol() : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
var x = {
|
||||
>x : {}
|
||||
>{ [s]: 0, [s]() { }, get [s]() { return 0; }} : {}
|
||||
|
||||
[s]: 0,
|
||||
>s : Symbol
|
||||
|
||||
[s]() { },
|
||||
>s : Symbol
|
||||
|
||||
get [s]() {
|
||||
>s : Symbol
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
20
tests/baselines/reference/symbolProperty3.errors.txt
Normal file
20
tests/baselines/reference/symbolProperty3.errors.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
tests/cases/conformance/es6/Symbols/symbolProperty3.ts(3,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
|
||||
tests/cases/conformance/es6/Symbols/symbolProperty3.ts(4,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
|
||||
tests/cases/conformance/es6/Symbols/symbolProperty3.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/Symbols/symbolProperty3.ts (3 errors) ====
|
||||
var s = Symbol;
|
||||
var x = {
|
||||
[s]: 0,
|
||||
~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
|
||||
[s]() { },
|
||||
~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
|
||||
get [s]() {
|
||||
~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
20
tests/baselines/reference/symbolProperty3.js
Normal file
20
tests/baselines/reference/symbolProperty3.js
Normal file
@@ -0,0 +1,20 @@
|
||||
//// [symbolProperty3.ts]
|
||||
var s = Symbol;
|
||||
var x = {
|
||||
[s]: 0,
|
||||
[s]() { },
|
||||
get [s]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [symbolProperty3.js]
|
||||
var s = Symbol;
|
||||
var x = {
|
||||
[s]: 0,
|
||||
[s]() {
|
||||
},
|
||||
get [s]() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
18
tests/baselines/reference/symbolProperty4.js
Normal file
18
tests/baselines/reference/symbolProperty4.js
Normal file
@@ -0,0 +1,18 @@
|
||||
//// [symbolProperty4.ts]
|
||||
var x = {
|
||||
[Symbol()]: 0,
|
||||
[Symbol()]() { },
|
||||
get [Symbol()]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [symbolProperty4.js]
|
||||
var x = {
|
||||
[Symbol()]: 0,
|
||||
[Symbol()]() {
|
||||
},
|
||||
get [Symbol()]() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
20
tests/baselines/reference/symbolProperty4.types
Normal file
20
tests/baselines/reference/symbolProperty4.types
Normal file
@@ -0,0 +1,20 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolProperty4.ts ===
|
||||
var x = {
|
||||
>x : {}
|
||||
>{ [Symbol()]: 0, [Symbol()]() { }, get [Symbol()]() { return 0; }} : {}
|
||||
|
||||
[Symbol()]: 0,
|
||||
>Symbol() : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
[Symbol()]() { },
|
||||
>Symbol() : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
get [Symbol()]() {
|
||||
>Symbol() : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
18
tests/baselines/reference/symbolProperty5.js
Normal file
18
tests/baselines/reference/symbolProperty5.js
Normal file
@@ -0,0 +1,18 @@
|
||||
//// [symbolProperty5.ts]
|
||||
var x = {
|
||||
[Symbol.iterator]: 0,
|
||||
[Symbol.isRegExp]() { },
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [symbolProperty5.js]
|
||||
var x = {
|
||||
[Symbol.iterator]: 0,
|
||||
[Symbol.isRegExp]() {
|
||||
},
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
23
tests/baselines/reference/symbolProperty5.types
Normal file
23
tests/baselines/reference/symbolProperty5.types
Normal file
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolProperty5.ts ===
|
||||
var x = {
|
||||
>x : { [Symbol.iterator]: number; [Symbol.isRegExp](): void; [Symbol.toStringTag]: number; }
|
||||
>{ [Symbol.iterator]: 0, [Symbol.isRegExp]() { }, get [Symbol.toStringTag]() { return 0; }} : { [Symbol.iterator]: number; [Symbol.isRegExp](): void; [Symbol.toStringTag]: number; }
|
||||
|
||||
[Symbol.iterator]: 0,
|
||||
>Symbol.iterator : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : Symbol
|
||||
|
||||
[Symbol.isRegExp]() { },
|
||||
>Symbol.isRegExp : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : Symbol
|
||||
|
||||
get [Symbol.toStringTag]() {
|
||||
>Symbol.toStringTag : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>toStringTag : Symbol
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
26
tests/baselines/reference/symbolProperty6.js
Normal file
26
tests/baselines/reference/symbolProperty6.js
Normal file
@@ -0,0 +1,26 @@
|
||||
//// [symbolProperty6.ts]
|
||||
class C {
|
||||
[Symbol.iterator] = 0;
|
||||
[Symbol.unscopables]: number;
|
||||
[Symbol.isRegExp]() { }
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [symbolProperty6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this[Symbol.iterator] = 0;
|
||||
}
|
||||
C.prototype[Symbol.isRegExp] = function () {
|
||||
};
|
||||
Object.defineProperty(C.prototype, Symbol.toStringTag, {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
27
tests/baselines/reference/symbolProperty6.types
Normal file
27
tests/baselines/reference/symbolProperty6.types
Normal file
@@ -0,0 +1,27 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolProperty6.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[Symbol.iterator] = 0;
|
||||
>Symbol.iterator : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : Symbol
|
||||
|
||||
[Symbol.unscopables]: number;
|
||||
>Symbol.unscopables : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>unscopables : Symbol
|
||||
|
||||
[Symbol.isRegExp]() { }
|
||||
>Symbol.isRegExp : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : Symbol
|
||||
|
||||
get [Symbol.toStringTag]() {
|
||||
>Symbol.toStringTag : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>toStringTag : Symbol
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
17
tests/baselines/reference/symbolProperty7.errors.txt
Normal file
17
tests/baselines/reference/symbolProperty7.errors.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
tests/cases/conformance/es6/Symbols/symbolProperty7.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
|
||||
tests/cases/conformance/es6/Symbols/symbolProperty7.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/Symbols/symbolProperty7.ts (2 errors) ====
|
||||
class C {
|
||||
[Symbol()] = 0;
|
||||
~~~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
|
||||
[Symbol()]: number;
|
||||
~~~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
|
||||
[Symbol()]() { }
|
||||
get [Symbol()]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
7
tests/baselines/reference/symbolProperty8.js
Normal file
7
tests/baselines/reference/symbolProperty8.js
Normal file
@@ -0,0 +1,7 @@
|
||||
//// [symbolProperty8.ts]
|
||||
interface I {
|
||||
[Symbol.unscopables]: number;
|
||||
[Symbol.isRegExp]();
|
||||
}
|
||||
|
||||
//// [symbolProperty8.js]
|
||||
14
tests/baselines/reference/symbolProperty8.types
Normal file
14
tests/baselines/reference/symbolProperty8.types
Normal file
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolProperty8.ts ===
|
||||
interface I {
|
||||
>I : I
|
||||
|
||||
[Symbol.unscopables]: number;
|
||||
>Symbol.unscopables : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>unscopables : Symbol
|
||||
|
||||
[Symbol.isRegExp]();
|
||||
>Symbol.isRegExp : Symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isRegExp : Symbol
|
||||
}
|
||||
9
tests/cases/conformance/es6/Symbols/symbolProperty1.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty1.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
//@target: ES6
|
||||
var s: Symbol;
|
||||
var x = {
|
||||
[s]: 0,
|
||||
[s]() { },
|
||||
get [s]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
9
tests/cases/conformance/es6/Symbols/symbolProperty2.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty2.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
//@target: ES6
|
||||
var s = Symbol();
|
||||
var x = {
|
||||
[s]: 0,
|
||||
[s]() { },
|
||||
get [s]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
9
tests/cases/conformance/es6/Symbols/symbolProperty3.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty3.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
//@target: ES6
|
||||
var s = Symbol;
|
||||
var x = {
|
||||
[s]: 0,
|
||||
[s]() { },
|
||||
get [s]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
8
tests/cases/conformance/es6/Symbols/symbolProperty4.ts
Normal file
8
tests/cases/conformance/es6/Symbols/symbolProperty4.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
//@target: ES6
|
||||
var x = {
|
||||
[Symbol()]: 0,
|
||||
[Symbol()]() { },
|
||||
get [Symbol()]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
8
tests/cases/conformance/es6/Symbols/symbolProperty5.ts
Normal file
8
tests/cases/conformance/es6/Symbols/symbolProperty5.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
//@target: ES6
|
||||
var x = {
|
||||
[Symbol.iterator]: 0,
|
||||
[Symbol.isRegExp]() { },
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
9
tests/cases/conformance/es6/Symbols/symbolProperty6.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty6.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.iterator] = 0;
|
||||
[Symbol.unscopables]: number;
|
||||
[Symbol.isRegExp]() { }
|
||||
get [Symbol.toStringTag]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
9
tests/cases/conformance/es6/Symbols/symbolProperty7.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty7.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
//@target: ES6
|
||||
class C {
|
||||
[Symbol()] = 0;
|
||||
[Symbol()]: number;
|
||||
[Symbol()]() { }
|
||||
get [Symbol()]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
5
tests/cases/conformance/es6/Symbols/symbolProperty8.ts
Normal file
5
tests/cases/conformance/es6/Symbols/symbolProperty8.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
//@target: ES6
|
||||
interface I {
|
||||
[Symbol.unscopables]: number;
|
||||
[Symbol.isRegExp]();
|
||||
}
|
||||
Reference in New Issue
Block a user