Introduce checkElementTypeOfArrayOrString for downlevel for..of type checking
This commit is contained in:
parent
5b46f5f9ae
commit
61cd2a7543
|
@ -1869,7 +1869,11 @@ module ts {
|
|||
return anyType;
|
||||
}
|
||||
if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement) {
|
||||
return getTypeForVariableDeclarationInForOfStatement(<ForOfStatement>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((<ForOfStatement>declaration.parent.parent).expression) || anyType;
|
||||
}
|
||||
if (isBindingPattern(declaration.parent)) {
|
||||
return getTypeForBindingElement(<BindingElement>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 = <Expression>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);
|
||||
|
|
|
@ -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}'." },
|
||||
|
|
|
@ -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",
|
||||
|
|
29
tests/baselines/reference/ES5For-of10.types
Normal file
29
tests/baselines/reference/ES5For-of10.types
Normal file
|
@ -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
|
||||
}
|
8
tests/baselines/reference/ES5For-of11.types
Normal file
8
tests/baselines/reference/ES5For-of11.types
Normal file
|
@ -0,0 +1,8 @@
|
|||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts ===
|
||||
var v;
|
||||
>v : any
|
||||
|
||||
for (v of []) { }
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
|
@ -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.
|
||||
~~~~
|
||||
!!! error TS2461: Type 'undefined' is not an array type.
|
9
tests/baselines/reference/ES5For-of13.types
Normal file
9
tests/baselines/reference/ES5For-of13.types
Normal file
|
@ -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
|
||||
}
|
12
tests/baselines/reference/ES5For-of24.types
Normal file
12
tests/baselines/reference/ES5For-of24.types
Normal file
|
@ -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
|
||||
}
|
15
tests/baselines/reference/ES5For-of25.types
Normal file
15
tests/baselines/reference/ES5For-of25.types
Normal file
|
@ -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[]
|
||||
}
|
10
tests/baselines/reference/ES5For-of26.errors.txt
Normal file
10
tests/baselines/reference/ES5For-of26.errors.txt
Normal file
|
@ -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;
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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;
|
||||
}
|
10
tests/baselines/reference/ES5For-of28.errors.txt
Normal file
10
tests/baselines/reference/ES5For-of28.errors.txt
Normal file
|
@ -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;
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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;
|
||||
}
|
9
tests/baselines/reference/ES5For-of3.types
Normal file
9
tests/baselines/reference/ES5For-of3.types
Normal file
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
30
tests/baselines/reference/ES5For-of9.types
Normal file
30
tests/baselines/reference/ES5For-of9.types
Normal file
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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<string|number> {
|
||||
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<string|number> {
|
||||
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;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//// [arityAndOrderCompatibility01.ts]
|
||||
//// [arityAndOrderCompatibility01.ts]
|
||||
interface StrNum extends Array<string|number> {
|
||||
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;
|
||||
|
|
242
tests/baselines/reference/downlevelLetConst16.errors.txt
Normal file
242
tests/baselines/reference/downlevelLetConst16.errors.txt
Normal file
|
@ -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);
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
|
@ -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'.
|
||||
}
|
Loading…
Reference in a new issue