Merge pull request #2308 from Microsoft/for-ofES5

Type checking 'for...of' in ES3/5
This commit is contained in:
Jason Freeman
2015-03-12 16:04:34 -07:00
125 changed files with 1204 additions and 600 deletions
+89 -27
View File
@@ -1918,7 +1918,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);
@@ -4759,17 +4763,22 @@ module ts {
// For a union type, remove all constituent types that are of the given type kind (when isOfTypeKind is true)
// or not of the given type kind (when isOfTypeKind is false)
function removeTypesFromUnionType(type: Type, typeKind: TypeFlags, isOfTypeKind: boolean): Type {
function removeTypesFromUnionType(type: Type, typeKind: TypeFlags, isOfTypeKind: boolean, allowEmptyUnionResult: boolean): Type {
if (type.flags & TypeFlags.Union) {
var types = (<UnionType>type).types;
if (forEach(types, t => !!(t.flags & typeKind) === isOfTypeKind)) {
// Above we checked if we have anything to remove, now use the opposite test to do the removal
var narrowedType = getUnionType(filter(types, t => !(t.flags & typeKind) === isOfTypeKind));
if (narrowedType !== emptyObjectType) {
if (allowEmptyUnionResult || narrowedType !== emptyObjectType) {
return narrowedType;
}
}
}
else if (allowEmptyUnionResult && !!(type.flags & typeKind) === isOfTypeKind) {
// Use getUnionType(emptyArray) instead of emptyObjectType in case the way empty union types
// are represented ever changes.
return getUnionType(emptyArray);
}
return type;
}
@@ -4972,7 +4981,8 @@ module ts {
if (assumeTrue) {
// Assumed result is true. If check was not for a primitive type, remove all primitive types
if (!typeInfo) {
return removeTypesFromUnionType(type, /*typeKind*/ TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.Boolean | TypeFlags.ESSymbol, /*isOfTypeKind*/ true);
return removeTypesFromUnionType(type, /*typeKind*/ TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.Boolean | TypeFlags.ESSymbol,
/*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false);
}
// Check was for a primitive type, return that primitive type if it is a subtype
if (isTypeSubtypeOf(typeInfo.type, type)) {
@@ -4980,12 +4990,12 @@ module ts {
}
// Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is
// union of enum types and other types.
return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false);
return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false);
}
else {
// Assumed result is false. If check was for a primitive type, remove that primitive type
if (typeInfo) {
return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true);
return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false);
}
// Otherwise we don't have enough information to do anything.
return type;
@@ -8826,16 +8836,11 @@ module ts {
}
function checkForOfStatement(node: ForOfStatement): void {
if (languageVersion < ScriptTarget.ES6) {
grammarErrorOnFirstToken(node, Diagnostics.for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher);
return;
}
checkGrammarForInOrForOfStatement(node)
// 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) {
@@ -8843,8 +8848,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) {
@@ -8926,18 +8930,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);
}
/**
@@ -9036,6 +9033,72 @@ module ts {
}
}
/**
* This function does the following steps:
* 1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents.
* 2. Take the element types of the array constituents.
* 3. Return the union of the element types, and string if there was a string constitutent.
*
* For example:
* string -> string
* number[] -> number
* string[] | number[] -> string | number
* string | number[] -> string | number
* string | string[] | number[] -> string | number
*
* It also errors if:
* 1. Some constituent is neither a string nor an array.
* 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable).
*/
function checkElementTypeOfArrayOrString(arrayOrStringType: Type, expressionForError: Expression): Type {
Debug.assert(languageVersion < ScriptTarget.ES6);
// After we remove all types that are StringLike, we will know if there was a string constituent
// based on whether the remaining type is the same as the initial type.
var arrayType = removeTypesFromUnionType(arrayOrStringType, TypeFlags.StringLike, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true);
var hasStringConstituent = arrayOrStringType !== arrayType;
var reportedError = false;
if (hasStringConstituent) {
if (languageVersion < ScriptTarget.ES5) {
error(expressionForError, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
reportedError = true;
}
// Now that we've removed all the StringLike types, if no constituents remain, then the entire
// arrayOrStringType was a string.
if (arrayType === emptyObjectType) {
return stringType;
}
}
if (!isArrayLikeType(arrayType)) {
if (!reportedError) {
// Which error we report depends on whether there was a string constituent. For example,
// if the input type is number | string, we want to say that number is not an array type.
// But if the input was just number, we want to say that number is not an array type
// or a string type.
var diagnostic = hasStringConstituent
? Diagnostics.Type_0_is_not_an_array_type
: Diagnostics.Type_0_is_not_an_array_type_or_a_string_type;
error(expressionForError, diagnostic, 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);
@@ -10980,7 +11043,6 @@ module ts {
}
function isUnknownIdentifier(location: Node, name: string): boolean {
// Do not call resolveName on a synthesized node!
Debug.assert(!nodeIsSynthesized(location), "isUnknownIdentifier called with a synthesized location");
return !resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined) &&
!hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name);
@@ -327,7 +327,6 @@ module ts {
Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." },
let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." },
Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." },
for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 2482, category: DiagnosticCategory.Error, key: "'for...of' statements are only available when targeting ECMAScript 6 or higher." },
The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." },
Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" },
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." },
@@ -339,6 +338,8 @@ 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." },
Type_0_is_not_an_array_type_or_a_string_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." },
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}'." },
+8 -4
View File
@@ -1299,10 +1299,6 @@
"category": "Error",
"code": 2481
},
"'for...of' statements are only available when targeting ECMAScript 6 or higher.": {
"category": "Error",
"code": 2482
},
"The left-hand side of a 'for...of' statement cannot use a type annotation.": {
"category": "Error",
"code": 2483
@@ -1347,6 +1343,14 @@
"category": "Error",
"code": 2493
},
"Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.": {
"category": "Error",
"code": 2494
},
"Type '{0}' is not an array type or a string type.": {
"category": "Error",
"code": 2461
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
@@ -0,0 +1,7 @@
tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts(1,15): error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
==== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts (1 errors) ====
for (var v of "") { }
~~
!!! error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
@@ -0,0 +1,7 @@
//// [ES3For-ofTypeCheck1.ts]
for (var v of "") { }
//// [ES3For-ofTypeCheck1.js]
for (var _i = 0, _a = ""; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,9 @@
//// [ES3For-ofTypeCheck2.ts]
for (var v of [true]) { }
//// [ES3For-ofTypeCheck2.js]
for (var _i = 0, _a = [
true
]; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,5 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck2.ts ===
for (var v of [true]) { }
>v : boolean
>[true] : boolean[]
@@ -0,0 +1,8 @@
tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts(2,17): error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
==== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts (1 errors) ====
var union: string | string[];
for (const v of union) { }
~~~~~
!!! error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
@@ -0,0 +1,9 @@
//// [ES3For-ofTypeCheck4.ts]
var union: string | string[];
for (const v of union) { }
//// [ES3For-ofTypeCheck4.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,9 @@
//// [ES3For-ofTypeCheck6.ts]
var union: string[] | number[];
for (var v of union) { }
//// [ES3For-ofTypeCheck6.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck6.ts ===
var union: string[] | number[];
>union : string[] | number[]
for (var v of union) { }
>v : string | number
>union : string[] | number[]
@@ -1,9 +1,9 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts(2,5): error TS2304: Cannot find name 'console'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts (1 errors) ====
for (var v of ['a', 'b', 'c']) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
console.log(v);
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
}
@@ -1,13 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts(4,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts (1 errors) ====
function foo() {
return { x: 0 };
}
for (foo().x of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
for (foo().x of [])
var p = foo().x;
}
@@ -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
}
@@ -1,8 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts(2,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts (1 errors) ====
var v;
for (v of []) { }
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
@@ -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,7): error TS2364: Invalid left-hand side of assignment expression.
==== 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.
for ([""] of [[""]]) { }
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
+6 -2
View File
@@ -1,7 +1,11 @@
//// [ES5For-of12.ts]
for ([""] of []) { }
for ([""] of [[""]]) { }
//// [ES5For-of12.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
for (var _i = 0, _a = [
[
""
]
]; _i < _a.length; _i++) {
"" = _a[_i][0];
}
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts (1 errors) ====
for (let v of ['a', 'b', 'c']) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = v;
}
@@ -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
}
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts (1 errors) ====
for (const v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = v;
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts ===
for (const v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
}
@@ -1,12 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of15.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of15.ts (1 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
for (const v of []) {
var x = v;
}
}
@@ -0,0 +1,17 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of15.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
for (const v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
}
}
@@ -1,13 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of16.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of16.ts (1 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
for (let v of []) {
var x = v;
v++;
}
}
@@ -0,0 +1,21 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of16.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
for (let v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
v++;
>v++ : number
>v : any
}
}
@@ -1,12 +1,12 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts(3,20): error TS2448: Block-scoped variable 'v' used before its declaration.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts (1 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
for (let v of [v]) {
~
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
var x = v;
v++;
}
@@ -1,16 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts(4,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts (2 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
}
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
}
@@ -0,0 +1,16 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
}
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
}
@@ -1,15 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of19.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of19.ts (1 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
function foo() {
for (const v of []) {
v;
}
}
}
@@ -0,0 +1,21 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of19.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
function foo() {
>foo : () => void
for (const v of []) {
>v : any
>[] : undefined[]
v;
>v : any
}
}
}
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of2.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of2.ts (1 errors) ====
for (var v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = v;
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of2.ts ===
for (var v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
}
@@ -1,12 +1,15 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts(3,20): error TS2448: Block-scoped variable 'v' used before its declaration.
tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts(4,15): error TS1155: 'const' declarations must be initialized
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts (1 errors) ====
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts (2 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
let v;
for (let v of [v]) {
~
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
const v;
~
!!! error TS1155: 'const' declarations must be initialized
}
}
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of21.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of21.ts (1 errors) ====
for (let v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
for (let _i of []) { }
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of21.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
for (let _i of []) { }
>_i : any
>[] : undefined[]
}
@@ -1,10 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of22.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of22.ts(3,5): error TS2304: Cannot find name 'console'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of22.ts (1 errors) ====
for (var x of [1, 2, 3]) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
let _a = 0;
console.log(x);
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
}
@@ -1,10 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of23.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of23.ts(3,5): error TS2304: Cannot find name 'console'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of23.ts (1 errors) ====
for (var x of [1, 2, 3]) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var _a = 0;
console.log(x);
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
}
@@ -1,10 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of24.ts(2,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of24.ts (1 errors) ====
var a = [1, 2, 3];
for (var v of a) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
let a = 0;
}
@@ -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
}
@@ -1,11 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of25.ts(2,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of25.ts (1 errors) ====
var a = [1, 2, 3];
for (var v of a) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
v;
a;
}
@@ -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[]
}
@@ -1,10 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
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 TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~~~~~~~~~~~~~~
!!! error TS2461: Type 'number' is not an array type.
a;
b;
}
@@ -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;
}
@@ -1,10 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of28.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
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 TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~~~~~~~~~~~~~~
!!! error TS2461: Type 'number' is not an array type.
a;
b;
}
@@ -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;
}
@@ -1,8 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of3.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of3.ts (1 errors) ====
for (var v of ['a', 'b', 'c'])
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = v;
@@ -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,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of4.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of4.ts (1 errors) ====
for (var v of [])
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = v;
var y = v;
@@ -0,0 +1,13 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of4.ts ===
for (var v of [])
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
var y = v;
>y : any
>v : any
@@ -1,9 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of5.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of5.ts (1 errors) ====
for (var _a of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = _a;
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of5.ts ===
for (var _a of []) {
>_a : any
>[] : undefined[]
var x = _a;
>x : any
>_a : any
}
@@ -1,11 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of6.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of6.ts (1 errors) ====
for (var w of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
for (var v of []) {
var x = [w, v];
}
}
@@ -0,0 +1,16 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of6.ts ===
for (var w of []) {
>w : any
>[] : undefined[]
for (var v of []) {
>v : any
>[] : undefined[]
var x = [w, v];
>x : any[]
>[w, v] : any[]
>w : any
>v : any
}
}
@@ -1,16 +1,13 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts(5,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts(6,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'any[]'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts (2 errors) ====
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts (1 errors) ====
for (var w of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = w;
}
for (var v of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
var x = [w, v];
~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'any[]'.
}
@@ -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;
}
@@ -1,14 +0,0 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of9.ts(4,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of9.ts (1 errors) ====
function foo() {
return { x: 0 };
}
for (foo().x of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
for (foo().x of []) {
var p = foo().x;
}
}
@@ -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
}
}
@@ -0,0 +1,7 @@
//// [ES5For-ofTypeCheck1.ts]
for (var v of "") { }
//// [ES5For-ofTypeCheck1.js]
for (var _i = 0, _a = ""; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,4 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck1.ts ===
for (var v of "") { }
>v : string
@@ -0,0 +1,23 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(1,15): error TS2461: Type 'StringIterator' is not an array type or a string type.
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(11,6): error TS2304: Cannot find name 'Symbol'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts (2 errors) ====
for (var v of new StringIterator) { }
~~~~~~~~~~~~~~~~~~
!!! error TS2461: Type 'StringIterator' is not an array type or a string type.
// In ES3/5, you cannot for...of over an arbitrary iterable.
class StringIterator {
next() {
return {
done: true,
value: ""
};
}
[Symbol.iterator]() {
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
return this;
}
}
@@ -0,0 +1,35 @@
//// [ES5For-ofTypeCheck10.ts]
for (var v of new StringIterator) { }
// In ES3/5, you cannot for...of over an arbitrary iterable.
class StringIterator {
next() {
return {
done: true,
value: ""
};
}
[Symbol.iterator]() {
return this;
}
}
//// [ES5For-ofTypeCheck10.js]
for (var _i = 0, _a = new StringIterator; _i < _a.length; _i++) {
var v = _a[_i];
}
// In ES3/5, you cannot for...of over an arbitrary iterable.
var StringIterator = (function () {
function StringIterator() {
}
StringIterator.prototype.next = function () {
return {
done: true,
value: ""
};
};
StringIterator.prototype[Symbol.iterator] = function () {
return this;
};
return StringIterator;
})();
@@ -0,0 +1,11 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6): error TS2322: Type 'string | number' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts (1 errors) ====
var union: string | number[];
var v: string;
for (v of union) { }
~
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
@@ -0,0 +1,11 @@
//// [ES5For-ofTypeCheck11.ts]
var union: string | number[];
var v: string;
for (v of union) { }
//// [ES5For-ofTypeCheck11.js]
var union;
var v;
for (var _i = 0; _i < union.length; _i++) {
v = union[_i];
}
@@ -0,0 +1,7 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts(1,17): error TS2461: Type 'number' is not an array type or a string type.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts (1 errors) ====
for (const v of 0) { }
~
!!! error TS2461: Type 'number' is not an array type or a string type.
@@ -0,0 +1,7 @@
//// [ES5For-ofTypeCheck12.ts]
for (const v of 0) { }
//// [ES5For-ofTypeCheck12.js]
for (var _i = 0, _a = 0; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck2.ts]
for (var v of [true]) { }
//// [ES5For-ofTypeCheck2.js]
for (var _i = 0, _a = [
true
]; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,5 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck2.ts ===
for (var v of [true]) { }
>v : boolean
>[true] : boolean[]
@@ -0,0 +1,12 @@
//// [ES5For-ofTypeCheck3.ts]
var tuple: [string, number] = ["", 0];
for (var v of tuple) { }
//// [ES5For-ofTypeCheck3.js]
var tuple = [
"",
0
];
for (var _i = 0; _i < tuple.length; _i++) {
var v = tuple[_i];
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck3.ts ===
var tuple: [string, number] = ["", 0];
>tuple : [string, number]
>["", 0] : [string, number]
for (var v of tuple) { }
>v : string | number
>tuple : [string, number]
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck4.ts]
var union: string | string[];
for (const v of union) { }
//// [ES5For-ofTypeCheck4.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck4.ts ===
var union: string | string[];
>union : string | string[]
for (const v of union) { }
>v : string
>union : string | string[]
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck5.ts]
var union: string | number[];
for (var v of union) { }
//// [ES5For-ofTypeCheck5.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck5.ts ===
var union: string | number[];
>union : string | number[]
for (var v of union) { }
>v : string | number
>union : string | number[]
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck6.ts]
var union: string[] | number[];
for (var v of union) { }
//// [ES5For-ofTypeCheck6.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck6.ts ===
var union: string[] | number[];
>union : string[] | number[]
for (var v of union) { }
>v : string | number
>union : string[] | number[]
@@ -0,0 +1,8 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck7.ts(2,15): error TS2461: Type 'number' is not an array type.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck7.ts (1 errors) ====
var union: string | number;
for (var v of union) { }
~~~~~
!!! error TS2461: Type 'number' is not an array type.
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck7.ts]
var union: string | number;
for (var v of union) { }
//// [ES5For-ofTypeCheck7.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,11 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck8.ts(3,6): error TS2322: Type 'string | number | symbol' is not assignable to type 'symbol'.
Type 'string' is not assignable to type 'symbol'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck8.ts (1 errors) ====
var union: string | string[]| number[]| symbol[];
var v: symbol;
for (v of union) { }
~
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'symbol'.
!!! error TS2322: Type 'string' is not assignable to type 'symbol'.
@@ -0,0 +1,11 @@
//// [ES5For-ofTypeCheck8.ts]
var union: string | string[]| number[]| symbol[];
var v: symbol;
for (v of union) { }
//// [ES5For-ofTypeCheck8.js]
var union;
var v;
for (var _i = 0; _i < union.length; _i++) {
v = union[_i];
}
@@ -0,0 +1,8 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts(2,15): error TS2461: Type 'number | symbol | string[]' is not an array type.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts (1 errors) ====
var union: string | string[] | number | symbol;
for (let v of union) { }
~~~~~
!!! error TS2461: Type 'number | symbol | string[]' is not an array type.
@@ -0,0 +1,9 @@
//// [ES5For-ofTypeCheck9.ts]
var union: string | string[] | number | symbol;
for (let v of union) { }
//// [ES5For-ofTypeCheck9.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -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;
@@ -1,12 +1,10 @@
tests/cases/compiler/downlevelLetConst16.ts(188,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(195,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(202,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(209,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(216,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
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 (6 errors) ====
==== tests/cases/compiler/downlevelLetConst16.ts (4 errors) ====
'use strict'
declare function use(a: any);
@@ -195,8 +193,6 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo7() {
for (let x of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
use(x);
@@ -204,8 +200,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo8() {
for (let [x] of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~~~
!!! error TS2461: Type 'undefined' is not an array type.
use(x);
}
use(x);
@@ -213,8 +209,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo9() {
for (let {a: x} 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.
use(x);
}
use(x);
@@ -222,8 +218,6 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo10() {
for (const x of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
use(x);
@@ -231,8 +225,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo11() {
for (const [x] of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
~~~
!!! error TS2461: Type 'undefined' is not an array type.
use(x);
}
use(x);
@@ -240,8 +234,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,5): error TS2482: 'for...of' sta
function foo12() {
for (const {a: x} 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.
use(x);
}
use(x);
@@ -1,73 +0,0 @@
tests/cases/compiler/downlevelLetConst17.ts(65,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/compiler/downlevelLetConst17.ts (1 errors) ====
'use strict'
declare function use(a: any);
var x;
for (let x = 10; ;) {
use(x);
}
use(x);
for (const x = 10; ;) {
use(x);
}
for (; ;) {
let x = 10;
use(x);
x = 1;
}
for (; ;) {
const x = 10;
use(x);
}
for (let x; ;) {
use(x);
x = 1;
}
for (; ;) {
let x;
use(x);
x = 1;
}
while (true) {
let x;
use(x);
}
while (true) {
const x = true;
use(x);
}
do {
let x;
use(x);
} while (true);
do {
let x;
use(x);
} while (true);
for (let x in []) {
use(x);
}
for (const x in []) {
use(x);
}
for (const x of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
@@ -0,0 +1,154 @@
=== tests/cases/compiler/downlevelLetConst17.ts ===
'use strict'
declare function use(a: any);
>use : (a: any) => any
>a : any
var x;
>x : any
for (let x = 10; ;) {
>x : number
use(x);
>use(x) : any
>use : (a: any) => any
>x : number
}
use(x);
>use(x) : any
>use : (a: any) => any
>x : any
for (const x = 10; ;) {
>x : number
use(x);
>use(x) : any
>use : (a: any) => any
>x : number
}
for (; ;) {
let x = 10;
>x : number
use(x);
>use(x) : any
>use : (a: any) => any
>x : number
x = 1;
>x = 1 : number
>x : number
}
for (; ;) {
const x = 10;
>x : number
use(x);
>use(x) : any
>use : (a: any) => any
>x : number
}
for (let x; ;) {
>x : any
use(x);
>use(x) : any
>use : (a: any) => any
>x : any
x = 1;
>x = 1 : number
>x : any
}
for (; ;) {
let x;
>x : any
use(x);
>use(x) : any
>use : (a: any) => any
>x : any
x = 1;
>x = 1 : number
>x : any
}
while (true) {
let x;
>x : any
use(x);
>use(x) : any
>use : (a: any) => any
>x : any
}
while (true) {
const x = true;
>x : boolean
use(x);
>use(x) : any
>use : (a: any) => any
>x : boolean
}
do {
let x;
>x : any
use(x);
>use(x) : any
>use : (a: any) => any
>x : any
} while (true);
do {
let x;
>x : any
use(x);
>use(x) : any
>use : (a: any) => any
>x : any
} while (true);
for (let x in []) {
>x : any
>[] : undefined[]
use(x);
>use(x) : any
>use : (a: any) => any
>x : any
}
for (const x in []) {
>x : any
>[] : undefined[]
use(x);
>use(x) : any
>use : (a: any) => any
>x : any
}
for (const x of []) {
>x : any
>[] : undefined[]
use(x);
>use(x) : any
>use : (a: any) => any
>x : any
}
@@ -1,8 +1,11 @@
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
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 TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
!!! 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,7 +0,0 @@
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement18.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement18.ts (1 errors) ====
for (var of of of) { }
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
@@ -0,0 +1,5 @@
=== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement18.ts ===
for (var of of of) { }
>of : any
>of : any
@@ -1,8 +1,8 @@
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement2.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement2.ts(1,9): error TS1123: Variable declaration list cannot be empty.
==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement2.ts (1 errors) ====
for (var of X) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
!!! error TS1123: Variable declaration list cannot be empty.
}

Some files were not shown because too many files have changed in this diff Show More