From 03f8403e85a54a58a5b5597e0c25fced714bfbd5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 31 Oct 2016 15:29:02 -0700 Subject: [PATCH] Accept new baselines --- .../constDeclarations-access3.errors.txt | 6 +- .../constDeclarations-access4.errors.txt | 6 +- .../constDeclarations-access5.errors.txt | 6 +- .../constEnumBadPropertyNames.errors.txt | 4 +- .../reference/constIndexedAccess.types | 8 +-- .../decrementOperatorWithEnumType.errors.txt | 16 ++--- ...externalModuleImmutableBindings.errors.txt | 48 +++++++------- .../for-inStatementsArrayErrors.errors.txt | 4 +- .../incrementOperatorWithEnumType.errors.txt | 12 ++-- .../reference/indexTypeCheck.errors.txt | 6 +- .../indexWithUndefinedAndNull.errors.txt | 28 ++++++++ ...ndefinedAndNullStrictNullChecks.errors.txt | 24 +++---- .../reference/noImplicitAnyForIn.errors.txt | 8 +-- .../noImplicitAnyIndexing.errors.txt | 16 ++--- ...mplicitAnyStringIndexerOnObject.errors.txt | 4 +- ...eationOfElementAccessExpression.errors.txt | 12 ++-- ...ctTypeWithStringNamedNumericProperty.types | 64 +++++++++---------- .../reference/parserForStatement2.errors.txt | 8 ++- .../reference/propertyAccess.errors.txt | 23 ++++--- .../reference/readonlyMembers.errors.txt | 8 +-- .../superSymbolIndexedAccess3.errors.txt | 6 +- .../reference/symbolProperty53.errors.txt | 6 +- 22 files changed, 180 insertions(+), 143 deletions(-) create mode 100644 tests/baselines/reference/indexWithUndefinedAndNull.errors.txt diff --git a/tests/baselines/reference/constDeclarations-access3.errors.txt b/tests/baselines/reference/constDeclarations-access3.errors.txt index 43864d5274d..03ea2d29bba 100644 --- a/tests/baselines/reference/constDeclarations-access3.errors.txt +++ b/tests/baselines/reference/constDeclarations-access3.errors.txt @@ -15,7 +15,7 @@ tests/cases/compiler/constDeclarations-access3.ts(22,3): error TS2540: Cannot as tests/cases/compiler/constDeclarations-access3.ts(23,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/constDeclarations-access3.ts(24,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/constDeclarations-access3.ts(26,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/constDeclarations-access3.ts(28,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/compiler/constDeclarations-access3.ts(28,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. ==== tests/cases/compiler/constDeclarations-access3.ts (18 errors) ==== @@ -81,8 +81,8 @@ tests/cases/compiler/constDeclarations-access3.ts(28,1): error TS2450: Left-hand !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. M["x"] = 0; - ~~~~~~ -!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. // OK var a = M.x + 1; diff --git a/tests/baselines/reference/constDeclarations-access4.errors.txt b/tests/baselines/reference/constDeclarations-access4.errors.txt index d9b63941c76..a4111c2d702 100644 --- a/tests/baselines/reference/constDeclarations-access4.errors.txt +++ b/tests/baselines/reference/constDeclarations-access4.errors.txt @@ -15,7 +15,7 @@ tests/cases/compiler/constDeclarations-access4.ts(22,3): error TS2540: Cannot as tests/cases/compiler/constDeclarations-access4.ts(23,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/constDeclarations-access4.ts(24,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/constDeclarations-access4.ts(26,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/constDeclarations-access4.ts(28,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/compiler/constDeclarations-access4.ts(28,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. ==== tests/cases/compiler/constDeclarations-access4.ts (18 errors) ==== @@ -81,8 +81,8 @@ tests/cases/compiler/constDeclarations-access4.ts(28,1): error TS2450: Left-hand !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. M["x"] = 0; - ~~~~~~ -!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. // OK var a = M.x + 1; diff --git a/tests/baselines/reference/constDeclarations-access5.errors.txt b/tests/baselines/reference/constDeclarations-access5.errors.txt index 72f28b992a9..316465e80b8 100644 --- a/tests/baselines/reference/constDeclarations-access5.errors.txt +++ b/tests/baselines/reference/constDeclarations-access5.errors.txt @@ -15,7 +15,7 @@ tests/cases/compiler/constDeclarations_access_2.ts(18,3): error TS2540: Cannot a tests/cases/compiler/constDeclarations_access_2.ts(19,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/constDeclarations_access_2.ts(20,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/constDeclarations_access_2.ts(22,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/compiler/constDeclarations_access_2.ts(24,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. ==== tests/cases/compiler/constDeclarations_access_2.ts (18 errors) ==== @@ -77,8 +77,8 @@ tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-han !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. m["x"] = 0; - ~~~~~~ -!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. // OK var a = m.x + 1; diff --git a/tests/baselines/reference/constEnumBadPropertyNames.errors.txt b/tests/baselines/reference/constEnumBadPropertyNames.errors.txt index f2330617dea..09610ca24e5 100644 --- a/tests/baselines/reference/constEnumBadPropertyNames.errors.txt +++ b/tests/baselines/reference/constEnumBadPropertyNames.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/constEnumBadPropertyNames.ts(2,11): error TS2479: Property 'B' does not exist on 'const' enum 'E'. +tests/cases/compiler/constEnumBadPropertyNames.ts(2,11): error TS2339: Property 'B' does not exist on type 'typeof E'. ==== tests/cases/compiler/constEnumBadPropertyNames.ts (1 errors) ==== const enum E { A } var x = E["B"] ~~~ -!!! error TS2479: Property 'B' does not exist on 'const' enum 'E'. \ No newline at end of file +!!! error TS2339: Property 'B' does not exist on type 'typeof E'. \ No newline at end of file diff --git a/tests/baselines/reference/constIndexedAccess.types b/tests/baselines/reference/constIndexedAccess.types index 0740a6efc67..9e08cf08f49 100644 --- a/tests/baselines/reference/constIndexedAccess.types +++ b/tests/baselines/reference/constIndexedAccess.types @@ -76,16 +76,16 @@ enum numbersNotConst { } let s3 = test[numbersNotConst.zero]; ->s3 : any ->test[numbersNotConst.zero] : any +>s3 : string +>test[numbersNotConst.zero] : string >test : indexAccess >numbersNotConst.zero : numbersNotConst.zero >numbersNotConst : typeof numbersNotConst >zero : numbersNotConst.zero let n3 = test[numbersNotConst.one]; ->n3 : any ->test[numbersNotConst.one] : any +>n3 : number +>test[numbersNotConst.one] : number >test : indexAccess >numbersNotConst.one : numbersNotConst.one >numbersNotConst : typeof numbersNotConst diff --git a/tests/baselines/reference/decrementOperatorWithEnumType.errors.txt b/tests/baselines/reference/decrementOperatorWithEnumType.errors.txt index bad8dacd856..aae28d5e417 100644 --- a/tests/baselines/reference/decrementOperatorWithEnumType.errors.txt +++ b/tests/baselines/reference/decrementOperatorWithEnumType.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(6,25): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(6,31): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(7,29): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(10,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(10,9): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,1): error TS2542: Index signature in type 'typeof ENUM1' only permits reading. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,7): error TS2304: Cannot find name 'A'. @@ -12,19 +12,19 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp // expression var ResultIsNumber1 = --ENUM1["A"]; - ~~~~~~~~~~ -!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property. var ResultIsNumber2 = ENUM1.A--; ~ !!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property. // miss assignment operator --ENUM1["A"]; - ~~~~~~~~~~ -!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property. ENUM1[A]--; ~~~~~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2542: Index signature in type 'typeof ENUM1' only permits reading. ~ !!! error TS2304: Cannot find name 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/externalModuleImmutableBindings.errors.txt b/tests/baselines/reference/externalModuleImmutableBindings.errors.txt index 7454868e361..815b5847458 100644 --- a/tests/baselines/reference/externalModuleImmutableBindings.errors.txt +++ b/tests/baselines/reference/externalModuleImmutableBindings.errors.txt @@ -1,23 +1,23 @@ tests/cases/compiler/f2.ts(7,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/f2.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/compiler/f2.ts(8,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(9,7): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. tests/cases/compiler/f2.ts(12,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/f2.ts(13,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. +tests/cases/compiler/f2.ts(13,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(17,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/f2.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/compiler/f2.ts(18,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(19,8): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. tests/cases/compiler/f2.ts(22,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/f2.ts(23,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. +tests/cases/compiler/f2.ts(23,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(27,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(28,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/f2.ts(29,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. -tests/cases/compiler/f2.ts(30,6): error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property. +tests/cases/compiler/f2.ts(29,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. +tests/cases/compiler/f2.ts(30,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(31,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. tests/cases/compiler/f2.ts(32,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. tests/cases/compiler/f2.ts(36,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(37,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/f2.ts(38,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. -tests/cases/compiler/f2.ts(39,6): error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property. +tests/cases/compiler/f2.ts(38,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. +tests/cases/compiler/f2.ts(39,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(40,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. @@ -36,8 +36,8 @@ tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist ~ !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. stuff['x'] = 1; - ~~~~~~~~~~ -!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. stuff.blah = 2; ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. @@ -47,8 +47,8 @@ tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist ~ !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. stuff['x']++; - ~~~~~~~~~~ -!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. stuff['blah']++; stuff[n]++; @@ -56,8 +56,8 @@ tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist ~ !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. (stuff['x']) = 1; - ~~~~~~~~~~~~ -!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. (stuff.blah) = 2; ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. @@ -67,8 +67,8 @@ tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist ~ !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. (stuff['x'])++; - ~~~~~~~~~~~~ -!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. (stuff['blah'])++; (stuff[n])++; @@ -79,11 +79,11 @@ tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist ~ !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. for (stuff['x'] in []) {} - ~~~~~~~~~~ -!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. for (stuff['x'] of []) {} - ~~~~~~~~~~ -!!! error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. for (stuff.blah in []) {} ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. @@ -100,11 +100,11 @@ tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist ~ !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. for ((stuff['x']) in []) {} - ~~~~~~~~~~~~ -!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. for ((stuff['x']) of []) {} - ~~~~~~~~~~~~ -!!! error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. for ((stuff.blah) in []) {} ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. diff --git a/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt b/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt index 6886d992bb2..03361cfcfab 100644 --- a/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt +++ b/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(5,14): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'. +tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(5,16): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(6,16): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(7,9): error TS2365: Operator '===' cannot be applied to types 'string' and 'number'. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(9,16): error TS2339: Property 'unknownProperty' does not exist on type 'string'. @@ -12,7 +12,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors. for (let x in a) { let a1 = a[x + 1]; - ~~~~~~~~ + ~~~~~ !!! error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'. let a2 = a[x - 1]; ~ diff --git a/tests/baselines/reference/incrementOperatorWithEnumType.errors.txt b/tests/baselines/reference/incrementOperatorWithEnumType.errors.txt index 5dc16bdc511..8fdbc343562 100644 --- a/tests/baselines/reference/incrementOperatorWithEnumType.errors.txt +++ b/tests/baselines/reference/incrementOperatorWithEnumType.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(6,25): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(6,31): error TS2540: Cannot assign to 'B' because it is a constant or a read-only property. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(7,29): error TS2540: Cannot assign to 'B' because it is a constant or a read-only property. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(10,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(10,9): error TS2540: Cannot assign to 'B' because it is a constant or a read-only property. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(12,7): error TS2540: Cannot assign to 'B' because it is a constant or a read-only property. @@ -11,16 +11,16 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp // expression var ResultIsNumber1 = ++ENUM1["B"]; - ~~~~~~~~~~ -!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'B' because it is a constant or a read-only property. var ResultIsNumber2 = ENUM1.B++; ~ !!! error TS2540: Cannot assign to 'B' because it is a constant or a read-only property. // miss assignment operator ++ENUM1["B"]; - ~~~~~~~~~~ -!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. + ~~~ +!!! error TS2540: Cannot assign to 'B' because it is a constant or a read-only property. ENUM1.B++; ~ diff --git a/tests/baselines/reference/indexTypeCheck.errors.txt b/tests/baselines/reference/indexTypeCheck.errors.txt index 06b844f8321..9d839e9eb30 100644 --- a/tests/baselines/reference/indexTypeCheck.errors.txt +++ b/tests/baselines/reference/indexTypeCheck.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type ' tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'. -tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexTypeCheck.ts(51,8): error TS2538: Type 'Blue' cannot be used as an index type. ==== tests/cases/compiler/indexTypeCheck.ts (8 errors) ==== @@ -74,8 +74,8 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression s[{}]; // ok yellow[blue]; // error - ~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~~ +!!! error TS2538: Type 'Blue' cannot be used as an index type. var x:number[]; x[0]; diff --git a/tests/baselines/reference/indexWithUndefinedAndNull.errors.txt b/tests/baselines/reference/indexWithUndefinedAndNull.errors.txt new file mode 100644 index 00000000000..6d6fa9c39e8 --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNull.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/indexWithUndefinedAndNull.ts(9,21): error TS2538: Type 'undefined' cannot be used as an index type. +tests/cases/compiler/indexWithUndefinedAndNull.ts(10,9): error TS2538: Type 'null' cannot be used as an index type. +tests/cases/compiler/indexWithUndefinedAndNull.ts(11,21): error TS2538: Type 'undefined' cannot be used as an index type. +tests/cases/compiler/indexWithUndefinedAndNull.ts(12,9): error TS2538: Type 'null' cannot be used as an index type. + + +==== tests/cases/compiler/indexWithUndefinedAndNull.ts (4 errors) ==== + interface N { + [n: number]: string; + } + interface S { + [s: string]: number; + } + let n: N; + let s: S; + let str: string = n[undefined]; + ~~~~~~~~~ +!!! error TS2538: Type 'undefined' cannot be used as an index type. + str = n[null]; + ~~~~ +!!! error TS2538: Type 'null' cannot be used as an index type. + let num: number = s[undefined]; + ~~~~~~~~~ +!!! error TS2538: Type 'undefined' cannot be used as an index type. + num = s[null]; + ~~~~ +!!! error TS2538: Type 'null' cannot be used as an index type. + \ No newline at end of file diff --git a/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt b/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt index a1fce75c54e..764ce212971 100644 --- a/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt +++ b/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(9,19): error TS2454: Variable 'n' is used before being assigned. -tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(9,19): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(9,21): error TS2538: Type 'undefined' cannot be used as an index type. tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(10,7): error TS2454: Variable 'n' is used before being assigned. -tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(10,7): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(10,9): error TS2538: Type 'null' cannot be used as an index type. tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(11,19): error TS2454: Variable 's' is used before being assigned. -tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(11,19): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(11,21): error TS2538: Type 'undefined' cannot be used as an index type. tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,7): error TS2454: Variable 's' is used before being assigned. -tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,7): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,9): error TS2538: Type 'null' cannot be used as an index type. ==== tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts (8 errors) ==== @@ -20,21 +20,21 @@ tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,7): error T let str: string = n[undefined]; ~ !!! error TS2454: Variable 'n' is used before being assigned. - ~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~~~~~~~ +!!! error TS2538: Type 'undefined' cannot be used as an index type. str = n[null]; ~ !!! error TS2454: Variable 'n' is used before being assigned. - ~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~~ +!!! error TS2538: Type 'null' cannot be used as an index type. let num: number = s[undefined]; ~ !!! error TS2454: Variable 's' is used before being assigned. - ~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~~~~~~~ +!!! error TS2538: Type 'undefined' cannot be used as an index type. num = s[null]; ~ !!! error TS2454: Variable 's' is used before being assigned. - ~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~~ +!!! error TS2538: Type 'null' cannot be used as an index type. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyForIn.errors.txt b/tests/baselines/reference/noImplicitAnyForIn.errors.txt index 69b5cd34906..3db1c260d51 100644 --- a/tests/baselines/reference/noImplicitAnyForIn.errors.txt +++ b/tests/baselines/reference/noImplicitAnyForIn.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/noImplicitAnyForIn.ts(8,18): error TS7017: Index signature of object type implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyForIn.ts(15,18): error TS7017: Index signature of object type implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyForIn.ts(8,18): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. +tests/cases/compiler/noImplicitAnyForIn.ts(15,18): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. tests/cases/compiler/noImplicitAnyForIn.ts(29,5): error TS7005: Variable 'n' implicitly has an 'any[][]' type. tests/cases/compiler/noImplicitAnyForIn.ts(31,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. @@ -14,7 +14,7 @@ tests/cases/compiler/noImplicitAnyForIn.ts(31,6): error TS2405: The left-hand si //Should yield an implicit 'any' error var _j = x[i][j]; ~~~~~~~ -!!! error TS7017: Index signature of object type implicitly has an 'any' type. +!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. } for (var k in x[0]) { @@ -23,7 +23,7 @@ tests/cases/compiler/noImplicitAnyForIn.ts(31,6): error TS2405: The left-hand si //Should yield an implicit 'any' error var k2 = k1[k]; ~~~~~ -!!! error TS7017: Index signature of object type implicitly has an 'any' type. +!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. } } diff --git a/tests/baselines/reference/noImplicitAnyIndexing.errors.txt b/tests/baselines/reference/noImplicitAnyIndexing.errors.txt index 8f4cf616bda..3274bec5aae 100644 --- a/tests/baselines/reference/noImplicitAnyIndexing.errors.txt +++ b/tests/baselines/reference/noImplicitAnyIndexing.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/noImplicitAnyIndexing.ts(13,26): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'. -tests/cases/compiler/noImplicitAnyIndexing.ts(20,9): error TS7017: Index signature of object type implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyIndexing.ts(23,9): error TS7017: Index signature of object type implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyIndexing.ts(31,10): error TS7017: Index signature of object type implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyIndexing.ts(13,37): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'. +tests/cases/compiler/noImplicitAnyIndexing.ts(20,9): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. +tests/cases/compiler/noImplicitAnyIndexing.ts(23,9): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. +tests/cases/compiler/noImplicitAnyIndexing.ts(31,10): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. ==== tests/cases/compiler/noImplicitAnyIndexing.ts (4 errors) ==== @@ -18,7 +18,7 @@ tests/cases/compiler/noImplicitAnyIndexing.ts(31,10): error TS7017: Index signat // Should be implicit 'any' ; property access fails, no string indexer. var strRepresentation3 = MyEmusEnum["monehh"]; - ~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'. // Should be okay; should be a MyEmusEnum @@ -28,12 +28,12 @@ tests/cases/compiler/noImplicitAnyIndexing.ts(31,10): error TS7017: Index signat // Should report an implicit 'any'. var x = {}["hi"]; ~~~~~~~~ -!!! error TS7017: Index signature of object type implicitly has an 'any' type. +!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. // Should report an implicit 'any'. var y = {}[10]; ~~~~~~ -!!! error TS7017: Index signature of object type implicitly has an 'any' type. +!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. var hi: any = "hi"; @@ -43,7 +43,7 @@ tests/cases/compiler/noImplicitAnyIndexing.ts(31,10): error TS7017: Index signat // Should report an implicit 'any'. var z1 = emptyObj[hi]; ~~~~~~~~~~~~ -!!! error TS7017: Index signature of object type implicitly has an 'any' type. +!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. var z2 = (emptyObj)[hi]; interface MyMap { diff --git a/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.errors.txt b/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.errors.txt index 5c0878f8ab9..c66a0a83108 100644 --- a/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.errors.txt +++ b/tests/baselines/reference/noImplicitAnyStringIndexerOnObject.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(2,9): error TS7017: Index signature of object type implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(2,9): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. ==== tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts (1 errors) ==== var x = {}["hello"]; ~~~~~~~~~~~ -!!! error TS7017: Index signature of object type implicitly has an 'any' type. \ No newline at end of file +!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. \ No newline at end of file diff --git a/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt b/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt index ef50db9e4e5..fecbee27b58 100644 --- a/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt +++ b/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,17): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,25): error TS2538: Type 'Cookie' cannot be used as an index type. tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,63): error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? -tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,33): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,41): error TS2538: Type 'Cookie' cannot be used as an index type. tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,79): error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? @@ -58,13 +58,13 @@ tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,79): error TS // ElementAccessExpressions can only contain one expression. There should be a parse error here. var foods = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2538: Type 'Cookie' cannot be used as an index type. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? var foods2: MonsterFood[] = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2538: Type 'Cookie' cannot be used as an index type. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? \ No newline at end of file diff --git a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types index 5e664fadd20..e050d33024c 100644 --- a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types +++ b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types @@ -84,15 +84,15 @@ var r3 = c[1.0]; // same as indexing by 1 when done numerically // BUG 823822 var r7 = i[-1]; ->r7 : any ->i[-1] : any +>r7 : Date +>i[-1] : Date >i : I >-1 : -1 >1 : 1 var r7 = i[-1.0]; ->r7 : any ->i[-1.0] : any +>r7 : Date +>i[-1.0] : Date >i : I >-1.0 : -1 >1.0 : 1 @@ -116,8 +116,8 @@ var r10 = i[0x1] >0x1 : 1 var r11 = i[-0x1] ->r11 : any ->i[-0x1] : any +>r11 : Date +>i[-0x1] : Date >i : I >-0x1 : -1 >0x1 : 1 @@ -129,8 +129,8 @@ var r12 = i[01] >01 : 1 var r13 = i[-01] ->r13 : any ->i[-01] : any +>r13 : Date +>i[-01] : Date >i : I >-01 : -1 >01 : 1 @@ -215,15 +215,15 @@ var r3 = c[1.0]; // same as indexing by 1 when done numerically // BUG 823822 var r7 = i[-1]; ->r7 : any ->i[-1] : any +>r7 : Date +>i[-1] : Date >i : I >-1 : -1 >1 : 1 var r7 = i[-1.0]; ->r7 : any ->i[-1.0] : any +>r7 : Date +>i[-1.0] : Date >i : I >-1.0 : -1 >1.0 : 1 @@ -247,8 +247,8 @@ var r10 = i[0x1] >0x1 : 1 var r11 = i[-0x1] ->r11 : any ->i[-0x1] : any +>r11 : Date +>i[-0x1] : Date >i : I >-0x1 : -1 >0x1 : 1 @@ -260,8 +260,8 @@ var r12 = i[01] >01 : 1 var r13 = i[-01] ->r13 : any ->i[-01] : any +>r13 : Date +>i[-01] : Date >i : I >-01 : -1 >01 : 1 @@ -342,15 +342,15 @@ var r3 = c[1.0]; // same as indexing by 1 when done numerically // BUG 823822 var r7 = i[-1]; ->r7 : any ->i[-1] : any +>r7 : Date +>i[-1] : Date >i : I >-1 : -1 >1 : 1 var r7 = i[-1.0]; ->r7 : any ->i[-1.0] : any +>r7 : Date +>i[-1.0] : Date >i : I >-1.0 : -1 >1.0 : 1 @@ -374,8 +374,8 @@ var r10 = i[0x1] >0x1 : 1 var r11 = i[-0x1] ->r11 : any ->i[-0x1] : any +>r11 : Date +>i[-0x1] : Date >i : I >-0x1 : -1 >0x1 : 1 @@ -387,8 +387,8 @@ var r12 = i[01] >01 : 1 var r13 = i[-01] ->r13 : any ->i[-01] : any +>r13 : Date +>i[-01] : Date >i : I >-01 : -1 >01 : 1 @@ -482,15 +482,15 @@ var r3 = c[1.0]; // same as indexing by 1 when done numerically // BUG 823822 var r7 = i[-1]; ->r7 : any ->i[-1] : any +>r7 : Date +>i[-1] : Date >i : I >-1 : -1 >1 : 1 var r7 = i[-1.0]; ->r7 : any ->i[-1.0] : any +>r7 : Date +>i[-1.0] : Date >i : I >-1.0 : -1 >1.0 : 1 @@ -514,8 +514,8 @@ var r10 = i[0x1] >0x1 : 1 var r11 = i[-0x1] ->r11 : any ->i[-0x1] : any +>r11 : Date +>i[-0x1] : Date >i : I >-0x1 : -1 >0x1 : 1 @@ -527,8 +527,8 @@ var r12 = i[01] >01 : 1 var r13 = i[-01] ->r13 : any ->i[-01] : any +>r13 : Date +>i[-01] : Date >i : I >-01 : -1 >01 : 1 diff --git a/tests/baselines/reference/parserForStatement2.errors.txt b/tests/baselines/reference/parserForStatement2.errors.txt index 59d6dd6dec8..68ab999b657 100644 --- a/tests/baselines/reference/parserForStatement2.errors.txt +++ b/tests/baselines/reference/parserForStatement2.errors.txt @@ -1,11 +1,17 @@ +tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement2.ts(4,13): error TS2538: Type 'undefined' cannot be used as an index type. +tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement2.ts(4,20): error TS2538: Type 'undefined' cannot be used as an index type. tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement2.ts(4,30): error TS2304: Cannot find name 'd'. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement2.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement2.ts (3 errors) ==== var a; var b = []; var c; for (a in b[c] = b[c] || [], d) { + ~ +!!! error TS2538: Type 'undefined' cannot be used as an index type. + ~ +!!! error TS2538: Type 'undefined' cannot be used as an index type. ~ !!! error TS2304: Cannot find name 'd'. diff --git a/tests/baselines/reference/propertyAccess.errors.txt b/tests/baselines/reference/propertyAccess.errors.txt index b3244956174..a183ad79c11 100644 --- a/tests/baselines/reference/propertyAccess.errors.txt +++ b/tests/baselines/reference/propertyAccess.errors.txt @@ -1,12 +1,13 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(11,55): error TS2322: Type '{ 3: string; 'three': string; }' is not assignable to type '{ [n: number]: string; }'. Object literal may only specify known properties, and ''three'' does not exist in type '{ [n: number]: string; }'. 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; }'. -tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(80,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. -tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(117,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. -tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(80,19): error TS2538: Type '{ name: string; }' cannot be used as an index type. +tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(117,18): error TS2538: Type '{ name: string; }' cannot be used as an index type. +tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,22): error TS2538: Type '{ name: string; }' cannot be used as an index type. +tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(149,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x3' must be of type 'A | B', but here has type 'A'. -==== tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts (5 errors) ==== +==== tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts (6 errors) ==== class A { a: number; } @@ -92,8 +93,8 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er // Bracket notation property access using value of other type on type with numeric index signature and no string index signature var ll = numIndex[someObject]; // Error - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~~~~~~~~ +!!! error TS2538: Type '{ name: string; }' cannot be used as an index type. // Bracket notation property access using string value on type with string index signature and no numeric index signature var mm = strIndex['N']; @@ -131,8 +132,8 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er // Bracket notation property access using values of other types on type with no index signatures var uu = noIndex[someObject]; // Error - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~~~~~~~~ +!!! error TS2538: Type '{ name: string; }' cannot be used as an index type. // Bracket notation property access using numeric value on type with numeric index signature and string index signature var vv = noIndex[32]; @@ -156,8 +157,8 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er // Bracket notation property access using value of other type on type with numeric index signature and no string index signature and string index signature var zzzz = bothIndex[someObject]; // Error - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~~~~~~~~ +!!! error TS2538: Type '{ name: string; }' cannot be used as an index type. var x1 = numIndex[stringOrNumber]; var x1: any; @@ -167,4 +168,6 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er var x3 = bothIndex[stringOrNumber]; var x3: A; + ~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x3' must be of type 'A | B', but here has type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/readonlyMembers.errors.txt b/tests/baselines/reference/readonlyMembers.errors.txt index bea3a81bf7c..7a6b74359d1 100644 --- a/tests/baselines/reference/readonlyMembers.errors.txt +++ b/tests/baselines/reference/readonlyMembers.errors.txt @@ -11,8 +11,8 @@ tests/cases/compiler/readonlyMembers.ts(36,3): error TS2540: Cannot assign to 'a tests/cases/compiler/readonlyMembers.ts(40,3): error TS2540: Cannot assign to 'a' because it is a constant or a read-only property. tests/cases/compiler/readonlyMembers.ts(49,3): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property. tests/cases/compiler/readonlyMembers.ts(56,3): error TS2540: Cannot assign to 'a' because it is a constant or a read-only property. -tests/cases/compiler/readonlyMembers.ts(62,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. -tests/cases/compiler/readonlyMembers.ts(65,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/compiler/readonlyMembers.ts(62,1): error TS2542: Index signature in type '{ readonly [x: string]: string; }' only permits reading. +tests/cases/compiler/readonlyMembers.ts(65,1): error TS2542: Index signature in type '{ [x: string]: string; readonly [x: number]: string; }' only permits reading. ==== tests/cases/compiler/readonlyMembers.ts (15 errors) ==== @@ -105,10 +105,10 @@ tests/cases/compiler/readonlyMembers.ts(65,1): error TS2450: Left-hand side of a let s = xx["foo"]; xx["foo"] = "abc"; // Error ~~~~~~~~~ -!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +!!! error TS2542: Index signature in type '{ readonly [x: string]: string; }' only permits reading. let yy: { readonly [x: number]: string, [x: string]: string }; yy[1] = "abc"; // Error ~~~~~ -!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +!!! error TS2542: Index signature in type '{ [x: string]: string; readonly [x: number]: string; }' only permits reading. yy["foo"] = "abc"; \ No newline at end of file diff --git a/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt b/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt index 1cac31dec40..a7011e66910 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt +++ b/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts(11,16): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts(11,22): error TS2538: Type 'typeof Bar' cannot be used as an index type. ==== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess class Bar extends Foo { [symbol]() { return super[Bar](); - ~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + ~~~ +!!! error TS2538: Type 'typeof Bar' cannot be used as an index type. } } \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty53.errors.txt b/tests/baselines/reference/symbolProperty53.errors.txt index 03002cd92b2..faea8413587 100644 --- a/tests/baselines/reference/symbolProperty53.errors.txt +++ b/tests/baselines/reference/symbolProperty53.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty53.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,5): error TS2538: Type '(key: string) => symbol' cannot be used as an index type. ==== tests/cases/conformance/es6/Symbols/symbolProperty53.ts (2 errors) ==== @@ -10,5 +10,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An i }; obj[Symbol.for]; - ~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. \ No newline at end of file + ~~~~~~~~~~ +!!! error TS2538: Type '(key: string) => symbol' cannot be used as an index type. \ No newline at end of file