Skip to content

Commit b30d8f3

Browse files
committed
Change computed property error messages to be about symbols
1 parent 11d75ef commit b30d8f3

File tree

43 files changed

+143
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+143
-143
lines changed

src/compiler/checker.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -10803,17 +10803,17 @@ module ts {
1080310803
// and accessors are not allowed in ambient contexts in general,
1080410804
// so this error only really matters for methods.
1080510805
if (isInAmbientContext(node)) {
10806-
return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context);
10806+
return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_Symbol);
1080710807
}
1080810808
else if (!node.body) {
10809-
return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_method_overloads);
10809+
return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_Symbol);
1081010810
}
1081110811
}
1081210812
else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) {
10813-
return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces);
10813+
return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_Symbol);
1081410814
}
1081510815
else if (node.parent.kind === SyntaxKind.TypeLiteral) {
10816-
return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_type_literals);
10816+
return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_Symbol);
1081710817
}
1081810818
}
1081910819

@@ -11084,17 +11084,17 @@ module ts {
1108411084
function checkGrammarProperty(node: PropertyDeclaration) {
1108511085
if (node.parent.kind === SyntaxKind.ClassDeclaration) {
1108611086
if (checkGrammarForInvalidQuestionMark(node, node.questionToken, Diagnostics.A_class_member_cannot_be_declared_optional) ||
11087-
checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_class_property_declarations)) {
11087+
checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_Symbol)) {
1108811088
return true;
1108911089
}
1109011090
}
1109111091
else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) {
11092-
if (checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces)) {
11092+
if (checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_Symbol)) {
1109311093
return true;
1109411094
}
1109511095
}
1109611096
else if (node.parent.kind === SyntaxKind.TypeLiteral) {
11097-
if (checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_type_literals)) {
11097+
if (checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_Symbol)) {
1109811098
return true;
1109911099
}
1110011100
}

