Skip to content

Commit 8325862

Browse files
committed
Fix error message
1 parent d07ed67 commit 8325862

7 files changed

+17
-17
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5827,7 +5827,7 @@ module ts {
58275827
}
58285828

58295829
// REVIEW: Users should know the type that was actually used.
5830-
error(node, Diagnostics.An_index_expression_argument_must_be_of_type_string_number_or_any);
5830+
error(node, Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any);
58315831

58325832
return unknownType;
58335833
}

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ module ts {
189189
Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
190190
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" },
191191
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
192-
An_index_expression_argument_must_be_of_type_string_number_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', or 'any'." },
192+
An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
193193
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
194194
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
195195
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@
749749
"category": "Error",
750750
"code": 2341
751751
},
752-
"An index expression argument must be of type 'string', 'number', or 'any'.": {
752+
"An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.": {
753753
"category": "Error",
754754
"code": 2342
755755
},

tests/baselines/reference/indexTypeCheck.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type '
55
tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
66
tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter.
77
tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string', 'number', or 'symbol'.
8-
tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
8+
tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
99

1010

1111
==== tests/cases/compiler/indexTypeCheck.ts (8 errors) ====
@@ -75,7 +75,7 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression
7575

7676
yellow[blue]; // error
7777
~~~~~~~~~~~~
78-
!!! error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
78+
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
7979

8080
var x:number[];
8181
x[0];

tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,17): error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
1+
tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,17): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
22
tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,63): error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'?
3-
tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,33): error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
3+
tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,33): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
44
tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,79): error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'?
55

66

@@ -59,12 +59,12 @@ tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,79): error TS
5959
// ElementAccessExpressions can only contain one expression. There should be a parse error here.
6060
var foods = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)];
6161
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62-
!!! error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
62+
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
6363
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6464
!!! error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'?
6565
var foods2: MonsterFood[] = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)];
6666
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67-
!!! error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
67+
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
6868
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6969
!!! error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'?
7070

tests/baselines/reference/propertyAccess.errors.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(45,14): error TS2339: Property 'qqq' does not exist on type '{ 10: string; x: string; y: number; z: { n: string; m: number; o: () => boolean; }; 'literal property': number; }'.
2-
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(80,10): error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
3-
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(117,10): error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
4-
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
2+
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(80,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
3+
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(117,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
4+
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
55

66

77
==== tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts (4 errors) ====
@@ -88,7 +88,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er
8888
// Bracket notation property access using value of other type on type with numeric index signature and no string index signature
8989
var ll = numIndex[someObject]; // Error
9090
~~~~~~~~~~~~~~~~~~~~
91-
!!! error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
91+
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
9292

9393
// Bracket notation property access using string value on type with string index signature and no numeric index signature
9494
var mm = strIndex['N'];
@@ -127,7 +127,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er
127127
// Bracket notation property access using values of other types on type with no index signatures
128128
var uu = noIndex[someObject]; // Error
129129
~~~~~~~~~~~~~~~~~~~
130-
!!! error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
130+
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
131131

132132
// Bracket notation property access using numeric value on type with numeric index signature and string index signature
133133
var vv = noIndex[32];
@@ -152,7 +152,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er
152152
// Bracket notation property access using value of other type on type with numeric index signature and no string index signature and string index signature
153153
var zzzz = bothIndex[someObject]; // Error
154154
~~~~~~~~~~~~~~~~~~~~~
155-
!!! error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
155+
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
156156

157157
var x1 = numIndex[stringOrNumber];
158158
var x1: any;

tests/baselines/reference/symbolProperty53.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/conformance/es6/Symbols/symbolProperty53.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
2-
tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
2+
tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
33

44

55
==== tests/cases/conformance/es6/Symbols/symbolProperty53.ts (2 errors) ====
@@ -11,4 +11,4 @@ tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An i
1111

1212
obj[Symbol.for];
1313
~~~~~~~~~~~~~~~
14-
!!! error TS2342: An index expression argument must be of type 'string', 'number', or 'any'.
14+
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.

0 commit comments

Comments
 (0)