Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
11d75ef
Allow Symbol indexer in ES6
JsonFreeman Jan 26, 2015
b30d8f3
Change computed property error messages to be about symbols
JsonFreeman Jan 28, 2015
39952b1
Syntactically allow computed properties everywhere if the name looks …
JsonFreeman Jan 28, 2015
d788624
Move hasDynamicName to utilities.ts
JsonFreeman Jan 28, 2015
07f3641
Update hasDynamicName to take well known symbols into account
JsonFreeman Jan 28, 2015
f344654
Add named property symbol for known Symbol properties
JsonFreeman Jan 28, 2015
30892af
Change computed property error message to mention Symbols
JsonFreeman Jan 29, 2015
9cb38fb
Create global Symbol type
JsonFreeman Jan 30, 2015
25fcbe2
Change certain hasDynamicName checks to check the SyntaxKind instead
JsonFreeman Jan 30, 2015
b60fa14
Add tests for operators with symbol operand
JsonFreeman Jan 30, 2015
779661c
Add tests for symbol properties
JsonFreeman Feb 2, 2015
95af997
Accept correct baselines for symbol property tests
JsonFreeman Feb 3, 2015
e508bf7
Add symbol keyword
JsonFreeman Feb 3, 2015
ebdd96b
Update tests to use new symbol keyword
JsonFreeman Feb 3, 2015
e346b70
Change isTypeOfKind calls to pass symbol TypeFlag when needed
JsonFreeman Feb 4, 2015
59a704e
Rename references in es6.d.ts from Symbol to symbol
JsonFreeman Feb 4, 2015
d793658
Change Symbol to symbol in error messages
JsonFreeman Feb 4, 2015
2d16474
Fix expression checking for symbols
JsonFreeman Feb 5, 2015
6a6c03b
Fix error message wording
JsonFreeman Feb 5, 2015
92617f5
Don't pass prop.name directly for error reporting
JsonFreeman Feb 5, 2015
fbeadbc
Add test for new Symbol()
JsonFreeman Feb 5, 2015
9f39a53
Make Symbol the apparent type of symbol
JsonFreeman Feb 5, 2015
df826de
symbols in type guards
JsonFreeman Feb 5, 2015
d07ed67
Support indexing with known symbols
JsonFreeman Feb 6, 2015
8325862
Fix error message
JsonFreeman Feb 6, 2015
3834edd
Refactor part of getPropertyNameForIndexedAccess into checkSymbolName…
JsonFreeman Feb 6, 2015
4c09ccd
Check that Symbol properties are proper, and support downlevel type c…
JsonFreeman Feb 7, 2015
3560442
Declaration emit for symbol properties
JsonFreeman Feb 7, 2015
2f3c32a
Navigation bar support for symbols
JsonFreeman Feb 7, 2015
eb50619
Disable symbol indexer
JsonFreeman Feb 7, 2015
52cb13e
Uncomment symbol properties in es6.d.ts
JsonFreeman Feb 7, 2015
75382c1
Accept baselines after rebase
JsonFreeman Feb 7, 2015
18276e5
Address feedback from @yuit
JsonFreeman Feb 11, 2015
a94e61b
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
JsonFreeman Feb 11, 2015
486cebd
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
JsonFreeman Feb 12, 2015
4942c5f
Address feedback
JsonFreeman Feb 13, 2015
9c273d8
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
JsonFreeman Feb 13, 2015
65d831e
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
JsonFreeman Feb 16, 2015
ac829a8
Error for naming an interface 'symbol'
JsonFreeman Feb 16, 2015
7d7d54f
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
JsonFreeman Feb 16, 2015
935c602
Rebaseline after merge
JsonFreeman Feb 16, 2015
59dc7d3
Address feedback
JsonFreeman Feb 17, 2015
dd6a129
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
JsonFreeman Feb 17, 2015
47404bc
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
JsonFreeman Feb 18, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create global Symbol type
  • Loading branch information
