Skip to content

Commit 30892af

Browse files
committed
Change computed property error message to mention Symbols
1 parent f344654 commit 30892af

12 files changed

+63
-63
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5517,7 +5517,7 @@ module ts {
55175517
// This will allow types number, string, or any. It will also allow enums, the unknown
55185518
// type, and any union of these types (like string | number).
55195519
if (!isTypeOfKind(links.resolvedType, TypeFlags.Any | TypeFlags.NumberLike | TypeFlags.StringLike)) {
5520-
error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_or_any);
5520+
error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_Symbol_or_any);
55215521
}
55225522
}
55235523

src/compiler/diagnosticInformationMap.generated.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ module ts {
300300
Type_0_is_not_an_array_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type." },
301301
A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" },
302302
A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." },
303-
A_computed_property_name_must_be_of_type_string_number_or_any: { code: 2464, category: DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', or 'any'." },
303+
A_computed_property_name_must_be_of_type_string_number_Symbol_or_any: { code: 2464, category: DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'Symbol', or 'any'." },
304304
this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." },
305305
super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." },
306306
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." },

src/compiler/diagnosticMessages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@
11931193
"category": "Error",
11941194
"code": 2463
11951195
},
1196-
"A computed property name must be of type 'string', 'number', or 'any'.": {
1196+
"A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.": {
11971197
"category": "Error",
11981198
"code": 2464
11991199
},
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(3,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
2-
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
3-
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(5,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
4-
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(6,12): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
5-
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
6-
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(8,12): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(3,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2+
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
3+
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(5,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
4+
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(6,12): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
5+
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
6+
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(8,12): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
77

88

99
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts (6 errors) ====
1010
var b: boolean;
1111
class C {
1212
[b]() {}
1313
~~~
14-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
14+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1515
static [true]() { }
1616
~~~~~~
17-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
17+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1818
[[]]() { }
1919
~~~~
20-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
20+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2121
static [{}]() { }
2222
~~~~
23-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
23+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2424
[undefined]() { }
2525
~~~~~~~~~~~
26-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
26+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2727
static [null]() { }
2828
~~~~~~
29-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
29+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
3030
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts(6,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
2-
tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts(6,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2+
tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
33

44

55
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts (2 errors) ====
@@ -10,8 +10,8 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts(7,5):
1010
[p1]() { }
1111
[p2]() { }
1212
~~~~
13-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
13+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1414
[p3]() { }
1515
~~~~
16-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
16+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1717
}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(3,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
2-
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(4,16): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
3-
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
4-
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
5-
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
6-
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(8,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(3,9): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2+
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(4,16): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
3+
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
4+
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
5+
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
6+
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(8,9): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
77

88

99
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts (6 errors) ====
1010
var b: boolean;
1111
class C {
1212
get [b]() { return 0;}
1313
~~~
14-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
14+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1515
static set [true](v) { }
1616
~~~~~~
17-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
17+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1818
get [[]]() { return 0; }
1919
~~~~
20-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
20+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2121
set [{}](v) { }
2222
~~~~
23-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
23+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2424
static get [undefined]() { return 0; }
2525
~~~~~~~~~~~
26-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
26+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2727
set [null](v) { }
2828
~~~~~~
29-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
29+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
3030
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
22
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
3-
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
4-
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
3+
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
4+
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
55
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
6-
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
6+
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
77

88

99
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (6 errors) ====
@@ -12,19 +12,19 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16):
1212
[0 + 1]() { }
1313
static [() => { }]() { }
1414
~~~~~~~~~~~
15-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
15+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1616
get [delete id]() { }
1717
~~~~~~~~~~~
1818
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
1919
~~~~~~~~~~~
20-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
20+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2121
set [[0, 1]](v) { }
2222
~~~~~~~~
23-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
23+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2424
static get [<String>""]() { }
2525
~~~~~~~~~~~~
2626
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
2727
~~~~~~~~~~~~
28-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
28+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2929
static set [id.toString()](v) { }
3030
}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(3,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
2-
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(4,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
3-
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(5,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
4-
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(6,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
5-
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
6-
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(8,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(3,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2+
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(4,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
3+
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(5,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
4+
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(6,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
5+
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
6+
tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts(8,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
77

88

99
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames5.ts (6 errors) ====
1010
var b: boolean;
1111
var v = {
1212
[b]: 0,
1313
~~~
14-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
14+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1515
[true]: 1,
1616
~~~~~~
17-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
17+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1818
[[]]: 0,
1919
~~~~
20-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
20+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2121
[{}]: 0,
2222
~~~~
23-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
23+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2424
[undefined]: undefined,
2525
~~~~~~~~~~~
26-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
26+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2727
[null]: null
2828
~~~~~~
29-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
29+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
3030
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNames6.ts(6,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
2-
tests/cases/conformance/es6/computedProperties/computedPropertyNames6.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNames6.ts(6,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
2+
tests/cases/conformance/es6/computedProperties/computedPropertyNames6.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
33

44

55
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames6.ts (2 errors) ====
@@ -10,8 +10,8 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames6.ts(7,5): e
1010
[p1]: 0,
1111
[p2]: 1,
1212
~~~~
13-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
13+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1414
[p3]: 2
1515
~~~~
16-
!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'.
16+
!!! error TS2464: A computed property name must be of type 'string', 'number', 'Symbol', or 'any'.
1717
}

0 commit comments

Comments
 (0)