From 61cd2a7543261c082213d314d1dc294d402bed88 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 9 Mar 2015 11:27:02 -0700 Subject: [PATCH] Introduce checkElementTypeOfArrayOrString for downlevel for..of type checking --- src/compiler/checker.ts | 67 +- .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 + tests/baselines/reference/ES5For-of10.types | 29 + tests/baselines/reference/ES5For-of11.types | 8 + .../reference/ES5For-of12.errors.txt | 6 +- tests/baselines/reference/ES5For-of13.types | 9 + tests/baselines/reference/ES5For-of24.types | 12 + tests/baselines/reference/ES5For-of25.types | 15 + .../reference/ES5For-of26.errors.txt | 10 + tests/baselines/reference/ES5For-of26.types | 12 - .../reference/ES5For-of27.errors.txt | 11 +- .../reference/ES5For-of28.errors.txt | 10 + tests/baselines/reference/ES5For-of28.types | 12 - .../reference/ES5For-of29.errors.txt | 11 +- tests/baselines/reference/ES5For-of3.types | 9 + .../reference/ES5For-of30.errors.txt | 6 +- .../reference/ES5For-of31.errors.txt | 11 +- .../baselines/reference/ES5For-of8.errors.txt | 6 +- tests/baselines/reference/ES5For-of9.types | 30 + .../arityAndOrderCompatibility01.errors.txt | 292 ++++---- .../reference/arityAndOrderCompatibility01.js | 56 +- .../reference/downlevelLetConst16.errors.txt | 242 ++++++ .../reference/downlevelLetConst16.types | 686 ------------------ .../parserES5ForOfStatement1.d.errors.txt | 5 +- .../parserES5ForOfStatement10.errors.txt | 6 +- .../parserES5ForOfStatement11.errors.txt | 6 +- .../parserES5ForOfStatement12.errors.txt | 6 +- .../parserES5ForOfStatement13.errors.txt | 6 +- .../parserES5ForOfStatement14.errors.txt | 6 +- .../parserES5ForOfStatement15.errors.txt | 6 +- .../parserES5ForOfStatement16.errors.txt | 6 +- .../parserES5ForOfStatement3.errors.txt | 5 +- .../parserES5ForOfStatement4.errors.txt | 5 +- .../parserES5ForOfStatement5.errors.txt | 5 +- .../parserES5ForOfStatement6.errors.txt | 5 +- .../parserES5ForOfStatement7.errors.txt | 5 +- .../parserES5ForOfStatement8.errors.txt | 6 +- .../parserES5ForOfStatement9.errors.txt | 6 +- 39 files changed, 685 insertions(+), 954 deletions(-) create mode 100644 tests/baselines/reference/ES5For-of10.types create mode 100644 tests/baselines/reference/ES5For-of11.types create mode 100644 tests/baselines/reference/ES5For-of13.types create mode 100644 tests/baselines/reference/ES5For-of24.types create mode 100644 tests/baselines/reference/ES5For-of25.types create mode 100644 tests/baselines/reference/ES5For-of26.errors.txt delete mode 100644 tests/baselines/reference/ES5For-of26.types create mode 100644 tests/baselines/reference/ES5For-of28.errors.txt delete mode 100644 tests/baselines/reference/ES5For-of28.types create mode 100644 tests/baselines/reference/ES5For-of3.types create mode 100644 tests/baselines/reference/ES5For-of9.types create mode 100644 tests/baselines/reference/downlevelLetConst16.errors.txt delete mode 100644 tests/baselines/reference/downlevelLetConst16.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6682761812d..414a8ce17fa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1869,7 +1869,11 @@ module ts { return anyType; } if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement) { - return getTypeForVariableDeclarationInForOfStatement(declaration.parent.parent); + // checkRightHandSideOfForOf will return undefined if the for-of expression type was + // missing properties/signatures required to get its iteratedType (like + // [Symbol.iterator] or next). This may be because we accessed properties from anyType, + // or it may have led to an error inside getIteratedType. + return checkRightHandSideOfForOf((declaration.parent.parent).expression) || anyType; } if (isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); @@ -8781,7 +8785,7 @@ module ts { // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS - // via getTypeForVariableDeclarationInForOfStatement. + // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { @@ -8789,8 +8793,7 @@ module ts { } else { var varExpr = node.initializer; - var rightType = checkExpression(node.expression); - var iteratedType = checkIteratedType(rightType, node.expression); + var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side if (varExpr.kind === SyntaxKind.ArrayLiteralExpression || varExpr.kind === SyntaxKind.ObjectLiteralExpression) { @@ -8872,18 +8875,11 @@ module ts { } } - function getTypeForVariableDeclarationInForOfStatement(forOfStatement: ForOfStatement): Type { - // Temporarily return 'any' below ES6 - if (languageVersion < ScriptTarget.ES6) { - return anyType; - } - - // iteratedType will be undefined if the for-of expression type was missing properties/signatures - // required to get its iteratedType (like [Symbol.iterator] or next). This may be - // because we accessed properties from anyType, or it may have led to an error inside - // getIteratedType. - var expressionType = getTypeOfExpression(forOfStatement.expression); - return checkIteratedType(expressionType, forOfStatement.expression) || anyType; + function checkRightHandSideOfForOf(rhsExpression: Expression): Type { + var expressionType = getTypeOfExpression(rhsExpression); + return languageVersion >= ScriptTarget.ES6 + ? checkIteratedType(expressionType, rhsExpression) + : checkElementTypeOfArrayOrString(expressionType, rhsExpression); } /** @@ -8982,6 +8978,45 @@ module ts { } } + function checkElementTypeOfArrayOrString(arrayOrStringType: Type, expressionForError: Expression): Type { + Debug.assert(languageVersion < ScriptTarget.ES6); + var isJustString = allConstituentTypesHaveKind(arrayOrStringType, TypeFlags.StringLike); + + // Check isJustString because removeTypesFromUnionType will only remove types if it doesn't result + // in an emptyObjectType. In this case, we actually do want the emptyObjectType. + var arrayType = isJustString ? emptyObjectType : removeTypesFromUnionType(arrayOrStringType, TypeFlags.StringLike, /*isTypeOfKind*/ true); + var hasStringConstituent = arrayOrStringType !== emptyObjectType && arrayOrStringType !== arrayType; + + var reportedError = false; + if (hasStringConstituent && languageVersion < ScriptTarget.ES5) { + error(expressionForError, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); + reportedError = true; + } + + if (isJustString) { + return stringType; + } + + if (!isArrayLikeType(arrayType)) { + if (!reportedError) { + error(expressionForError, Diagnostics.Type_0_is_not_an_array_type, typeToString(arrayType)); + } + return hasStringConstituent ? stringType : unknownType; + } + + var arrayElementType = getIndexTypeOfType(arrayType, IndexKind.Number) || unknownType; + if (hasStringConstituent) { + // This is just an optimization for the case where arrayOrStringType is string | string[] + if (arrayElementType.flags & TypeFlags.StringLike) { + return stringType; + } + + return getUnionType([arrayElementType, stringType]); + } + + return arrayElementType; + } + function checkBreakOrContinueStatement(node: BreakOrContinueStatement) { // Grammar checking checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 74028d85910..ef8a3936bc3 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -338,6 +338,7 @@ module ts { The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" }, Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, + Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f55c4391699..efeb54d93fc 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1343,6 +1343,10 @@ "category": "Error", "code": 2493 }, + "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.": { + "category": "Error", + "code": 2494 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/ES5For-of10.types b/tests/baselines/reference/ES5For-of10.types new file mode 100644 index 00000000000..32a2adcf3da --- /dev/null +++ b/tests/baselines/reference/ES5For-of10.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts === +function foo() { +>foo : () => { x: number; } + + return { x: 0 }; +>{ x: 0 } : { x: number; } +>x : number +} +for (foo().x of []) { +>foo().x : number +>foo() : { x: number; } +>foo : () => { x: number; } +>x : number +>[] : undefined[] + + for (foo().x of []) +>foo().x : number +>foo() : { x: number; } +>foo : () => { x: number; } +>x : number +>[] : undefined[] + + var p = foo().x; +>p : number +>foo().x : number +>foo() : { x: number; } +>foo : () => { x: number; } +>x : number +} diff --git a/tests/baselines/reference/ES5For-of11.types b/tests/baselines/reference/ES5For-of11.types new file mode 100644 index 00000000000..e51bc46f157 --- /dev/null +++ b/tests/baselines/reference/ES5For-of11.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts === +var v; +>v : any + +for (v of []) { } +>v : any +>[] : undefined[] + diff --git a/tests/baselines/reference/ES5For-of12.errors.txt b/tests/baselines/reference/ES5For-of12.errors.txt index ca7c2b190a2..55144f549a0 100644 --- a/tests/baselines/reference/ES5For-of12.errors.txt +++ b/tests/baselines/reference/ES5For-of12.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts(1,6): error TS2461: Type 'undefined' is not an array type. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts (1 errors) ==== for ([""] of []) { } - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. \ No newline at end of file + ~~~~ +!!! error TS2461: Type 'undefined' is not an array type. \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of13.types b/tests/baselines/reference/ES5For-of13.types new file mode 100644 index 00000000000..64aac2ae4b2 --- /dev/null +++ b/tests/baselines/reference/ES5For-of13.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts === +for (let v of ['a', 'b', 'c']) { +>v : string +>['a', 'b', 'c'] : string[] + + var x = v; +>x : string +>v : string +} diff --git a/tests/baselines/reference/ES5For-of24.types b/tests/baselines/reference/ES5For-of24.types new file mode 100644 index 00000000000..7170073b5d9 --- /dev/null +++ b/tests/baselines/reference/ES5For-of24.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of24.ts === +var a = [1, 2, 3]; +>a : number[] +>[1, 2, 3] : number[] + +for (var v of a) { +>v : number +>a : number[] + + let a = 0; +>a : number +} diff --git a/tests/baselines/reference/ES5For-of25.types b/tests/baselines/reference/ES5For-of25.types new file mode 100644 index 00000000000..7b306ee9a26 --- /dev/null +++ b/tests/baselines/reference/ES5For-of25.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of25.ts === +var a = [1, 2, 3]; +>a : number[] +>[1, 2, 3] : number[] + +for (var v of a) { +>v : number +>a : number[] + + v; +>v : number + + a; +>a : number[] +} diff --git a/tests/baselines/reference/ES5For-of26.errors.txt b/tests/baselines/reference/ES5For-of26.errors.txt new file mode 100644 index 00000000000..324ded25b4f --- /dev/null +++ b/tests/baselines/reference/ES5For-of26.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts(1,10): error TS2461: Type 'number' is not an array type. + + +==== tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts (1 errors) ==== + for (var [a = 0, b = 1] of [2, 3]) { + ~~~~~~~~~~~~~~ +!!! error TS2461: Type 'number' is not an array type. + a; + b; + } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of26.types b/tests/baselines/reference/ES5For-of26.types deleted file mode 100644 index b59378fdb6b..00000000000 --- a/tests/baselines/reference/ES5For-of26.types +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts === -for (var [a = 0, b = 1] of [2, 3]) { ->a : number ->b : number ->[2, 3] : number[] - - a; ->a : number - - b; ->b : number -} diff --git a/tests/baselines/reference/ES5For-of27.errors.txt b/tests/baselines/reference/ES5For-of27.errors.txt index f54c66d7eae..0c839859930 100644 --- a/tests/baselines/reference/ES5For-of27.errors.txt +++ b/tests/baselines/reference/ES5For-of27.errors.txt @@ -1,10 +1,13 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts(1,11): error TS2459: Type 'number' has no property 'x' and no string index signature. +tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts(1,21): error TS2459: Type 'number' has no property 'y' and no string index signature. -==== tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts (1 errors) ==== +==== tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts (2 errors) ==== for (var {x: a = 0, y: b = 1} of [2, 3]) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2459: Type 'number' has no property 'x' and no string index signature. + ~ +!!! error TS2459: Type 'number' has no property 'y' and no string index signature. a; b; } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of28.errors.txt b/tests/baselines/reference/ES5For-of28.errors.txt new file mode 100644 index 00000000000..81398fa5a9b --- /dev/null +++ b/tests/baselines/reference/ES5For-of28.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/statements/for-ofStatements/ES5For-of28.ts(1,10): error TS2461: Type 'number' is not an array type. + + +==== tests/cases/conformance/statements/for-ofStatements/ES5For-of28.ts (1 errors) ==== + for (let [a = 0, b = 1] of [2, 3]) { + ~~~~~~~~~~~~~~ +!!! error TS2461: Type 'number' is not an array type. + a; + b; + } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of28.types b/tests/baselines/reference/ES5For-of28.types deleted file mode 100644 index 61a4779e80b..00000000000 --- a/tests/baselines/reference/ES5For-of28.types +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/conformance/statements/for-ofStatements/ES5For-of28.ts === -for (let [a = 0, b = 1] of [2, 3]) { ->a : number ->b : number ->[2, 3] : number[] - - a; ->a : number - - b; ->b : number -} diff --git a/tests/baselines/reference/ES5For-of29.errors.txt b/tests/baselines/reference/ES5For-of29.errors.txt index 24a0b67aec8..e669b070222 100644 --- a/tests/baselines/reference/ES5For-of29.errors.txt +++ b/tests/baselines/reference/ES5For-of29.errors.txt @@ -1,10 +1,13 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts(1,13): error TS2459: Type 'number' has no property 'x' and no string index signature. +tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts(1,23): error TS2459: Type 'number' has no property 'y' and no string index signature. -==== tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts (1 errors) ==== +==== tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts (2 errors) ==== for (const {x: a = 0, y: b = 1} of [2, 3]) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2459: Type 'number' has no property 'x' and no string index signature. + ~ +!!! error TS2459: Type 'number' has no property 'y' and no string index signature. a; b; } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of3.types b/tests/baselines/reference/ES5For-of3.types new file mode 100644 index 00000000000..c47328816e8 --- /dev/null +++ b/tests/baselines/reference/ES5For-of3.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of3.ts === +for (var v of ['a', 'b', 'c']) +>v : string +>['a', 'b', 'c'] : string[] + + var x = v; +>x : string +>v : string + diff --git a/tests/baselines/reference/ES5For-of30.errors.txt b/tests/baselines/reference/ES5For-of30.errors.txt index 9ab0dfca3cd..0b02a55ba3f 100644 --- a/tests/baselines/reference/ES5For-of30.errors.txt +++ b/tests/baselines/reference/ES5For-of30.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'string | number' is not an array type. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts (1 errors) ==== var a: string, b: number; var tuple: [number, string] = [2, "3"]; for ([a = 1, b = ""] of tuple) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~~~~~~~~~~~~~~~ +!!! error TS2461: Type 'string | number' is not an array type. a; b; } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of31.errors.txt b/tests/baselines/reference/ES5For-of31.errors.txt index fa3b7617980..4a49e1fdf92 100644 --- a/tests/baselines/reference/ES5For-of31.errors.txt +++ b/tests/baselines/reference/ES5For-of31.errors.txt @@ -1,12 +1,15 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts(3,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts(3,8): error TS2459: Type 'undefined' has no property 'a' and no string index signature. +tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts(3,18): error TS2459: Type 'undefined' has no property 'b' and no string index signature. -==== tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts (1 errors) ==== +==== tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts (2 errors) ==== var a: string, b: number; for ({ a: b = 1, b: a = ""} of []) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2459: Type 'undefined' has no property 'a' and no string index signature. + ~ +!!! error TS2459: Type 'undefined' has no property 'b' and no string index signature. a; b; } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of8.errors.txt b/tests/baselines/reference/ES5For-of8.errors.txt index d32d50a6610..7cc3c871277 100644 --- a/tests/baselines/reference/ES5For-of8.errors.txt +++ b/tests/baselines/reference/ES5For-of8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-of8.ts(4,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/statements/for-ofStatements/ES5For-of8.ts(4,6): error TS2322: Type 'string' is not assignable to type 'number'. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-of8.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-of8.ts(4,1): error TS return { x: 0 }; } for (foo().x of ['a', 'b', 'c']) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. var p = foo().x; } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of9.types b/tests/baselines/reference/ES5For-of9.types new file mode 100644 index 00000000000..60870c2d642 --- /dev/null +++ b/tests/baselines/reference/ES5For-of9.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of9.ts === +function foo() { +>foo : () => { x: number; } + + return { x: 0 }; +>{ x: 0 } : { x: number; } +>x : number +} +for (foo().x of []) { +>foo().x : number +>foo() : { x: number; } +>foo : () => { x: number; } +>x : number +>[] : undefined[] + + for (foo().x of []) { +>foo().x : number +>foo() : { x: number; } +>foo : () => { x: number; } +>x : number +>[] : undefined[] + + var p = foo().x; +>p : number +>foo().x : number +>foo() : { x: number; } +>foo : () => { x: number; } +>x : number + } +} diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt index 3925cdff747..391fbf42384 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt +++ b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt @@ -1,147 +1,147 @@ -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(13,12): error TS2493: Tuple type '[string, number]' with length '2' cannot be assigned to tuple with length '3'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(14,12): error TS2460: Type 'StrNum' has no property '2'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,5): error TS2461: Type '{ 0: string; 1: number; }' is not an array type. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(16,5): error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(17,5): error TS2322: Type 'StrNum' is not assignable to type '[number, number, number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(18,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, number, number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(19,5): error TS2322: Type '[string, number]' is not assignable to type '[string, number, number]'. - Property '2' is missing in type '[string, number]'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(20,5): error TS2322: Type 'StrNum' is not assignable to type '[string, number, number]'. - Property '2' is missing in type 'StrNum'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(21,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string, number, number]'. - Property '2' is missing in type '{ 0: string; 1: number; }'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(22,5): error TS2322: Type '[string, number]' is not assignable to type '[number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(23,5): error TS2322: Type 'StrNum' is not assignable to type '[number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(24,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(25,5): error TS2322: Type '[string, number]' is not assignable to type '[string]'. - Types of property 'pop' are incompatible. - Type '() => string | number' is not assignable to type '() => string'. - Type 'string | number' is not assignable to type 'string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(26,5): error TS2322: Type 'StrNum' is not assignable to type '[string]'. - Types of property 'pop' are incompatible. - Type '() => string | number' is not assignable to type '() => string'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(27,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string]'. - Property 'length' is missing in type '{ 0: string; 1: number; }'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(28,5): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(29,5): error TS2322: Type 'StrNum' is not assignable to type '[number, string]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, string]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. - - -==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (18 errors) ==== - interface StrNum extends Array { - 0: string; - 1: number; - } - - var x: [string, number]; - var y: StrNum - var z: { - 0: string; - 1: number; - } - - var [a, b, c] = x; - ~ -!!! error TS2493: Tuple type '[string, number]' with length '2' cannot be assigned to tuple with length '3'. - var [d, e, f] = y; - ~ -!!! error TS2460: Type 'StrNum' has no property '2'. - var [g, h, i] = z; - ~~~~~~~~~ -!!! error TS2461: Type '{ 0: string; 1: number; }' is not an array type. - var j1: [number, number, number] = x; - ~~ -!!! error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. - var j2: [number, number, number] = y; - ~~ -!!! error TS2322: Type 'StrNum' is not assignable to type '[number, number, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. - var j3: [number, number, number] = z; - ~~ -!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, number, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. - var k1: [string, number, number] = x; - ~~ -!!! error TS2322: Type '[string, number]' is not assignable to type '[string, number, number]'. -!!! error TS2322: Property '2' is missing in type '[string, number]'. - var k2: [string, number, number] = y; - ~~ -!!! error TS2322: Type 'StrNum' is not assignable to type '[string, number, number]'. -!!! error TS2322: Property '2' is missing in type 'StrNum'. - var k3: [string, number, number] = z; - ~~ -!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string, number, number]'. -!!! error TS2322: Property '2' is missing in type '{ 0: string; 1: number; }'. - var l1: [number] = x; - ~~ -!!! error TS2322: Type '[string, number]' is not assignable to type '[number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. - var l2: [number] = y; - ~~ -!!! error TS2322: Type 'StrNum' is not assignable to type '[number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. - var l3: [number] = z; - ~~ -!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. - var m1: [string] = x; - ~~ -!!! error TS2322: Type '[string, number]' is not assignable to type '[string]'. -!!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => string | number' is not assignable to type '() => string'. -!!! error TS2322: Type 'string | number' is not assignable to type 'string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - var m2: [string] = y; - ~~ -!!! error TS2322: Type 'StrNum' is not assignable to type '[string]'. -!!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => string | number' is not assignable to type '() => string'. - var m3: [string] = z; - ~~ -!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string]'. -!!! error TS2322: Property 'length' is missing in type '{ 0: string; 1: number; }'. - var n1: [number, string] = x; - ~~ -!!! error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. - var n2: [number, string] = y; - ~~ -!!! error TS2322: Type 'StrNum' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. - var n3: [number, string] = z; - ~~ -!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. - var o1: [string, number] = x; - var o2: [string, number] = y; - var o3: [string, number] = y; +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(13,12): error TS2493: Tuple type '[string, number]' with length '2' cannot be assigned to tuple with length '3'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(14,12): error TS2460: Type 'StrNum' has no property '2'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,5): error TS2461: Type '{ 0: string; 1: number; }' is not an array type. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(16,5): error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(17,5): error TS2322: Type 'StrNum' is not assignable to type '[number, number, number]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(18,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, number, number]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(19,5): error TS2322: Type '[string, number]' is not assignable to type '[string, number, number]'. + Property '2' is missing in type '[string, number]'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(20,5): error TS2322: Type 'StrNum' is not assignable to type '[string, number, number]'. + Property '2' is missing in type 'StrNum'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(21,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string, number, number]'. + Property '2' is missing in type '{ 0: string; 1: number; }'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(22,5): error TS2322: Type '[string, number]' is not assignable to type '[number]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(23,5): error TS2322: Type 'StrNum' is not assignable to type '[number]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(24,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(25,5): error TS2322: Type '[string, number]' is not assignable to type '[string]'. + Types of property 'pop' are incompatible. + Type '() => string | number' is not assignable to type '() => string'. + Type 'string | number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(26,5): error TS2322: Type 'StrNum' is not assignable to type '[string]'. + Types of property 'pop' are incompatible. + Type '() => string | number' is not assignable to type '() => string'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(27,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string]'. + Property 'length' is missing in type '{ 0: string; 1: number; }'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(28,5): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(29,5): error TS2322: Type 'StrNum' is not assignable to type '[number, string]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, string]'. + Types of property '0' are incompatible. + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (18 errors) ==== + interface StrNum extends Array { + 0: string; + 1: number; + } + + var x: [string, number]; + var y: StrNum + var z: { + 0: string; + 1: number; + } + + var [a, b, c] = x; + ~ +!!! error TS2493: Tuple type '[string, number]' with length '2' cannot be assigned to tuple with length '3'. + var [d, e, f] = y; + ~ +!!! error TS2460: Type 'StrNum' has no property '2'. + var [g, h, i] = z; + ~~~~~~~~~ +!!! error TS2461: Type '{ 0: string; 1: number; }' is not an array type. + var j1: [number, number, number] = x; + ~~ +!!! error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + var j2: [number, number, number] = y; + ~~ +!!! error TS2322: Type 'StrNum' is not assignable to type '[number, number, number]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + var j3: [number, number, number] = z; + ~~ +!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, number, number]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + var k1: [string, number, number] = x; + ~~ +!!! error TS2322: Type '[string, number]' is not assignable to type '[string, number, number]'. +!!! error TS2322: Property '2' is missing in type '[string, number]'. + var k2: [string, number, number] = y; + ~~ +!!! error TS2322: Type 'StrNum' is not assignable to type '[string, number, number]'. +!!! error TS2322: Property '2' is missing in type 'StrNum'. + var k3: [string, number, number] = z; + ~~ +!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string, number, number]'. +!!! error TS2322: Property '2' is missing in type '{ 0: string; 1: number; }'. + var l1: [number] = x; + ~~ +!!! error TS2322: Type '[string, number]' is not assignable to type '[number]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + var l2: [number] = y; + ~~ +!!! error TS2322: Type 'StrNum' is not assignable to type '[number]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + var l3: [number] = z; + ~~ +!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + var m1: [string] = x; + ~~ +!!! error TS2322: Type '[string, number]' is not assignable to type '[string]'. +!!! error TS2322: Types of property 'pop' are incompatible. +!!! error TS2322: Type '() => string | number' is not assignable to type '() => string'. +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + var m2: [string] = y; + ~~ +!!! error TS2322: Type 'StrNum' is not assignable to type '[string]'. +!!! error TS2322: Types of property 'pop' are incompatible. +!!! error TS2322: Type '() => string | number' is not assignable to type '() => string'. + var m3: [string] = z; + ~~ +!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string]'. +!!! error TS2322: Property 'length' is missing in type '{ 0: string; 1: number; }'. + var n1: [number, string] = x; + ~~ +!!! error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + var n2: [number, string] = y; + ~~ +!!! error TS2322: Type 'StrNum' is not assignable to type '[number, string]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + var n3: [number, string] = z; + ~~ +!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[number, string]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + var o1: [string, number] = x; + var o2: [string, number] = y; + var o3: [string, number] = y; \ No newline at end of file diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.js b/tests/baselines/reference/arityAndOrderCompatibility01.js index 5b88697fd4f..2eb1bcf8bd8 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.js +++ b/tests/baselines/reference/arityAndOrderCompatibility01.js @@ -1,4 +1,4 @@ -//// [arityAndOrderCompatibility01.ts] +//// [arityAndOrderCompatibility01.ts] interface StrNum extends Array { 0: string; 1: number; @@ -32,30 +32,30 @@ var n3: [number, string] = z; var o1: [string, number] = x; var o2: [string, number] = y; var o3: [string, number] = y; - - -//// [arityAndOrderCompatibility01.js] -var x; -var y; -var z; -var a = x[0], b = x[1], c = x[2]; -var d = y[0], e = y[1], f = y[2]; -var g = z[0], h = z[1], i = z[2]; -var j1 = x; -var j2 = y; -var j3 = z; -var k1 = x; -var k2 = y; -var k3 = z; -var l1 = x; -var l2 = y; -var l3 = z; -var m1 = x; -var m2 = y; -var m3 = z; -var n1 = x; -var n2 = y; -var n3 = z; -var o1 = x; -var o2 = y; -var o3 = y; + + +//// [arityAndOrderCompatibility01.js] +var x; +var y; +var z; +var a = x[0], b = x[1], c = x[2]; +var d = y[0], e = y[1], f = y[2]; +var g = z[0], h = z[1], i = z[2]; +var j1 = x; +var j2 = y; +var j3 = z; +var k1 = x; +var k2 = y; +var k3 = z; +var l1 = x; +var l2 = y; +var l3 = z; +var m1 = x; +var m2 = y; +var m3 = z; +var n1 = x; +var n2 = y; +var n3 = z; +var o1 = x; +var o2 = y; +var o3 = y; diff --git a/tests/baselines/reference/downlevelLetConst16.errors.txt b/tests/baselines/reference/downlevelLetConst16.errors.txt new file mode 100644 index 00000000000..94c53360b87 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst16.errors.txt @@ -0,0 +1,242 @@ +tests/cases/compiler/downlevelLetConst16.ts(195,14): error TS2461: Type 'undefined' is not an array type. +tests/cases/compiler/downlevelLetConst16.ts(202,15): error TS2459: Type 'undefined' has no property 'a' and no string index signature. +tests/cases/compiler/downlevelLetConst16.ts(216,16): error TS2461: Type 'undefined' is not an array type. +tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefined' has no property 'a' and no string index signature. + + +==== tests/cases/compiler/downlevelLetConst16.ts (4 errors) ==== + 'use strict' + + declare function use(a: any); + + var x = 10; + var y; + var z; + use(x); + use(y); + use(z); + function foo1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = {a: 1}; + use(z); + } + + function foo2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + + class A { + m1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + m2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + + } + + class B { + m1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + m2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + } + } + + function bar1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + } + + function bar2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + } + + module M1 { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + + module M2 { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + + module M3 { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + + module M4 { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + use(y); + use(z); + } + + function foo3() { + for (let x; ;) { + use(x); + } + for (let [y] = []; ;) { + use(y); + } + for (let {a: z} = {a: 1}; ;) { + use(z); + } + use(x); + } + + function foo4() { + for (const x = 1; ;) { + use(x); + } + for (const [y] = []; ;) { + use(y); + } + for (const {a: z} = { a: 1 }; ;) { + use(z); + } + use(x); + } + + function foo5() { + for (let x in []) { + use(x); + } + use(x); + } + + function foo6() { + for (const x in []) { + use(x); + } + use(x); + } + + function foo7() { + for (let x of []) { + use(x); + } + use(x); + } + + function foo8() { + for (let [x] of []) { + ~~~ +!!! error TS2461: Type 'undefined' is not an array type. + use(x); + } + use(x); + } + + function foo9() { + for (let {a: x} of []) { + ~ +!!! error TS2459: Type 'undefined' has no property 'a' and no string index signature. + use(x); + } + use(x); + } + + function foo10() { + for (const x of []) { + use(x); + } + use(x); + } + + function foo11() { + for (const [x] of []) { + ~~~ +!!! error TS2461: Type 'undefined' is not an array type. + use(x); + } + use(x); + } + + function foo12() { + for (const {a: x} of []) { + ~ +!!! error TS2459: Type 'undefined' has no property 'a' and no string index signature. + use(x); + } + use(x); + } \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst16.types b/tests/baselines/reference/downlevelLetConst16.types deleted file mode 100644 index a9a11507c30..00000000000 --- a/tests/baselines/reference/downlevelLetConst16.types +++ /dev/null @@ -1,686 +0,0 @@ -=== tests/cases/compiler/downlevelLetConst16.ts === -'use strict' - -declare function use(a: any); ->use : (a: any) => any ->a : any - -var x = 10; ->x : number - -var y; ->y : any - -var z; ->z : any - -use(x); ->use(x) : any ->use : (a: any) => any ->x : number - -use(y); ->use(y) : any ->use : (a: any) => any ->y : any - -use(z); ->use(z) : any ->use : (a: any) => any ->z : any - -function foo1() { ->foo1 : () => void - - let x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - let [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - let {a: z} = {a: 1}; ->a : unknown ->z : number ->{a: 1} : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number -} - -function foo2() { ->foo2 : () => void - { - let x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - let [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - let {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -class A { ->A : A - - m1() { ->m1 : () => void - - let x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - let [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - let {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - } - m2() { ->m2 : () => void - { - let x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - let [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - let {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - } - -} - -class B { ->B : B - - m1() { ->m1 : () => void - - const x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - const [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - const {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - - } - m2() { ->m2 : () => void - { - const x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - const [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - const {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - } -} - -function bar1() { ->bar1 : () => void - - const x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - const [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - const {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number -} - -function bar2() { ->bar2 : () => void - { - const x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - const [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - const {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -module M1 { ->M1 : typeof M1 - - let x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - let [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - let {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number -} - -module M2 { ->M2 : typeof M2 - { - let x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - let [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - let {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -module M3 { ->M3 : typeof M3 - - const x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - const [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - const {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - -} - -module M4 { ->M4 : typeof M4 - { - const x = 1; ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - const [y] = [1]; ->y : number ->[1] : [number] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : number - - const {a: z} = { a: 1 }; ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - - use(y); ->use(y) : any ->use : (a: any) => any ->y : any - - use(z); ->use(z) : any ->use : (a: any) => any ->z : any -} - -function foo3() { ->foo3 : () => void - - for (let x; ;) { ->x : any - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - } - for (let [y] = []; ;) { ->y : any ->[] : undefined[] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : any - } - for (let {a: z} = {a: 1}; ;) { ->a : unknown ->z : number ->{a: 1} : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -function foo4() { ->foo4 : () => void - - for (const x = 1; ;) { ->x : number - - use(x); ->use(x) : any ->use : (a: any) => any ->x : number - } - for (const [y] = []; ;) { ->y : any ->[] : undefined[] - - use(y); ->use(y) : any ->use : (a: any) => any ->y : any - } - for (const {a: z} = { a: 1 }; ;) { ->a : unknown ->z : number ->{ a: 1 } : { a: number; } ->a : number - - use(z); ->use(z) : any ->use : (a: any) => any ->z : number - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -function foo5() { ->foo5 : () => void - - for (let x in []) { ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -function foo6() { ->foo6 : () => void - - for (const x in []) { ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -function foo7() { ->foo7 : () => void - - for (let x of []) { ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -function foo8() { ->foo8 : () => void - - for (let [x] of []) { ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -function foo9() { ->foo9 : () => void - - for (let {a: x} of []) { ->a : unknown ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -function foo10() { ->foo10 : () => void - - for (const x of []) { ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -function foo11() { ->foo11 : () => void - - for (const [x] of []) { ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} - -function foo12() { ->foo12 : () => void - - for (const {a: x} of []) { ->a : unknown ->x : any ->[] : undefined[] - - use(x); ->use(x) : any ->use : (a: any) => any ->x : any - } - use(x); ->use(x) : any ->use : (a: any) => any ->x : number -} diff --git a/tests/baselines/reference/parserES5ForOfStatement1.d.errors.txt b/tests/baselines/reference/parserES5ForOfStatement1.d.errors.txt index f3034cd2c27..d8e186b4d57 100644 --- a/tests/baselines/reference/parserES5ForOfStatement1.d.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement1.d.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts(1,15): error TS2304: Cannot find name 'e'. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts (2 errors) ==== for (var i of e) { ~~~ !!! error TS1036: Statements are not allowed in ambient contexts. + ~ +!!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement10.errors.txt b/tests/baselines/reference/parserES5ForOfStatement10.errors.txt index 5cee7472d24..e0ea8928be1 100644 --- a/tests/baselines/reference/parserES5ForOfStatement10.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement10.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement10.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement10.ts(1,17): error TS2304: Cannot find name 'X'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement10.ts (1 errors) ==== for (const v of X) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement11.errors.txt b/tests/baselines/reference/parserES5ForOfStatement11.errors.txt index 79b16ed1ad6..098d895e6c3 100644 --- a/tests/baselines/reference/parserES5ForOfStatement11.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement11.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement11.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement11.ts(1,22): error TS2304: Cannot find name 'X'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement11.ts (1 errors) ==== for (const [a, b] of X) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement12.errors.txt b/tests/baselines/reference/parserES5ForOfStatement12.errors.txt index cdb6db690cf..63916799810 100644 --- a/tests/baselines/reference/parserES5ForOfStatement12.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement12.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement12.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement12.ts(1,22): error TS2304: Cannot find name 'X'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement12.ts (1 errors) ==== for (const {a, b} of X) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement13.errors.txt b/tests/baselines/reference/parserES5ForOfStatement13.errors.txt index 9d97fd9e249..e197c0c42ee 100644 --- a/tests/baselines/reference/parserES5ForOfStatement13.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement13.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement13.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement13.ts(1,20): error TS2304: Cannot find name 'X'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement13.ts (1 errors) ==== for (let {a, b} of X) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement14.errors.txt b/tests/baselines/reference/parserES5ForOfStatement14.errors.txt index 303439ec447..f48a17cbc43 100644 --- a/tests/baselines/reference/parserES5ForOfStatement14.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement14.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement14.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement14.ts(1,20): error TS2304: Cannot find name 'X'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement14.ts (1 errors) ==== for (let [a, b] of X) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement15.errors.txt b/tests/baselines/reference/parserES5ForOfStatement15.errors.txt index f0eab288fa7..dd4d61c420b 100644 --- a/tests/baselines/reference/parserES5ForOfStatement15.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement15.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement15.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement15.ts(1,20): error TS2304: Cannot find name 'X'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement15.ts (1 errors) ==== for (var [a, b] of X) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement16.errors.txt b/tests/baselines/reference/parserES5ForOfStatement16.errors.txt index b9248140f33..3879fb64e70 100644 --- a/tests/baselines/reference/parserES5ForOfStatement16.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement16.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement16.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement16.ts(1,20): error TS2304: Cannot find name 'X'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement16.ts (1 errors) ==== for (var {a, b} of X) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement3.errors.txt b/tests/baselines/reference/parserES5ForOfStatement3.errors.txt index a976d9c0d54..7388676a703 100644 --- a/tests/baselines/reference/parserES5ForOfStatement3.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement3.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement3.ts(1,13): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement3.ts(1,18): error TS2304: Cannot find name 'X'. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement3.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement3.ts (2 errors) ==== for (var a, b of X) { ~ !!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement4.errors.txt b/tests/baselines/reference/parserES5ForOfStatement4.errors.txt index e2b38b56be5..8a0d7abf0d0 100644 --- a/tests/baselines/reference/parserES5ForOfStatement4.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement4.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement4.ts(1,10): error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement4.ts(1,19): error TS2304: Cannot find name 'X'. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement4.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement4.ts (2 errors) ==== for (var a = 1 of X) { ~ !!! error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement5.errors.txt b/tests/baselines/reference/parserES5ForOfStatement5.errors.txt index 0e88ce6cf36..43c9161156a 100644 --- a/tests/baselines/reference/parserES5ForOfStatement5.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement5.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement5.ts(1,10): error TS2483: The left-hand side of a 'for...of' statement cannot use a type annotation. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement5.ts(1,23): error TS2304: Cannot find name 'X'. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement5.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement5.ts (2 errors) ==== for (var a: number of X) { ~ !!! error TS2483: The left-hand side of a 'for...of' statement cannot use a type annotation. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement6.errors.txt b/tests/baselines/reference/parserES5ForOfStatement6.errors.txt index da76589190d..8ddf2273ba8 100644 --- a/tests/baselines/reference/parserES5ForOfStatement6.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement6.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement6.ts(1,17): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement6.ts(1,26): error TS2304: Cannot find name 'X'. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement6.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement6.ts (2 errors) ==== for (var a = 1, b = 2 of X) { ~ !!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement7.errors.txt b/tests/baselines/reference/parserES5ForOfStatement7.errors.txt index ced399ca103..6bf7f300183 100644 --- a/tests/baselines/reference/parserES5ForOfStatement7.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement7.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement7.ts(1,25): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement7.ts(1,43): error TS2304: Cannot find name 'X'. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement7.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement7.ts (2 errors) ==== for (var a: number = 1, b: string = "" of X) { ~ !!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement8.errors.txt b/tests/baselines/reference/parserES5ForOfStatement8.errors.txt index 829fea57e6e..53b263ad6e1 100644 --- a/tests/baselines/reference/parserES5ForOfStatement8.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement8.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement8.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement8.ts(1,15): error TS2304: Cannot find name 'X'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement8.ts (1 errors) ==== for (var v of X) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement9.errors.txt b/tests/baselines/reference/parserES5ForOfStatement9.errors.txt index 4cf082b4f15..869cdfdf647 100644 --- a/tests/baselines/reference/parserES5ForOfStatement9.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement9.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement9.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement9.ts(1,15): error TS2304: Cannot find name 'X'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement9.ts (1 errors) ==== for (let v of X) { - ~~~ -!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file