src/compiler/diagnosticInformationMap.generated.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ module ts {
123123
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." },
124124
yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." },
125125
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." },
126-
Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in an ambient context." },
127-
Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in class property declarations." },
126+
A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_Symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in Symbol." },
127+
A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_Symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in Symbol." },
128128
Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." },
129-
Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in method overloads." },
130-
Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces." },
131-
Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in type literals." },
129+
A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_Symbol: { code: 1168, category: DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in Symbol." },
130+
A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_Symbol: { code: 1169, category: DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in Symbol." },
131+
A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_Symbol: { code: 1170, category: DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in Symbol." },
132132
A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." },
133133
extends_clause_already_seen: { code: 1172, category: DiagnosticCategory.Error, key: "'extends' clause already seen." },
134134
extends_clause_must_precede_implements_clause: { code: 1173, category: DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." },

src/compiler/diagnosticMessages.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -483,27 +483,27 @@
483483
"category": "Error",
484484
"code": 1164
485485
},
486-
"Computed property names are not allowed in an ambient context.": {
486+
"A computed property name in an ambient context must directly refer to a built-in Symbol.": {
487487
"category": "Error",
488488
"code": 1165
489489
},
490-
"Computed property names are not allowed in class property declarations.": {
490+
"A computed property name in a class property declaration must directly refer to a built-in Symbol.": {
491491
"category": "Error",
492492
"code": 1166
493493
},
494494
"Computed property names are only available when targeting ECMAScript 6 and higher.": {
495495
"category": "Error",
496496
"code": 1167
497497
},
498-
"Computed property names are not allowed in method overloads.": {
498+
"A computed property name in a method overload must directly refer to a built-in Symbol.": {
499499
"category": "Error",
500500
"code": 1168
501501
},
502-
"Computed property names are not allowed in interfaces.": {
502+
"A computed property name in an interface must directly refer to a built-in Symbol.": {
503503
"category": "Error",
504504
"code": 1169
505505
},
506-
"Computed property names are not allowed in type literals.": {
506+
"A computed property name in a type literal must directly refer to a built-in Symbol.": {
507507
"category": "Error",
508508
"code": 1170
509509
},
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(5,5): error TS1166: Computed property names are not allowed in class property declarations.
2-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(6,5): error TS1166: Computed property names are not allowed in class property declarations.
3-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(7,12): error TS1166: Computed property names are not allowed in class property declarations.
4-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(8,5): error TS1166: Computed property names are not allowed in class property declarations.
5-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(9,5): error TS1166: Computed property names are not allowed in class property declarations.
6-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(10,12): error TS1166: Computed property names are not allowed in class property declarations.
7-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(11,5): error TS1166: Computed property names are not allowed in class property declarations.
8-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(12,5): error TS1166: Computed property names are not allowed in class property declarations.
9-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(13,12): error TS1166: Computed property names are not allowed in class property declarations.
10-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(14,5): error TS1166: Computed property names are not allowed in class property declarations.
11-
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(15,12): error TS1166: Computed property names are not allowed in class property declarations.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(5,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
2+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(6,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
3+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(7,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
4+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
5+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
6+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(10,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
7+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(11,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
8+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(12,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
9+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(13,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
10+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(14,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
11+
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(15,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
1212

1313

1414
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts (11 errors) ====
@@ -18,35 +18,35 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(15,12)
1818
class C {
1919
[s]: number;
2020
~~~
21-
!!! error TS1166: Computed property names are not allowed in class property declarations.
21+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
2222
[n] = n;
2323
~~~
24-
!!! error TS1166: Computed property names are not allowed in class property declarations.
24+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
2525
static [s + s]: string;
2626
~~~~~~~
27-
!!! error TS1166: Computed property names are not allowed in class property declarations.
27+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
2828
[s + n] = 2;
2929
~~~~~~~
30-
!!! error TS1166: Computed property names are not allowed in class property declarations.
30+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
3131
[+s]: typeof s;
3232
~~~~
33-
!!! error TS1166: Computed property names are not allowed in class property declarations.
33+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
3434
static [""]: number;
3535
~~~~
36-
!!! error TS1166: Computed property names are not allowed in class property declarations.
36+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
3737
[0]: number;
3838
~~~
39-
!!! error TS1166: Computed property names are not allowed in class property declarations.
39+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
4040
[a]: number;
4141
~~~
42-
!!! error TS1166: Computed property names are not allowed in class property declarations.
42+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
4343
static [<any>true]: number;
4444
~~~~~~~~~~~
45-
!!! error TS1166: Computed property names are not allowed in class property declarations.
45+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
4646
[`hello bye`] = 0;
4747
~~~~~~~~~~~~~
48-
!!! error TS1166: Computed property names are not allowed in class property declarations.
48+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
4949
static [`hello ${a} bye`] = 0
5050
~~~~~~~~~~~~~~~~~~
51-
!!! error TS1166: Computed property names are not allowed in class property declarations.
51+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
5252
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNames35.ts(4,5): error TS1169: Computed property names are not allowed in interfaces.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNames35.ts(4,5): error TS1169: A computed property name in an interface must directly refer to a built-in Symbol.
22
tests/cases/conformance/es6/computedProperties/computedPropertyNames35.ts(4,10): error TS2466: A computed property name cannot reference a type parameter from its containing type.
33

44

@@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames35.ts(4,10):
88
bar(): string;
99
[foo<T>()](): void;
1010
~~~~~~~~~~
11-
!!! error TS1169: Computed property names are not allowed in interfaces.
11+
!!! error TS1169: A computed property name in an interface must directly refer to a built-in Symbol.
1212
~
1313
!!! error TS2466: A computed property name cannot reference a type parameter from its containing type.
1414
}

tests/baselines/reference/computedPropertyNames42.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNames42.ts(8,5): error TS1166: Computed property names are not allowed in class property declarations.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNames42.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
22
tests/cases/conformance/es6/computedProperties/computedPropertyNames42.ts(8,5): error TS2411: Property '[""]' of type 'Foo' is not assignable to string index type 'Foo2'.
33

44

@@ -12,7 +12,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames42.ts(8,5):
1212
// Computed properties
1313
[""]: Foo;
1414
~~~~
15-
!!! error TS1166: Computed property names are not allowed in class property declarations.
15+
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in Symbol.
1616
~~~~~~~~~~
1717
!!! error TS2411: Property '[""]' of type 'Foo' is not assignable to string index type 'Foo2'.
1818
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3.ts(2,5): error TS1169: Computed property names are not allowed in interfaces.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in Symbol.
22

33

44
==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3.ts (1 errors) ====
55
interface I {
66
["" + ""](): void;
77
~~~~~~~~~
8-
!!! error TS1169: Computed property names are not allowed in interfaces.
8+
!!! error TS1169: A computed property name in an interface must directly refer to a built-in Symbol.
99
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4.ts(2,5): error TS1170: Computed property names are not allowed in type literals.
1+
tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4.ts(2,5): error TS1170: A computed property name in a type literal must directly refer to a built-in Symbol.
22

33

44
==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4.ts (1 errors) ====
55
var v: {
66
["" + ""](): void;
77
~~~~~~~~~
8-
!!! error TS1170: Computed property names are not allowed in type literals.
8+
!!! error TS1170: A computed property name in a type literal must directly refer to a built-in Symbol.
99
}

0 commit comments

Comments
 (0)