JsonFreeman committed Feb 7, 2015
commit 9cb38fb5f2cf88fc39773f59454a3664ffbbccfc
81 changes: 58 additions & 23 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ module ts {
var globals: SymbolTable = {};

var globalArraySymbol: Symbol;
var globalESSymbolConstructorSymbol: Symbol;

var globalObjectType: ObjectType;
var globalFunctionType: ObjectType;
Expand All @@ -93,6 +94,8 @@ module ts {
var globalBooleanType: ObjectType;
var globalRegExpType: ObjectType;
var globalTemplateStringsArrayType: ObjectType;
var globalESSymbolType: ObjectType;
var globalESSymbolConstructorType: ObjectType;

var anyArrayType: Type;

Expand Down Expand Up @@ -3005,12 +3008,20 @@ module ts {
return <ObjectType>type;
}

function getGlobalSymbol(name: string): Symbol {
return resolveName(undefined, name, SymbolFlags.Type, Diagnostics.Cannot_find_global_type_0, name);
function getGlobalValueSymbol(name: string): Symbol {
return getGlobalSymbol(name, SymbolFlags.Value, Diagnostics.Cannot_find_global_value_0);
}

function getGlobalTypeSymbol(name: string): Symbol {
return getGlobalSymbol(name, SymbolFlags.Type, Diagnostics.Cannot_find_global_type_0);
}

function getGlobalSymbol(name: string, meaning: SymbolFlags, diagnostic: DiagnosticMessage): Symbol {
return resolveName(undefined, name, meaning, diagnostic, name);
}

function getGlobalType(name: string): ObjectType {
return getTypeOfGlobalSymbol(getGlobalSymbol(name), 0);
return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), 0);
}

function createArrayType(elementType: Type): Type {
Expand Down Expand Up @@ -5481,7 +5492,7 @@ module ts {
function isNumericComputedName(name: ComputedPropertyName): boolean {
// It seems odd to consider an expression of type Any to result in a numeric name,
// but this behavior is consistent with checkIndexedAccess
return isTypeOfKind(checkComputedPropertyName(name), TypeFlags.Any | TypeFlags.NumberLike);
return isTypeOfKind(checkComputedPropertyName(name), TypeFlags.Any | TypeFlags.NumberLike, /*includeESSymbols*/ false);
}

function isNumericLiteralName(name: string) {
Expand Down Expand Up @@ -5514,9 +5525,9 @@ module ts {
if (!links.resolvedType) {
links.resolvedType = checkExpression(node.expression);

// This will allow types number, string, or any. It will also allow enums, the unknown
// This will allow types number, string, Symbol or any. It will also allow enums, the unknown
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this both symbol and Symbol?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, should be symbol. Thanks

// type, and any union of these types (like string | number).
if (!isTypeOfKind(links.resolvedType, TypeFlags.Any | TypeFlags.NumberLike | TypeFlags.StringLike)) {
if (!isTypeOfKind(links.resolvedType, TypeFlags.Any | TypeFlags.NumberLike | TypeFlags.StringLike, /*includeESSymbols*/ true)) {
error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_Symbol_or_any);
}
}
Expand Down Expand Up @@ -5781,10 +5792,10 @@ module ts {
}

// Check for compatible indexer types.
if (isTypeOfKind(indexType, TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike)) {
if (isTypeOfKind(indexType, TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike, /*includeESSymbols*/ true)) {

// Try to use a number indexer.
if (isTypeOfKind(indexType, TypeFlags.Any | TypeFlags.NumberLike)) {
if (isTypeOfKind(indexType, TypeFlags.Any | TypeFlags.NumberLike, /*includeESSymbols*/ false)) {
var numberIndexType = getIndexTypeOfType(objectType, IndexKind.Number);
if (numberIndexType) {
return numberIndexType;
Expand Down Expand Up @@ -6722,7 +6733,7 @@ module ts {
}

function checkArithmeticOperandType(operand: Node, type: Type, diagnostic: DiagnosticMessage): boolean {
if (!isTypeOfKind(type, TypeFlags.Any | TypeFlags.NumberLike)) {
if (!isTypeOfKind(type, TypeFlags.Any | TypeFlags.NumberLike, /*includeESSymbols*/ false)) {
error(operand, diagnostic);
return false;
}
Expand Down Expand Up @@ -6874,19 +6885,28 @@ module ts {
}

// Return true if type has the given flags, or is a union type composed of types that all have those flags
function isTypeOfKind(type: Type, kind: TypeFlags): boolean {
// If include includeESSymbols is true, then check if the type (or union constituents) is an ESSymbol
// if it does not match the kind. This is necessary because ESSymbol has no corresponding flag.
function isTypeOfKind(type: Type, kind: TypeFlags, includeESSymbols: boolean): boolean {
if (type.flags & kind) {
return true;
}
if (type.flags & TypeFlags.Union) {
var types = (<UnionType>type).types;
for (var i = 0; i < types.length; i++) {
if (!(types[i].flags & kind)) {
return false;
if (types[i].flags & kind) {
continue;
}
if (includeESSymbols && types[i] === globalESSymbolType) {
continue;
}
return false;
}
return true;
}
if (includeESSymbols) {
return type === globalESSymbolType;
}
return false;
}

Expand All @@ -6904,7 +6924,11 @@ module ts {
// and the right operand to be of type Any or a subtype of the 'Function' interface type.
// The result is always of the Boolean primitive type.
// NOTE: do not raise error if leftType is unknown as related error was already reported
if (isTypeOfKind(leftType, TypeFlags.Primitive)) {
//
// The reason for globalESSymbolType !== unknownType is that if the type is unknownType, we don't want to error.
// If the globalESSymbolType is also unknownType, then by including globalESSymbolType, we will error
// on unknownType, because transitively, type will be the same as globalESSymbolType.
if (isTypeOfKind(leftType, TypeFlags.Primitive, /*includeESSymbols*/ globalESSymbolType !== unknownType)) {
error(node.left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
// NOTE: do not raise error if right is unknown as related error was already reported
Expand All @@ -6919,10 +6943,10 @@ module ts {
// The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type,
// and the right operand to be of type Any, an object type, or a type parameter type.
// The result is always of the Boolean primitive type.
if (!isTypeOfKind(leftType, TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike)) {
if (!isTypeOfKind(leftType, TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike, /*includeESSymbols*/ true)) {
error(node.left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number);
}
if (!isTypeOfKind(rightType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
if (!isTypeOfKind(rightType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter, /*includeESSymbols*/ false)) {
error(node.right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
return booleanType;
Expand Down Expand Up @@ -7083,12 +7107,12 @@ module ts {
if (rightType.flags & (TypeFlags.Undefined | TypeFlags.Null)) rightType = leftType;

var resultType: Type;
if (isTypeOfKind(leftType, TypeFlags.NumberLike) && isTypeOfKind(rightType, TypeFlags.NumberLike)) {
if (isTypeOfKind(leftType, TypeFlags.NumberLike, /*includeESSymbols*/ false) && isTypeOfKind(rightType, TypeFlags.NumberLike, /*includeESSymbols*/ false)) {
// Operands of an enum type are treated as having the primitive type Number.
// If both operands are of the Number primitive type, the result is of the Number primitive type.
resultType = numberType;
}
else if (isTypeOfKind(leftType, TypeFlags.StringLike) || isTypeOfKind(rightType, TypeFlags.StringLike)) {
else if (isTypeOfKind(leftType, TypeFlags.StringLike, /*includeESSymbols*/ false) || isTypeOfKind(rightType, TypeFlags.StringLike, /*includeESSymbols*/ false)) {
// If one or both operands are of the String primitive type, the result is of the String primitive type.
resultType = stringType;
}
Expand Down Expand Up @@ -8454,7 +8478,7 @@ module ts {
// and Expr must be an expression of type Any, an object type, or a type parameter type.
var varExpr = <Expression>node.initializer;
var exprType = checkExpression(varExpr);
if (exprType !== anyType && exprType !== stringType) {
if (!isTypeOfKind(exprType, TypeFlags.Any | TypeFlags.StringLike, /*includeESSymbols*/ true)) {
error(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
}
else {
Expand All @@ -8466,7 +8490,7 @@ module ts {
var exprType = checkExpression(node.expression);
// unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
// in this case error about missing name is already reported - do not report extra one
if (!isTypeOfKind(exprType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
if (!isTypeOfKind(exprType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter, /*includeESSymbols*/ false)) {
error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
}

Expand Down Expand Up @@ -10251,19 +10275,30 @@ module ts {
getSymbolLinks(unknownSymbol).type = unknownType;
globals[undefinedSymbol.name] = undefinedSymbol;
// Initialize special types
globalArraySymbol = getGlobalSymbol("Array");
globalArraySymbol = getGlobalTypeSymbol("Array");
globalArrayType = getTypeOfGlobalSymbol(globalArraySymbol, 1);
globalObjectType = getGlobalType("Object");
globalFunctionType = getGlobalType("Function");
globalStringType = getGlobalType("String");
globalNumberType = getGlobalType("Number");
globalBooleanType = getGlobalType("Boolean");
globalRegExpType = getGlobalType("RegExp");

// If we're in ES6 mode, load the TemplateStringsArray.
// Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios.
globalTemplateStringsArrayType = languageVersion >= ScriptTarget.ES6
? getGlobalType("TemplateStringsArray")
: unknownType;
if (languageVersion >= ScriptTarget.ES6) {
globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray");
globalESSymbolType = getGlobalType("Symbol");
globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol");
globalESSymbolConstructorType = getTypeOfGlobalSymbol(globalESSymbolConstructorSymbol, /*arity*/ 0);
}
else {
globalTemplateStringsArrayType = unknownType;
globalESSymbolType = unknownType;
globalESSymbolConstructorSymbol = unknownSymbol;
globalESSymbolConstructorType = unknownType;
}

anyArrayType = createArrayType(anyType);
}

Expand Down
1 change: 1 addition & 0 deletions src/compiler/diagnosticInformationMap.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ module ts {
this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." },
super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." },
A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2466, category: DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." },
Cannot_find_global_value_0: { code: 2468, category: DiagnosticCategory.Error, key: "Cannot find global value '{0}'." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,10 @@
"category": "Error",
"code": 2466
},
"Cannot find global value '{0}'.": {
"category": "Error",
"code": 2468
},

"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
Expand Down
5 changes: 1 addition & 4 deletions tests/baselines/reference/parserForStatement3.errors.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
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 '_'.
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts(1,23): error TS2304: Cannot find name 'a'.
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 '_'.
~
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/parserForStatement6.errors.txt
Original file line number Diff line number Diff line change
@@ -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'.


Expand All @@ -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'.
}
4 changes: 2 additions & 2 deletions tests/baselines/reference/parserForStatement7.errors.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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'.


==== 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'.
~
Expand Down
20 changes: 20 additions & 0 deletions tests/baselines/reference/symbolProperty1.js
Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 0 deletions tests/baselines/reference/symbolProperty1.types
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions tests/baselines/reference/symbolProperty2.js
Original file line number Diff line number Diff line change
@@ -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 changes: 22 additions & 0 deletions tests/baselines/reference/symbolProperty2.types
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions tests/baselines/reference/symbolProperty3.errors.txt
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading