diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5d57e9d202874..3afdccb91433a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2510,9 +2510,9 @@ namespace ts { // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration: VariableLikeDeclaration): Type { - // A variable declared in a for..in statement is always of type any + // A variable declared in a for..in statement is always of type string if (declaration.parent.parent.kind === SyntaxKind.ForInStatement) { - return anyType; + return stringType; } if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement) { @@ -12691,6 +12691,7 @@ namespace ts { } } + const isVariableInForInStatement = node.parent.parent.kind === SyntaxKind.ForInStatement; // For a binding pattern, check contained binding elements if (isBindingPattern(node.name)) { forEach((node.name).elements, checkSourceElement); @@ -12702,7 +12703,9 @@ namespace ts { } // For a binding pattern, validate the initializer and exit if (isBindingPattern(node.name)) { - if (node.initializer) { + // do not check initializer if this is variable in ForIn statement. + // this situation is already illegal so no need to report misleading errors. + if (node.initializer && !isVariableInForInStatement) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -12712,7 +12715,9 @@ namespace ts { const type = getTypeOfVariableOrParameterOrProperty(symbol); if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer - if (node.initializer) { + // NOTE: do not check initializer if this is variable in ForIn statement. + // this situation is already illegal so no need to report misleading errors. + if (node.initializer && !isVariableInForInStatement) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } diff --git a/tests/baselines/reference/capturedLetConstInLoop1.types b/tests/baselines/reference/capturedLetConstInLoop1.types index c68f2422f4346..bed3db55d7cf2 100644 --- a/tests/baselines/reference/capturedLetConstInLoop1.types +++ b/tests/baselines/reference/capturedLetConstInLoop1.types @@ -1,18 +1,18 @@ === tests/cases/compiler/capturedLetConstInLoop1.ts === //==== let for (let x in {}) { ->x : any +>x : string >{} : {} (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string } for (let x of []) { @@ -216,18 +216,18 @@ for (let y = 0; y < 1; ++y) { //=========const for (const x in {}) { ->x : any +>x : string >{} : {} (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string } for (const x of []) { diff --git a/tests/baselines/reference/capturedLetConstInLoop1_ES6.types b/tests/baselines/reference/capturedLetConstInLoop1_ES6.types index 5e25e1f930d47..47b125866849c 100644 --- a/tests/baselines/reference/capturedLetConstInLoop1_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop1_ES6.types @@ -1,18 +1,18 @@ === tests/cases/compiler/capturedLetConstInLoop1_ES6.ts === //==== let for (let x in {}) { ->x : any +>x : string >{} : {} (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string } for (let x of []) { @@ -216,18 +216,18 @@ for (let y = 0; y < 1; ++y) { //=========const for (const x in {}) { ->x : any +>x : string >{} : {} (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string } for (const x of []) { diff --git a/tests/baselines/reference/capturedLetConstInLoop2.types b/tests/baselines/reference/capturedLetConstInLoop2.types index 5108fc399eee2..2872eb4c763f8 100644 --- a/tests/baselines/reference/capturedLetConstInLoop2.types +++ b/tests/baselines/reference/capturedLetConstInLoop2.types @@ -37,7 +37,7 @@ function foo0_1(x) { >x : any for (let x in []) { ->x : any +>x : string >[] : undefined[] let a = arguments.length; @@ -47,17 +47,17 @@ function foo0_1(x) { >length : number (function() { return x + a }); ->(function() { return x + a }) : () => any ->function() { return x + a } : () => any ->x + a : any ->x : any +>(function() { return x + a }) : () => string +>function() { return x + a } : () => string +>x + a : string +>x : string >a : number (() => x + a); ->(() => x + a) : () => any ->() => x + a : () => any ->x + a : any ->x : any +>(() => x + a) : () => string +>() => x + a : () => string +>x + a : string +>x : string >a : number } } @@ -400,7 +400,7 @@ function foo0_1_c(x) { >x : any for (const x in []) { ->x : any +>x : string >[] : undefined[] const a = arguments.length; @@ -410,17 +410,17 @@ function foo0_1_c(x) { >length : number (function() { return x + a }); ->(function() { return x + a }) : () => any ->function() { return x + a } : () => any ->x + a : any ->x : any +>(function() { return x + a }) : () => string +>function() { return x + a } : () => string +>x + a : string +>x : string >a : number (() => x + a); ->(() => x + a) : () => any ->() => x + a : () => any ->x + a : any ->x : any +>(() => x + a) : () => string +>() => x + a : () => string +>x + a : string +>x : string >a : number } } diff --git a/tests/baselines/reference/capturedLetConstInLoop2_ES6.types b/tests/baselines/reference/capturedLetConstInLoop2_ES6.types index 9fea265da44ba..8a4d9c826285e 100644 --- a/tests/baselines/reference/capturedLetConstInLoop2_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop2_ES6.types @@ -36,7 +36,7 @@ function foo0_1(x) { >x : any for (let x in []) { ->x : any +>x : string >[] : undefined[] let a = arguments.length; @@ -46,17 +46,17 @@ function foo0_1(x) { >length : number (function() { return x + a }); ->(function() { return x + a }) : () => any ->function() { return x + a } : () => any ->x + a : any ->x : any +>(function() { return x + a }) : () => string +>function() { return x + a } : () => string +>x + a : string +>x : string >a : number (() => x + a); ->(() => x + a) : () => any ->() => x + a : () => any ->x + a : any ->x : any +>(() => x + a) : () => string +>() => x + a : () => string +>x + a : string +>x : string >a : number } } @@ -399,7 +399,7 @@ function foo0_1_c(x) { >x : any for (const x in []) { ->x : any +>x : string >[] : undefined[] const a = arguments.length; @@ -409,17 +409,17 @@ function foo0_1_c(x) { >length : number (function() { return x + a }); ->(function() { return x + a }) : () => any ->function() { return x + a } : () => any ->x + a : any ->x : any +>(function() { return x + a }) : () => string +>function() { return x + a } : () => string +>x + a : string +>x : string >a : number (() => x + a); ->(() => x + a) : () => any ->() => x + a : () => any ->x + a : any ->x : any +>(() => x + a) : () => string +>() => x + a : () => string +>x + a : string +>x : string >a : number } } diff --git a/tests/baselines/reference/capturedLetConstInLoop3.types b/tests/baselines/reference/capturedLetConstInLoop3.types index 51646f5a98b41..9c0c188b7272b 100644 --- a/tests/baselines/reference/capturedLetConstInLoop3.types +++ b/tests/baselines/reference/capturedLetConstInLoop3.types @@ -42,32 +42,32 @@ function foo0_1(x) { >x : any for (let x in []) { ->x : any +>x : string >[] : undefined[] var v = x; ->v : any ->x : any +>v : string +>x : string (function() { return x + v }); ->(function() { return x + v }) : () => any ->function() { return x + v } : () => any ->x + v : any ->x : any ->v : any +>(function() { return x + v }) : () => string +>function() { return x + v } : () => string +>x + v : string +>x : string +>v : string (() => x + v); ->(() => x + v) : () => any ->() => x + v : () => any ->x + v : any ->x : any ->v : any +>(() => x + v) : () => string +>() => x + v : () => string +>x + v : string +>x : string +>v : string } use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : string } function foo1(x) { @@ -438,32 +438,32 @@ function foo0_1_c(x) { >x : any for (const x in []) { ->x : any +>x : string >[] : undefined[] var v = x; ->v : any ->x : any +>v : string +>x : string (function() { return x + v }); ->(function() { return x + v }) : () => any ->function() { return x + v } : () => any ->x + v : any ->x : any ->v : any +>(function() { return x + v }) : () => string +>function() { return x + v } : () => string +>x + v : string +>x : string +>v : string (() => x + v); ->(() => x + v) : () => any ->() => x + v : () => any ->x + v : any ->x : any ->v : any +>(() => x + v) : () => string +>() => x + v : () => string +>x + v : string +>x : string +>v : string } use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : string } function foo1_c(x) { diff --git a/tests/baselines/reference/capturedLetConstInLoop3_ES6.types b/tests/baselines/reference/capturedLetConstInLoop3_ES6.types index cc4b57ff9ea46..03377d913c967 100644 --- a/tests/baselines/reference/capturedLetConstInLoop3_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop3_ES6.types @@ -43,32 +43,32 @@ function foo0_1(x) { >x : any for (let x in []) { ->x : any +>x : string >[] : undefined[] var v = x; ->v : any ->x : any +>v : string +>x : string (function() { return x + v }); ->(function() { return x + v }) : () => any ->function() { return x + v } : () => any ->x + v : any ->x : any ->v : any +>(function() { return x + v }) : () => string +>function() { return x + v } : () => string +>x + v : string +>x : string +>v : string (() => x + v); ->(() => x + v) : () => any ->() => x + v : () => any ->x + v : any ->x : any ->v : any +>(() => x + v) : () => string +>() => x + v : () => string +>x + v : string +>x : string +>v : string } use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : string } function foo1(x) { @@ -439,32 +439,32 @@ function foo0_1_c(x) { >x : any for (const x in []) { ->x : any +>x : string >[] : undefined[] var v = x; ->v : any ->x : any +>v : string +>x : string (function() { return x + v }); ->(function() { return x + v }) : () => any ->function() { return x + v } : () => any ->x + v : any ->x : any ->v : any +>(function() { return x + v }) : () => string +>function() { return x + v } : () => string +>x + v : string +>x : string +>v : string (() => x + v); ->(() => x + v) : () => any ->() => x + v : () => any ->x + v : any ->x : any ->v : any +>(() => x + v) : () => string +>() => x + v : () => string +>x + v : string +>x : string +>v : string } use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : string } function foo1_c(x) { diff --git a/tests/baselines/reference/capturedLetConstInLoop4.types b/tests/baselines/reference/capturedLetConstInLoop4.types index f19e5d109b874..1bc928cefe447 100644 --- a/tests/baselines/reference/capturedLetConstInLoop4.types +++ b/tests/baselines/reference/capturedLetConstInLoop4.types @@ -2,20 +2,20 @@ //======let export function exportedFoo() { ->exportedFoo : () => any +>exportedFoo : () => string return v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8; ->v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 : any ->v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 : any ->v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 : any ->v0 + v00 + v1 + v2 + v3 + v4 + v5 : any ->v0 + v00 + v1 + v2 + v3 + v4 : any ->v0 + v00 + v1 + v2 + v3 : any ->v0 + v00 + v1 + v2 : any ->v0 + v00 + v1 : any ->v0 + v00 : any +>v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 : string +>v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 : string +>v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 : string +>v0 + v00 + v1 + v2 + v3 + v4 + v5 : string +>v0 + v00 + v1 + v2 + v3 + v4 : string +>v0 + v00 + v1 + v2 + v3 : string +>v0 + v00 + v1 + v2 : string +>v0 + v00 + v1 : string +>v0 + v00 : string >v0 : any ->v00 : any +>v00 : string >v1 : number >v2 : any >v3 : any @@ -48,24 +48,24 @@ for (let x of []) { } for (let x in []) { ->x : any +>x : string >[] : undefined[] var v00 = x; ->v00 : any ->x : any +>v00 : string +>x : string (function() { return x + v00}); ->(function() { return x + v00}) : () => any ->function() { return x + v00} : () => any ->x + v00 : any ->x : any ->v00 : any +>(function() { return x + v00}) : () => string +>function() { return x + v00} : () => string +>x + v00 : string +>x : string +>v00 : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string } for (let x = 0; x < 1; ++x) { @@ -302,20 +302,20 @@ for (let y = 0; y < 1; ++y) { //======const export function exportedFoo2() { ->exportedFoo2 : () => any +>exportedFoo2 : () => string return v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c; ->v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c : any ->v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c : any ->v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c : any ->v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c : any ->v0_c + v00_c + v1_c + v2_c + v3_c + v4_c : any ->v0_c + v00_c + v1_c + v2_c + v3_c : any ->v0_c + v00_c + v1_c + v2_c : any ->v0_c + v00_c + v1_c : any ->v0_c + v00_c : any +>v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c : string +>v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c : string +>v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c : string +>v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c : string +>v0_c + v00_c + v1_c + v2_c + v3_c + v4_c : string +>v0_c + v00_c + v1_c + v2_c + v3_c : string +>v0_c + v00_c + v1_c + v2_c : string +>v0_c + v00_c + v1_c : string +>v0_c + v00_c : string >v0_c : any ->v00_c : any +>v00_c : string >v1_c : number >v2_c : number >v3_c : number @@ -348,24 +348,24 @@ for (const x of []) { } for (const x in []) { ->x : any +>x : string >[] : undefined[] var v00_c = x; ->v00_c : any ->x : any +>v00_c : string +>x : string (function() { return x + v00}); ->(function() { return x + v00}) : () => any ->function() { return x + v00} : () => any ->x + v00 : any ->x : any ->v00 : any +>(function() { return x + v00}) : () => string +>function() { return x + v00} : () => string +>x + v00 : string +>x : string +>v00 : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string } for (const x = 0; x < 1;) { diff --git a/tests/baselines/reference/capturedLetConstInLoop4_ES6.types b/tests/baselines/reference/capturedLetConstInLoop4_ES6.types index fd5f6dadf62ad..cf44c7b69819e 100644 --- a/tests/baselines/reference/capturedLetConstInLoop4_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop4_ES6.types @@ -2,20 +2,20 @@ //======let export function exportedFoo() { ->exportedFoo : () => any +>exportedFoo : () => string return v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8; ->v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 : any ->v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 : any ->v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 : any ->v0 + v00 + v1 + v2 + v3 + v4 + v5 : any ->v0 + v00 + v1 + v2 + v3 + v4 : any ->v0 + v00 + v1 + v2 + v3 : any ->v0 + v00 + v1 + v2 : any ->v0 + v00 + v1 : any ->v0 + v00 : any +>v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 : string +>v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 : string +>v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 : string +>v0 + v00 + v1 + v2 + v3 + v4 + v5 : string +>v0 + v00 + v1 + v2 + v3 + v4 : string +>v0 + v00 + v1 + v2 + v3 : string +>v0 + v00 + v1 + v2 : string +>v0 + v00 + v1 : string +>v0 + v00 : string >v0 : any ->v00 : any +>v00 : string >v1 : number >v2 : any >v3 : any @@ -48,24 +48,24 @@ for (let x of []) { } for (let x in []) { ->x : any +>x : string >[] : undefined[] var v00 = x; ->v00 : any ->x : any +>v00 : string +>x : string (function() { return x + v00}); ->(function() { return x + v00}) : () => any ->function() { return x + v00} : () => any ->x + v00 : any ->x : any ->v00 : any +>(function() { return x + v00}) : () => string +>function() { return x + v00} : () => string +>x + v00 : string +>x : string +>v00 : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string } for (let x = 0; x < 1; ++x) { @@ -302,20 +302,20 @@ for (let y = 0; y < 1; ++y) { //======const export function exportedFoo2() { ->exportedFoo2 : () => any +>exportedFoo2 : () => string return v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c; ->v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c : any ->v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c : any ->v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c : any ->v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c : any ->v0_c + v00_c + v1_c + v2_c + v3_c + v4_c : any ->v0_c + v00_c + v1_c + v2_c + v3_c : any ->v0_c + v00_c + v1_c + v2_c : any ->v0_c + v00_c + v1_c : any ->v0_c + v00_c : any +>v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c : string +>v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c : string +>v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c : string +>v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c : string +>v0_c + v00_c + v1_c + v2_c + v3_c + v4_c : string +>v0_c + v00_c + v1_c + v2_c + v3_c : string +>v0_c + v00_c + v1_c + v2_c : string +>v0_c + v00_c + v1_c : string +>v0_c + v00_c : string >v0_c : any ->v00_c : any +>v00_c : string >v1_c : number >v2_c : number >v3_c : number @@ -348,24 +348,24 @@ for (const x of []) { } for (const x in []) { ->x : any +>x : string >[] : undefined[] var v00_c = x; ->v00_c : any ->x : any +>v00_c : string +>x : string (function() { return x + v00}); ->(function() { return x + v00}) : () => any ->function() { return x + v00} : () => any ->x + v00 : any ->x : any ->v00 : any +>(function() { return x + v00}) : () => string +>function() { return x + v00} : () => string +>x + v00 : string +>x : string +>v00 : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string } for (const x = 0; x < 1;) { diff --git a/tests/baselines/reference/capturedLetConstInLoop5.js b/tests/baselines/reference/capturedLetConstInLoop5.js index d7d177a19b9c2..b73484cb430b0 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5.js +++ b/tests/baselines/reference/capturedLetConstInLoop5.js @@ -20,7 +20,7 @@ function foo00(x) { var v = x; (function() { return x + v }); (() => x + v); - if (x == 1) { + if (x == "1") { return; } } @@ -159,7 +159,7 @@ function foo00_c(x) { var v = x; (function() { return x + v }); (() => x + v); - if (x == 1) { + if (x == "1") { return; } } @@ -303,7 +303,7 @@ function foo00(x) { v = x_2; (function () { return x_2 + v; }); (function () { return x_2 + v; }); - if (x_2 == 1) { + if (x_2 == "1") { return { value: void 0 }; } }; @@ -471,7 +471,7 @@ function foo00_c(x) { v = x_12; (function () { return x_12 + v; }); (function () { return x_12 + v; }); - if (x_12 == 1) { + if (x_12 == "1") { return { value: void 0 }; } }; diff --git a/tests/baselines/reference/capturedLetConstInLoop5.symbols b/tests/baselines/reference/capturedLetConstInLoop5.symbols index 2d514e8c88cf4..965379d3a1123 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5.symbols +++ b/tests/baselines/reference/capturedLetConstInLoop5.symbols @@ -54,7 +54,7 @@ function foo00(x) { >x : Symbol(x, Decl(capturedLetConstInLoop5.ts, 17, 12)) >v : Symbol(v, Decl(capturedLetConstInLoop5.ts, 18, 11)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop5.ts, 17, 12)) return; @@ -395,7 +395,7 @@ function foo00_c(x) { >x : Symbol(x, Decl(capturedLetConstInLoop5.ts, 156, 14)) >v : Symbol(v, Decl(capturedLetConstInLoop5.ts, 157, 11)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop5.ts, 156, 14)) return; diff --git a/tests/baselines/reference/capturedLetConstInLoop5.types b/tests/baselines/reference/capturedLetConstInLoop5.types index 3654ffe5820e2..b7b4b880dc4c1 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5.types +++ b/tests/baselines/reference/capturedLetConstInLoop5.types @@ -50,31 +50,31 @@ function foo00(x) { >x : any for (let x in []) { ->x : any +>x : string >[] : undefined[] var v = x; ->v : any ->x : any +>v : string +>x : string (function() { return x + v }); ->(function() { return x + v }) : () => any ->function() { return x + v } : () => any ->x + v : any ->x : any ->v : any +>(function() { return x + v }) : () => string +>function() { return x + v } : () => string +>x + v : string +>x : string +>v : string (() => x + v); ->(() => x + v) : () => any ->() => x + v : () => any ->x + v : any ->x : any ->v : any +>(() => x + v) : () => string +>() => x + v : () => string +>x + v : string +>x : string +>v : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string return; } @@ -83,7 +83,7 @@ function foo00(x) { use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : string } function foo1(x) { @@ -525,31 +525,31 @@ function foo00_c(x) { >x : any for (const x in []) { ->x : any +>x : string >[] : undefined[] var v = x; ->v : any ->x : any +>v : string +>x : string (function() { return x + v }); ->(function() { return x + v }) : () => any ->function() { return x + v } : () => any ->x + v : any ->x : any ->v : any +>(function() { return x + v }) : () => string +>function() { return x + v } : () => string +>x + v : string +>x : string +>v : string (() => x + v); ->(() => x + v) : () => any ->() => x + v : () => any ->x + v : any ->x : any ->v : any +>(() => x + v) : () => string +>() => x + v : () => string +>x + v : string +>x : string +>v : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string return; } @@ -558,7 +558,7 @@ function foo00_c(x) { use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : string } function foo1_c(x) { diff --git a/tests/baselines/reference/capturedLetConstInLoop5_ES6.js b/tests/baselines/reference/capturedLetConstInLoop5_ES6.js index e5996bb305366..0f0624b8a8b6d 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop5_ES6.js @@ -21,7 +21,7 @@ function foo00(x) { var v = x; (function() { return x + v }); (() => x + v); - if (x == 1) { + if (x == "1") { return; } } @@ -160,7 +160,7 @@ function foo00_c(x) { var v = x; (function() { return x + v }); (() => x + v); - if (x == 1) { + if (x == "1") { return; } } @@ -298,7 +298,7 @@ function foo00(x) { var v = x; (function () { return x + v; }); (() => x + v); - if (x == 1) { + if (x == "1") { return; } } @@ -416,7 +416,7 @@ function foo00_c(x) { var v = x; (function () { return x + v; }); (() => x + v); - if (x == 1) { + if (x == "1") { return; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop5_ES6.symbols b/tests/baselines/reference/capturedLetConstInLoop5_ES6.symbols index b3d338ad60e0c..5b40cb4459958 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5_ES6.symbols +++ b/tests/baselines/reference/capturedLetConstInLoop5_ES6.symbols @@ -55,7 +55,7 @@ function foo00(x) { >x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 18, 12)) >v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 19, 11)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 18, 12)) return; @@ -396,7 +396,7 @@ function foo00_c(x) { >x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 157, 14)) >v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 158, 11)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 157, 14)) return; diff --git a/tests/baselines/reference/capturedLetConstInLoop5_ES6.types b/tests/baselines/reference/capturedLetConstInLoop5_ES6.types index 8db8ae25e9b86..855bbfc63086a 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop5_ES6.types @@ -51,31 +51,31 @@ function foo00(x) { >x : any for (let x in []) { ->x : any +>x : string >[] : undefined[] var v = x; ->v : any ->x : any +>v : string +>x : string (function() { return x + v }); ->(function() { return x + v }) : () => any ->function() { return x + v } : () => any ->x + v : any ->x : any ->v : any +>(function() { return x + v }) : () => string +>function() { return x + v } : () => string +>x + v : string +>x : string +>v : string (() => x + v); ->(() => x + v) : () => any ->() => x + v : () => any ->x + v : any ->x : any ->v : any +>(() => x + v) : () => string +>() => x + v : () => string +>x + v : string +>x : string +>v : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string return; } @@ -84,7 +84,7 @@ function foo00(x) { use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : string } function foo1(x) { @@ -526,31 +526,31 @@ function foo00_c(x) { >x : any for (const x in []) { ->x : any +>x : string >[] : undefined[] var v = x; ->v : any ->x : any +>v : string +>x : string (function() { return x + v }); ->(function() { return x + v }) : () => any ->function() { return x + v } : () => any ->x + v : any ->x : any ->v : any +>(function() { return x + v }) : () => string +>function() { return x + v } : () => string +>x + v : string +>x : string +>v : string (() => x + v); ->(() => x + v) : () => any ->() => x + v : () => any ->x + v : any ->x : any ->v : any +>(() => x + v) : () => string +>() => x + v : () => string +>x + v : string +>x : string +>v : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string return; } @@ -559,7 +559,7 @@ function foo00_c(x) { use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : string } function foo1_c(x) { diff --git a/tests/baselines/reference/capturedLetConstInLoop6.js b/tests/baselines/reference/capturedLetConstInLoop6.js index 187d9f10ad30e..ca3b634ef18de 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6.js +++ b/tests/baselines/reference/capturedLetConstInLoop6.js @@ -14,10 +14,10 @@ for (let x of []) { for (let x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 2) { + if (x == "2") { continue; } } @@ -133,10 +133,10 @@ for (const x of []) { for (const x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 2) { + if (x == "2") { continue; } } @@ -259,10 +259,10 @@ for (var _i = 0, _a = []; _i < _a.length; _i++) { var _loop_2 = function(x) { (function () { return x; }); (function () { return x; }); - if (x == 1) { + if (x == "1") { return "break"; } - if (x == 2) { + if (x == "2") { return "continue"; } }; @@ -417,10 +417,10 @@ for (var _b = 0, _c = []; _b < _c.length; _b++) { var _loop_12 = function(x) { (function () { return x; }); (function () { return x; }); - if (x == 1) { + if (x == "1") { return "break"; } - if (x == 2) { + if (x == "2") { return "continue"; } }; diff --git a/tests/baselines/reference/capturedLetConstInLoop6.symbols b/tests/baselines/reference/capturedLetConstInLoop6.symbols index 8d8e6d6ce5965..872bc3a4727b1 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6.symbols +++ b/tests/baselines/reference/capturedLetConstInLoop6.symbols @@ -30,12 +30,12 @@ for (let x in []) { (() => x); >x : Symbol(x, Decl(capturedLetConstInLoop6.ts, 12, 8)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop6.ts, 12, 8)) break; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop6.ts, 12, 8)) continue; @@ -272,12 +272,12 @@ for (const x in []) { (() => x); >x : Symbol(x, Decl(capturedLetConstInLoop6.ts, 131, 10)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop6.ts, 131, 10)) break; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop6.ts, 131, 10)) continue; diff --git a/tests/baselines/reference/capturedLetConstInLoop6.types b/tests/baselines/reference/capturedLetConstInLoop6.types index 6c31bdef31b98..f2b1103305fb8 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6.types +++ b/tests/baselines/reference/capturedLetConstInLoop6.types @@ -31,30 +31,30 @@ for (let x of []) { } for (let x in []) { ->x : any +>x : string >[] : undefined[] (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break; } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue; } @@ -396,30 +396,30 @@ for (const x of []) { } for (const x in []) { ->x : any +>x : string >[] : undefined[] (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break; } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue; } diff --git a/tests/baselines/reference/capturedLetConstInLoop6_ES6.js b/tests/baselines/reference/capturedLetConstInLoop6_ES6.js index 924f55b69153f..33d64e889276a 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop6_ES6.js @@ -14,10 +14,10 @@ for (let x of []) { for (let x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 2) { + if (x == "2") { continue; } } @@ -133,10 +133,10 @@ for (const x of []) { for (const x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 2) { + if (x == "2") { continue; } } @@ -253,10 +253,10 @@ for (let x of []) { for (let x in []) { (function () { return x; }); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 2) { + if (x == "2") { continue; } } @@ -360,10 +360,10 @@ for (const x of []) { for (const x in []) { (function () { return x; }); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 2) { + if (x == "2") { continue; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop6_ES6.symbols b/tests/baselines/reference/capturedLetConstInLoop6_ES6.symbols index acd557e471486..63cb26c4300ad 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6_ES6.symbols +++ b/tests/baselines/reference/capturedLetConstInLoop6_ES6.symbols @@ -30,12 +30,12 @@ for (let x in []) { (() => x); >x : Symbol(x, Decl(capturedLetConstInLoop6_ES6.ts, 12, 8)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop6_ES6.ts, 12, 8)) break; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop6_ES6.ts, 12, 8)) continue; @@ -272,12 +272,12 @@ for (const x in []) { (() => x); >x : Symbol(x, Decl(capturedLetConstInLoop6_ES6.ts, 131, 10)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop6_ES6.ts, 131, 10)) break; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop6_ES6.ts, 131, 10)) continue; diff --git a/tests/baselines/reference/capturedLetConstInLoop6_ES6.types b/tests/baselines/reference/capturedLetConstInLoop6_ES6.types index 87f21709120c4..cfd55a63aaab2 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop6_ES6.types @@ -31,30 +31,30 @@ for (let x of []) { } for (let x in []) { ->x : any +>x : string >[] : undefined[] (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break; } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue; } @@ -396,30 +396,30 @@ for (const x of []) { } for (const x in []) { ->x : any +>x : string >[] : undefined[] (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break; } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue; } diff --git a/tests/baselines/reference/capturedLetConstInLoop7.js b/tests/baselines/reference/capturedLetConstInLoop7.js index ce6769d2b1afb..6ec4ec1df447d 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7.js +++ b/tests/baselines/reference/capturedLetConstInLoop7.js @@ -22,16 +22,16 @@ l00: for (let x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 1) { + if (x == "1") { break l00; } - if (x == 2) { + if (x == "2") { continue; } - if (x == 2) { + if (x == "2") { continue l00; } } @@ -210,16 +210,16 @@ l00_c: for (const x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 1) { + if (x == "1") { break l00_c; } - if (x == 2) { + if (x == "2") { continue; } - if (x == 2) { + if (x == "2") { continue l00_c; } } @@ -406,16 +406,16 @@ l0: for (var _i = 0, _a = []; _i < _a.length; _i++) { var _loop_2 = function(x) { (function () { return x; }); (function () { return x; }); - if (x == 1) { + if (x == "1") { return "break"; } - if (x == 1) { + if (x == "1") { return "break-l00"; } - if (x == 2) { + if (x == "2") { return "continue"; } - if (x == 2) { + if (x == "2") { return "continue-l00"; } }; @@ -664,16 +664,16 @@ l0_c: for (var _b = 0, _c = []; _b < _c.length; _b++) { var _loop_12 = function(x) { (function () { return x; }); (function () { return x; }); - if (x == 1) { + if (x == "1") { return "break"; } - if (x == 1) { + if (x == "1") { return "break-l00_c"; } - if (x == 2) { + if (x == "2") { return "continue"; } - if (x == 2) { + if (x == "2") { return "continue-l00_c"; } }; diff --git a/tests/baselines/reference/capturedLetConstInLoop7.symbols b/tests/baselines/reference/capturedLetConstInLoop7.symbols index 2aa5ec2cd383c..0f4395a6d6873 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7.symbols +++ b/tests/baselines/reference/capturedLetConstInLoop7.symbols @@ -42,22 +42,22 @@ for (let x in []) { (() => x); >x : Symbol(x, Decl(capturedLetConstInLoop7.ts, 20, 8)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop7.ts, 20, 8)) break; } - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop7.ts, 20, 8)) break l00; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop7.ts, 20, 8)) continue; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop7.ts, 20, 8)) continue l00; @@ -393,22 +393,22 @@ for (const x in []) { (() => x); >x : Symbol(x, Decl(capturedLetConstInLoop7.ts, 208, 10)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop7.ts, 208, 10)) break; } - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop7.ts, 208, 10)) break l00_c; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop7.ts, 208, 10)) continue; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop7.ts, 208, 10)) continue l00_c; diff --git a/tests/baselines/reference/capturedLetConstInLoop7.types b/tests/baselines/reference/capturedLetConstInLoop7.types index 280985eae0f9e..29ea34e39a16b 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7.types +++ b/tests/baselines/reference/capturedLetConstInLoop7.types @@ -53,45 +53,45 @@ l00: >l00 : any for (let x in []) { ->x : any +>x : string >[] : undefined[] (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break; } - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break l00; >l00 : any } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue; } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue l00; >l00 : any @@ -607,45 +607,45 @@ l00_c: >l00_c : any for (const x in []) { ->x : any +>x : string >[] : undefined[] (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break; } - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break l00_c; >l00_c : any } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue; } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue l00_c; >l00_c : any diff --git a/tests/baselines/reference/capturedLetConstInLoop7_ES6.js b/tests/baselines/reference/capturedLetConstInLoop7_ES6.js index 4a2db64008121..13c69a883921f 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop7_ES6.js @@ -22,16 +22,16 @@ l00: for (let x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 1) { + if (x == "1") { break l00; } - if (x == 2) { + if (x == "2") { continue; } - if (x == 2) { + if (x == "2") { continue l00; } } @@ -210,16 +210,16 @@ l00_c: for (const x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 1) { + if (x == "1") { break l00_c; } - if (x == 2) { + if (x == "2") { continue; } - if (x == 2) { + if (x == "2") { continue l00_c; } } @@ -396,16 +396,16 @@ l0: for (let x of []) { l00: for (let x in []) { (function () { return x; }); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 1) { + if (x == "1") { break l00; } - if (x == 2) { + if (x == "2") { continue; } - if (x == 2) { + if (x == "2") { continue l00; } } @@ -563,16 +563,16 @@ l0_c: for (const x of []) { l00_c: for (const x in []) { (function () { return x; }); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 1) { + if (x == "1") { break l00_c; } - if (x == 2) { + if (x == "2") { continue; } - if (x == 2) { + if (x == "2") { continue l00_c; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop7_ES6.symbols b/tests/baselines/reference/capturedLetConstInLoop7_ES6.symbols index 51131f421bae9..a817377834ba8 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7_ES6.symbols +++ b/tests/baselines/reference/capturedLetConstInLoop7_ES6.symbols @@ -42,22 +42,22 @@ for (let x in []) { (() => x); >x : Symbol(x, Decl(capturedLetConstInLoop7_ES6.ts, 20, 8)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop7_ES6.ts, 20, 8)) break; } - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop7_ES6.ts, 20, 8)) break l00; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop7_ES6.ts, 20, 8)) continue; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop7_ES6.ts, 20, 8)) continue l00; @@ -393,22 +393,22 @@ for (const x in []) { (() => x); >x : Symbol(x, Decl(capturedLetConstInLoop7_ES6.ts, 208, 10)) - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop7_ES6.ts, 208, 10)) break; } - if (x == 1) { + if (x == "1") { >x : Symbol(x, Decl(capturedLetConstInLoop7_ES6.ts, 208, 10)) break l00_c; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop7_ES6.ts, 208, 10)) continue; } - if (x == 2) { + if (x == "2") { >x : Symbol(x, Decl(capturedLetConstInLoop7_ES6.ts, 208, 10)) continue l00_c; diff --git a/tests/baselines/reference/capturedLetConstInLoop7_ES6.types b/tests/baselines/reference/capturedLetConstInLoop7_ES6.types index 56573fb492737..c72afb4194200 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop7_ES6.types @@ -53,45 +53,45 @@ l00: >l00 : any for (let x in []) { ->x : any +>x : string >[] : undefined[] (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break; } - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break l00; >l00 : any } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue; } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue l00; >l00 : any @@ -607,45 +607,45 @@ l00_c: >l00_c : any for (const x in []) { ->x : any +>x : string >[] : undefined[] (function() { return x}); ->(function() { return x}) : () => any ->function() { return x} : () => any ->x : any +>(function() { return x}) : () => string +>function() { return x} : () => string +>x : string (() => x); ->(() => x) : () => any ->() => x : () => any ->x : any +>(() => x) : () => string +>() => x : () => string +>x : string - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break; } - if (x == 1) { ->x == 1 : boolean ->x : any ->1 : number + if (x == "1") { +>x == "1" : boolean +>x : string +>"1" : string break l00_c; >l00_c : any } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue; } - if (x == 2) { ->x == 2 : boolean ->x : any ->2 : number + if (x == "2") { +>x == "2" : boolean +>x : string +>"2" : string continue l00_c; >l00_c : any diff --git a/tests/baselines/reference/destructuringInForIn.errors.txt b/tests/baselines/reference/destructuringInForIn.errors.txt new file mode 100644 index 0000000000000..2f05b31fe5d87 --- /dev/null +++ b/tests/baselines/reference/destructuringInForIn.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/destructuringInForIn.ts(1,10): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. + + +==== tests/cases/compiler/destructuringInForIn.ts (1 errors) ==== + for (let {toString, toLowerCase} in []) {} + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringInForIn.js b/tests/baselines/reference/destructuringInForIn.js new file mode 100644 index 0000000000000..0430a17b2ad63 --- /dev/null +++ b/tests/baselines/reference/destructuringInForIn.js @@ -0,0 +1,5 @@ +//// [destructuringInForIn.ts] +for (let {toString, toLowerCase} in []) {} + +//// [destructuringInForIn.js] +for (var _a = void 0, toString = _a.toString, toLowerCase = _a.toLowerCase in []) { } diff --git a/tests/baselines/reference/downlevelLetConst17.types b/tests/baselines/reference/downlevelLetConst17.types index 824abcc76be52..4f539835ada42 100644 --- a/tests/baselines/reference/downlevelLetConst17.types +++ b/tests/baselines/reference/downlevelLetConst17.types @@ -139,23 +139,23 @@ do { >true : boolean for (let x in []) { ->x : any +>x : string >[] : undefined[] use(x); >use(x) : any >use : (a: any) => any ->x : any +>x : string } for (const x in []) { ->x : any +>x : string >[] : undefined[] use(x); >use(x) : any >use : (a: any) => any ->x : any +>x : string } for (const x of []) { diff --git a/tests/baselines/reference/duplicateLocalVariable1.errors.txt b/tests/baselines/reference/duplicateLocalVariable1.errors.txt index 0a49c71e29bd0..90c5974cd2b6a 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.errors.txt +++ b/tests/baselines/reference/duplicateLocalVariable1.errors.txt @@ -2,10 +2,12 @@ tests/cases/compiler/duplicateLocalVariable1.ts(2,4): error TS1005: ';' expected tests/cases/compiler/duplicateLocalVariable1.ts(2,11): error TS1146: Declaration expected. tests/cases/compiler/duplicateLocalVariable1.ts(2,13): error TS2304: Cannot find name 'commonjs'. tests/cases/compiler/duplicateLocalVariable1.ts(12,14): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. -tests/cases/compiler/duplicateLocalVariable1.ts(187,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'any', but here has type 'number'. +tests/cases/compiler/duplicateLocalVariable1.ts(187,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. +tests/cases/compiler/duplicateLocalVariable1.ts(187,29): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. +tests/cases/compiler/duplicateLocalVariable1.ts(187,37): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. -==== tests/cases/compiler/duplicateLocalVariable1.ts (5 errors) ==== +==== tests/cases/compiler/duplicateLocalVariable1.ts (7 errors) ==== / /@module: commonjs ~ @@ -202,7 +204,11 @@ tests/cases/compiler/duplicateLocalVariable1.ts(187,22): error TS2403: Subsequen var bytes = []; for (var i = 0; i < 14; i++) { ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'any', but here has type 'number'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. + ~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. + ~ +!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. bytes.push(fb.readByte()); } var expected = [0xEF, 0xBB, 0xBF, 0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]; diff --git a/tests/baselines/reference/duplicateLocalVariable2.errors.txt b/tests/baselines/reference/duplicateLocalVariable2.errors.txt index 0fbe0018bf881..5e89cc422cce9 100644 --- a/tests/baselines/reference/duplicateLocalVariable2.errors.txt +++ b/tests/baselines/reference/duplicateLocalVariable2.errors.txt @@ -1,7 +1,9 @@ -tests/cases/compiler/duplicateLocalVariable2.ts(27,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'any', but here has type 'number'. +tests/cases/compiler/duplicateLocalVariable2.ts(27,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. +tests/cases/compiler/duplicateLocalVariable2.ts(27,29): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. +tests/cases/compiler/duplicateLocalVariable2.ts(27,37): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. -==== tests/cases/compiler/duplicateLocalVariable2.ts (1 errors) ==== +==== tests/cases/compiler/duplicateLocalVariable2.ts (3 errors) ==== export class TestCase { constructor (public name: string, public test: ()=>boolean, public errorMessageRegEx?: string) { } @@ -30,7 +32,11 @@ tests/cases/compiler/duplicateLocalVariable2.ts(27,22): error TS2403: Subsequent var bytes = []; for (var i = 0; i < 14; i++) { ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'any', but here has type 'number'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. + ~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. + ~ +!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. bytes.push(fb.readByte()); } var expected = [0xEF]; diff --git a/tests/baselines/reference/for-inStatementsDestructuring.errors.txt b/tests/baselines/reference/for-inStatementsDestructuring.errors.txt index e540b182cf5e7..e54f2c93272a3 100644 --- a/tests/baselines/reference/for-inStatementsDestructuring.errors.txt +++ b/tests/baselines/reference/for-inStatementsDestructuring.errors.txt @@ -1,7 +1,10 @@ +tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts(1,10): error TS2461: Type 'string' is not an array type. tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts(1,10): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. -==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts (1 errors) ==== +==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts (2 errors) ==== for (var [a, b] in []) {} ~~~~~~ +!!! error TS2461: Type 'string' is not an array type. + ~~~~~~ !!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. \ No newline at end of file diff --git a/tests/baselines/reference/for-inStatementsDestructuring2.errors.txt b/tests/baselines/reference/for-inStatementsDestructuring2.errors.txt index 56d2436d4c78f..7589610a64e35 100644 --- a/tests/baselines/reference/for-inStatementsDestructuring2.errors.txt +++ b/tests/baselines/reference/for-inStatementsDestructuring2.errors.txt @@ -1,7 +1,13 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts(1,10): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. +tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts(1,11): error TS2459: Type 'string' has no property 'a' and no string index signature. +tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts(1,14): error TS2459: Type 'string' has no property 'b' and no string index signature. -==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts (1 errors) ==== +==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts (3 errors) ==== for (var {a, b} in []) {} ~~~~~~ -!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. \ No newline at end of file +!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. + ~ +!!! error TS2459: Type 'string' has no property 'a' and no string index signature. + ~ +!!! error TS2459: Type 'string' has no property 'b' and no string index signature. \ No newline at end of file diff --git a/tests/baselines/reference/for-inStatementsInvalid.errors.txt b/tests/baselines/reference/for-inStatementsInvalid.errors.txt index 67e536a3069f7..86809b174bb94 100644 --- a/tests/baselines/reference/for-inStatementsInvalid.errors.txt +++ b/tests/baselines/reference/for-inStatementsInvalid.errors.txt @@ -1,22 +1,26 @@ -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(2,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(5,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(8,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(10,10): error TS2404: The left-hand side of a 'for...in' statement cannot use a type annotation. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(13,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(17,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(3,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(9,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(11,10): error TS2404: The left-hand side of a 'for...in' statement cannot use a type annotation. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(14,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(16,27): error TS7005: Variable 'e' implicitly has an 'any' type. tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(18,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(19,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(20,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(21,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(22,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(29,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(38,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(46,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(51,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(62,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(22,20): error TS7017: Index signature of object type implicitly has an 'any' type. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(22,27): error TS7017: Index signature of object type implicitly has an 'any' type. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(23,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(30,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(39,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(46,5): error TS7010: 'boz', which lacks return-type annotation, implicitly has an 'any' return type. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(47,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(52,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(63,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -==== tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts (16 errors) ==== +==== tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts (19 errors) ==== + var aNumber: number; for (aNumber in {}) { } ~~~~~~~ @@ -42,6 +46,8 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6 !!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. var c : string, d:string, e; + ~ +!!! error TS7005: Variable 'e' implicitly has an 'any' type. for (var x in c || d) { } ~~~~~~ @@ -56,8 +62,10 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6 ~~~~~~~~~~ !!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. for (var x in 42 ? d[x] : c[x]) { } - ~~~~~~~~~~~~~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. + ~~~~ +!!! error TS7017: Index signature of object type implicitly has an 'any' type. + ~~~~ +!!! error TS7017: Index signature of object type implicitly has an 'any' type. for (var x in c[23]) { } ~~~~~ !!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. @@ -88,6 +96,8 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6 class B extends A { boz() { + ~~~ +!!! error TS7010: 'boz', which lacks return-type annotation, implicitly has an 'any' return type. for (var x in this.biz()) { } ~~~~~~~~~~ !!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. diff --git a/tests/baselines/reference/for-inStatementsInvalid.js b/tests/baselines/reference/for-inStatementsInvalid.js index caec9bd1987ce..4654f1e10e48f 100644 --- a/tests/baselines/reference/for-inStatementsInvalid.js +++ b/tests/baselines/reference/for-inStatementsInvalid.js @@ -1,4 +1,5 @@ //// [for-inStatementsInvalid.ts] + var aNumber: number; for (aNumber in {}) { } diff --git a/tests/baselines/reference/forInBreakStatements.types b/tests/baselines/reference/forInBreakStatements.types index 7714429e5af42..4f4b9b3bef98a 100644 --- a/tests/baselines/reference/forInBreakStatements.types +++ b/tests/baselines/reference/forInBreakStatements.types @@ -1,7 +1,7 @@ === tests/cases/conformance/statements/breakStatements/forInBreakStatements.ts === for(var x in {}) { ->x : any +>x : string >{} : {} break; @@ -11,7 +11,7 @@ ONE: >ONE : any for(var x in {}) { ->x : any +>x : string >{} : {} break ONE; @@ -25,7 +25,7 @@ THREE: >THREE : any for(var x in {}) { ->x : any +>x : string >{} : {} break THREE; @@ -36,14 +36,14 @@ FOUR: >FOUR : any for(var x in {}) { ->x : any +>x : string >{} : {} FIVE: >FIVE : any for(var x in {}) { ->x : any +>x : string >{} : {} break FOUR; @@ -52,14 +52,14 @@ for(var x in {}) { } for(var x in {}) { ->x : any +>x : string >{} : {} SIX: >SIX : any for(var x in {}) break SIX; ->x : any +>x : string >{} : {} >SIX : any } @@ -68,11 +68,11 @@ SEVEN: >SEVEN : any for (var x in {}) for (var x in {}) for (var x in {}) break SEVEN; ->x : any +>x : string >{} : {} ->x : any +>x : string >{} : {} ->x : any +>x : string >{} : {} >SEVEN : any @@ -80,7 +80,7 @@ EIGHT: >EIGHT : any for (var x in {}){ ->x : any +>x : string >{} : {} var fn = function () { } diff --git a/tests/baselines/reference/forInContinueStatements.types b/tests/baselines/reference/forInContinueStatements.types index 572fd16053d33..e45cc7985429b 100644 --- a/tests/baselines/reference/forInContinueStatements.types +++ b/tests/baselines/reference/forInContinueStatements.types @@ -1,7 +1,7 @@ === tests/cases/conformance/statements/continueStatements/forInContinueStatements.ts === for(var x in {}) { ->x : any +>x : string >{} : {} continue; @@ -11,7 +11,7 @@ ONE: >ONE : any for(var x in {}) { ->x : any +>x : string >{} : {} continue ONE; @@ -25,7 +25,7 @@ THREE: >THREE : any for(var x in {}) { ->x : any +>x : string >{} : {} continue THREE; @@ -36,14 +36,14 @@ FOUR: >FOUR : any for(var x in {}) { ->x : any +>x : string >{} : {} FIVE: >FIVE : any for(var x in {}) { ->x : any +>x : string >{} : {} continue FOUR; @@ -52,14 +52,14 @@ for(var x in {}) { } for(var x in {}) { ->x : any +>x : string >{} : {} SIX: >SIX : any for(var x in {}) continue SIX; ->x : any +>x : string >{} : {} >SIX : any } @@ -68,11 +68,11 @@ SEVEN: >SEVEN : any for (var x in {}) for (var x in {}) for (var x in {}) continue SEVEN; ->x : any +>x : string >{} : {} ->x : any +>x : string >{} : {} ->x : any +>x : string >{} : {} >SEVEN : any @@ -80,7 +80,7 @@ EIGHT: >EIGHT : any for (var x in {}){ ->x : any +>x : string >{} : {} var fn = function () { } diff --git a/tests/baselines/reference/forInStatement1.types b/tests/baselines/reference/forInStatement1.types index 8ccacc9e2f77f..ed2e568a39ef1 100644 --- a/tests/baselines/reference/forInStatement1.types +++ b/tests/baselines/reference/forInStatement1.types @@ -3,6 +3,6 @@ var expr: any; >expr : any for (var a in expr) { ->a : any +>a : string >expr : any } diff --git a/tests/baselines/reference/forInStatement3.types b/tests/baselines/reference/forInStatement3.types index 1d3803065bd17..d3767790ed2e3 100644 --- a/tests/baselines/reference/forInStatement3.types +++ b/tests/baselines/reference/forInStatement3.types @@ -8,7 +8,7 @@ function F() { >T : T for (var a in expr) { ->a : any +>a : string >expr : T } } diff --git a/tests/baselines/reference/implicitAnyInCatch.types b/tests/baselines/reference/implicitAnyInCatch.types index cd0dd2d2423e2..015d41b123f68 100644 --- a/tests/baselines/reference/implicitAnyInCatch.types +++ b/tests/baselines/reference/implicitAnyInCatch.types @@ -12,7 +12,7 @@ try { } catch (error) { >2147024809 : number } for (var key in this) { } ->key : any +>key : string >this : any class C { @@ -22,7 +22,7 @@ class C { >temp : () => void for (var x in this) { ->x : any +>x : string >this : this } } diff --git a/tests/baselines/reference/inOperatorWithGeneric.types b/tests/baselines/reference/inOperatorWithGeneric.types index 2048e11082ab5..facdb7b50e246 100644 --- a/tests/baselines/reference/inOperatorWithGeneric.types +++ b/tests/baselines/reference/inOperatorWithGeneric.types @@ -9,7 +9,7 @@ class C { >T : T for (var p in x) { ->p : any +>p : string >x : T } } diff --git a/tests/baselines/reference/letDeclarations-es5.types b/tests/baselines/reference/letDeclarations-es5.types index 005e0b2615570..f6e8d418632d0 100644 --- a/tests/baselines/reference/letDeclarations-es5.types +++ b/tests/baselines/reference/letDeclarations-es5.types @@ -29,7 +29,7 @@ let l9 = 0, l10 :string = "", l11 = null; >null : null for(let l11 in {}) { } ->l11 : any +>l11 : string >{} : {} for(let l12 = 0; l12 < 9; l12++) { } diff --git a/tests/baselines/reference/letDeclarations.types b/tests/baselines/reference/letDeclarations.types index 55be4326b195e..bb20f895a14c5 100644 --- a/tests/baselines/reference/letDeclarations.types +++ b/tests/baselines/reference/letDeclarations.types @@ -29,7 +29,7 @@ let l9 = 0, l10 :string = "", l11 = null; >null : null for(let l11 in {}) { } ->l11 : any +>l11 : string >{} : {} for(let l12 = 0; l12 < 9; l12++) { } diff --git a/tests/baselines/reference/letInVarDeclOfForIn_ES5.types b/tests/baselines/reference/letInVarDeclOfForIn_ES5.types index ac1ca3f27c9a3..095ae16b91e9d 100644 --- a/tests/baselines/reference/letInVarDeclOfForIn_ES5.types +++ b/tests/baselines/reference/letInVarDeclOfForIn_ES5.types @@ -2,7 +2,7 @@ // should not be an error for (var let in [1,2,3]) {} ->let : any +>let : string >[1,2,3] : number[] >1 : number >2 : number @@ -10,7 +10,7 @@ for (var let in [1,2,3]) {} { for (var let in [1,2,3]) {} ->let : any +>let : string >[1,2,3] : number[] >1 : number >2 : number diff --git a/tests/baselines/reference/letInVarDeclOfForIn_ES6.types b/tests/baselines/reference/letInVarDeclOfForIn_ES6.types index 3c508bd8e2b9b..a5e2ce108db14 100644 --- a/tests/baselines/reference/letInVarDeclOfForIn_ES6.types +++ b/tests/baselines/reference/letInVarDeclOfForIn_ES6.types @@ -2,7 +2,7 @@ // should not be an error for (var let in [1,2,3]) {} ->let : any +>let : string >[1,2,3] : number[] >1 : number >2 : number @@ -10,7 +10,7 @@ for (var let in [1,2,3]) {} { for (var let in [1,2,3]) {} ->let : any +>let : string >[1,2,3] : number[] >1 : number >2 : number diff --git a/tests/baselines/reference/noImplicitAnyForIn.errors.txt b/tests/baselines/reference/noImplicitAnyForIn.errors.txt index 2fb8e5a410303..1eb50e2f887ce 100644 --- a/tests/baselines/reference/noImplicitAnyForIn.errors.txt +++ b/tests/baselines/reference/noImplicitAnyForIn.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/noImplicitAnyForIn.ts(5,19): error TS7017: Index signature of object type implicitly has an 'any' type. tests/cases/compiler/noImplicitAnyForIn.ts(8,18): error TS7017: Index signature of object type implicitly has an 'any' type. tests/cases/compiler/noImplicitAnyForIn.ts(15,18): error TS7017: Index signature of object type implicitly has an 'any' type. tests/cases/compiler/noImplicitAnyForIn.ts(21,9): error TS7005: Variable 'b' implicitly has an 'any' type. @@ -5,16 +6,18 @@ tests/cases/compiler/noImplicitAnyForIn.ts(29,5): error TS7005: Variable 'n' imp tests/cases/compiler/noImplicitAnyForIn.ts(31,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. -==== tests/cases/compiler/noImplicitAnyForIn.ts (5 errors) ==== +==== tests/cases/compiler/noImplicitAnyForIn.ts (6 errors) ==== var x: {}[] = [[1, 2, 3], ["hello"]]; for (var i in x) { for (var j in x[i]) { + ~~~~ +!!! error TS7017: Index signature of object type implicitly has an 'any' type. //Should yield an implicit 'any' error var _j = x[i][j]; - ~~~~~~~ + ~~~~ !!! error TS7017: Index signature of object type implicitly has an 'any' type. } diff --git a/tests/baselines/reference/parserES5ForOfStatement19.errors.txt b/tests/baselines/reference/parserES5ForOfStatement19.errors.txt new file mode 100644 index 0000000000000..9d0bb02f1efb5 --- /dev/null +++ b/tests/baselines/reference/parserES5ForOfStatement19.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement19.ts(1,16): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. + + +==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement19.ts (1 errors) ==== + for (var of in of) { } + ~~ +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement19.symbols b/tests/baselines/reference/parserES5ForOfStatement19.symbols deleted file mode 100644 index 93ba77e3db94c..0000000000000 --- a/tests/baselines/reference/parserES5ForOfStatement19.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement19.ts === -for (var of in of) { } ->of : Symbol(of, Decl(parserES5ForOfStatement19.ts, 0, 8)) ->of : Symbol(of, Decl(parserES5ForOfStatement19.ts, 0, 8)) - diff --git a/tests/baselines/reference/parserES5ForOfStatement19.types b/tests/baselines/reference/parserES5ForOfStatement19.types deleted file mode 100644 index 13abc7ae757b4..0000000000000 --- a/tests/baselines/reference/parserES5ForOfStatement19.types +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement19.ts === -for (var of in of) { } ->of : any ->of : any - diff --git a/tests/baselines/reference/parserES5ForOfStatement20.errors.txt b/tests/baselines/reference/parserES5ForOfStatement20.errors.txt index 4aee32394b60b..2bfc54590ad54 100644 --- a/tests/baselines/reference/parserES5ForOfStatement20.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement20.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement20.ts(1,10): error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement20.ts(1,20): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement20.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement20.ts (2 errors) ==== for (var of = 0 in of) { } ~~ -!!! error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer. \ No newline at end of file +!!! error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer. + ~~ +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement19.errors.txt b/tests/baselines/reference/parserForOfStatement19.errors.txt new file mode 100644 index 0000000000000..a111498efe709 --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement19.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement19.ts(1,16): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. + + +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement19.ts (1 errors) ==== + for (var of in of) { } + ~~ +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement19.symbols b/tests/baselines/reference/parserForOfStatement19.symbols deleted file mode 100644 index 1e123349e13c6..0000000000000 --- a/tests/baselines/reference/parserForOfStatement19.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement19.ts === -for (var of in of) { } ->of : Symbol(of, Decl(parserForOfStatement19.ts, 0, 8)) ->of : Symbol(of, Decl(parserForOfStatement19.ts, 0, 8)) - diff --git a/tests/baselines/reference/parserForOfStatement19.types b/tests/baselines/reference/parserForOfStatement19.types deleted file mode 100644 index 6fcc5e8f79216..0000000000000 --- a/tests/baselines/reference/parserForOfStatement19.types +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement19.ts === -for (var of in of) { } ->of : any ->of : any - diff --git a/tests/baselines/reference/parserForOfStatement20.errors.txt b/tests/baselines/reference/parserForOfStatement20.errors.txt index 461f307f6b936..f2b6ac39a8332 100644 --- a/tests/baselines/reference/parserForOfStatement20.errors.txt +++ b/tests/baselines/reference/parserForOfStatement20.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement20.ts(1,10): error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement20.ts(1,20): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement20.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement20.ts (2 errors) ==== for (var of = 0 in of) { } ~~ -!!! error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer. \ No newline at end of file +!!! error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer. + ~~ +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. \ No newline at end of file diff --git a/tests/baselines/reference/recursiveLetConst.errors.txt b/tests/baselines/reference/recursiveLetConst.errors.txt index 88ecb379e5ef8..6d3f15880bb96 100644 --- a/tests/baselines/reference/recursiveLetConst.errors.txt +++ b/tests/baselines/reference/recursiveLetConst.errors.txt @@ -5,13 +5,14 @@ tests/cases/compiler/recursiveLetConst.ts(5,14): error TS2448: Block-scoped vari tests/cases/compiler/recursiveLetConst.ts(6,14): error TS2448: Block-scoped variable 'v' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(7,1): error TS7027: Unreachable code detected. tests/cases/compiler/recursiveLetConst.ts(7,16): error TS2448: Block-scoped variable 'v' used before its declaration. +tests/cases/compiler/recursiveLetConst.ts(8,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. tests/cases/compiler/recursiveLetConst.ts(8,15): error TS2448: Block-scoped variable 'v' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(9,15): error TS2448: Block-scoped variable 'v' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(10,17): error TS2448: Block-scoped variable 'v' used before its declaration. tests/cases/compiler/recursiveLetConst.ts(11,11): error TS2448: Block-scoped variable 'x2' used before its declaration. -==== tests/cases/compiler/recursiveLetConst.ts (11 errors) ==== +==== tests/cases/compiler/recursiveLetConst.ts (12 errors) ==== 'use strict' let x = x + 1; ~ @@ -35,6 +36,8 @@ tests/cases/compiler/recursiveLetConst.ts(11,11): error TS2448: Block-scoped var !!! error TS2448: Block-scoped variable 'v' used before its declaration. for (let v in v) { } ~ +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. + ~ !!! error TS2448: Block-scoped variable 'v' used before its declaration. for (let v of v) { } ~ diff --git a/tests/baselines/reference/throwInEnclosingStatements.types b/tests/baselines/reference/throwInEnclosingStatements.types index 568fd800e353f..32f0fb093bcd9 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.types +++ b/tests/baselines/reference/throwInEnclosingStatements.types @@ -51,9 +51,9 @@ for (var i = 0; ;) { throw i; } >i : number for (var idx in {}) { throw idx; } ->idx : any +>idx : string >{} : {} ->idx : any +>idx : string do { throw null; }while(true) >null : null diff --git a/tests/baselines/reference/variableTypeInForInStatement.js b/tests/baselines/reference/variableTypeInForInStatement.js new file mode 100644 index 0000000000000..686b114a26e4f --- /dev/null +++ b/tests/baselines/reference/variableTypeInForInStatement.js @@ -0,0 +1,18 @@ +//// [variableTypeInForInStatement.ts] +let x = {}; +for (const c in x) { + +} + +let arr = [1]; +for (const c in arr) { + +} + +//// [variableTypeInForInStatement.js] +var x = {}; +for (var c in x) { +} +var arr = [1]; +for (var c in arr) { +} diff --git a/tests/baselines/reference/variableTypeInForInStatement.symbols b/tests/baselines/reference/variableTypeInForInStatement.symbols new file mode 100644 index 0000000000000..1f7fe19f6552c --- /dev/null +++ b/tests/baselines/reference/variableTypeInForInStatement.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/variableTypeInForInStatement.ts === +let x = {}; +>x : Symbol(x, Decl(variableTypeInForInStatement.ts, 0, 3)) + +for (const c in x) { +>c : Symbol(c, Decl(variableTypeInForInStatement.ts, 1, 10)) +>x : Symbol(x, Decl(variableTypeInForInStatement.ts, 0, 3)) + +} + +let arr = [1]; +>arr : Symbol(arr, Decl(variableTypeInForInStatement.ts, 5, 3)) + +for (const c in arr) { +>c : Symbol(c, Decl(variableTypeInForInStatement.ts, 6, 10)) +>arr : Symbol(arr, Decl(variableTypeInForInStatement.ts, 5, 3)) + +} diff --git a/tests/baselines/reference/variableTypeInForInStatement.types b/tests/baselines/reference/variableTypeInForInStatement.types new file mode 100644 index 0000000000000..59483b636c403 --- /dev/null +++ b/tests/baselines/reference/variableTypeInForInStatement.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/variableTypeInForInStatement.ts === +let x = {}; +>x : {} +>{} : {} + +for (const c in x) { +>c : string +>x : {} + +} + +let arr = [1]; +>arr : number[] +>[1] : number[] +>1 : number + +for (const c in arr) { +>c : string +>arr : number[] + +} diff --git a/tests/cases/compiler/capturedLetConstInLoop5.ts b/tests/cases/compiler/capturedLetConstInLoop5.ts index 475137c14ccb2..5eedd5aac85b7 100644 --- a/tests/cases/compiler/capturedLetConstInLoop5.ts +++ b/tests/cases/compiler/capturedLetConstInLoop5.ts @@ -19,7 +19,7 @@ function foo00(x) { var v = x; (function() { return x + v }); (() => x + v); - if (x == 1) { + if (x == "1") { return; } } @@ -158,7 +158,7 @@ function foo00_c(x) { var v = x; (function() { return x + v }); (() => x + v); - if (x == 1) { + if (x == "1") { return; } } diff --git a/tests/cases/compiler/capturedLetConstInLoop5_ES6.ts b/tests/cases/compiler/capturedLetConstInLoop5_ES6.ts index 035e21b9e841c..224ffa823bf32 100644 --- a/tests/cases/compiler/capturedLetConstInLoop5_ES6.ts +++ b/tests/cases/compiler/capturedLetConstInLoop5_ES6.ts @@ -21,7 +21,7 @@ function foo00(x) { var v = x; (function() { return x + v }); (() => x + v); - if (x == 1) { + if (x == "1") { return; } } @@ -160,7 +160,7 @@ function foo00_c(x) { var v = x; (function() { return x + v }); (() => x + v); - if (x == 1) { + if (x == "1") { return; } } diff --git a/tests/cases/compiler/capturedLetConstInLoop6.ts b/tests/cases/compiler/capturedLetConstInLoop6.ts index 321d20e3c2060..a854be4619527 100644 --- a/tests/cases/compiler/capturedLetConstInLoop6.ts +++ b/tests/cases/compiler/capturedLetConstInLoop6.ts @@ -13,10 +13,10 @@ for (let x of []) { for (let x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 2) { + if (x == "2") { continue; } } @@ -132,10 +132,10 @@ for (const x of []) { for (const x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 2) { + if (x == "2") { continue; } } diff --git a/tests/cases/compiler/capturedLetConstInLoop6_ES6.ts b/tests/cases/compiler/capturedLetConstInLoop6_ES6.ts index f43fe5851d226..ad10f1fcb74f7 100644 --- a/tests/cases/compiler/capturedLetConstInLoop6_ES6.ts +++ b/tests/cases/compiler/capturedLetConstInLoop6_ES6.ts @@ -14,10 +14,10 @@ for (let x of []) { for (let x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 2) { + if (x == "2") { continue; } } @@ -133,10 +133,10 @@ for (const x of []) { for (const x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 2) { + if (x == "2") { continue; } } diff --git a/tests/cases/compiler/capturedLetConstInLoop7.ts b/tests/cases/compiler/capturedLetConstInLoop7.ts index a1d35c4038b7b..12805411f969f 100644 --- a/tests/cases/compiler/capturedLetConstInLoop7.ts +++ b/tests/cases/compiler/capturedLetConstInLoop7.ts @@ -21,16 +21,16 @@ l00: for (let x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 1) { + if (x == "1") { break l00; } - if (x == 2) { + if (x == "2") { continue; } - if (x == 2) { + if (x == "2") { continue l00; } } @@ -209,16 +209,16 @@ l00_c: for (const x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 1) { + if (x == "1") { break l00_c; } - if (x == 2) { + if (x == "2") { continue; } - if (x == 2) { + if (x == "2") { continue l00_c; } } diff --git a/tests/cases/compiler/capturedLetConstInLoop7_ES6.ts b/tests/cases/compiler/capturedLetConstInLoop7_ES6.ts index 14b1d0c85af0a..2e2784f9a16c0 100644 --- a/tests/cases/compiler/capturedLetConstInLoop7_ES6.ts +++ b/tests/cases/compiler/capturedLetConstInLoop7_ES6.ts @@ -22,16 +22,16 @@ l00: for (let x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 1) { + if (x == "1") { break l00; } - if (x == 2) { + if (x == "2") { continue; } - if (x == 2) { + if (x == "2") { continue l00; } } @@ -210,16 +210,16 @@ l00_c: for (const x in []) { (function() { return x}); (() => x); - if (x == 1) { + if (x == "1") { break; } - if (x == 1) { + if (x == "1") { break l00_c; } - if (x == 2) { + if (x == "2") { continue; } - if (x == 2) { + if (x == "2") { continue l00_c; } } diff --git a/tests/cases/compiler/destructuringInForIn.ts b/tests/cases/compiler/destructuringInForIn.ts new file mode 100644 index 0000000000000..b31edd03996db --- /dev/null +++ b/tests/cases/compiler/destructuringInForIn.ts @@ -0,0 +1 @@ +for (let {toString, toLowerCase} in []) {} \ No newline at end of file diff --git a/tests/cases/compiler/variableTypeInForInStatement.ts b/tests/cases/compiler/variableTypeInForInStatement.ts new file mode 100644 index 0000000000000..b920530f2d3dc --- /dev/null +++ b/tests/cases/compiler/variableTypeInForInStatement.ts @@ -0,0 +1,9 @@ +let x = {}; +for (const c in x) { + +} + +let arr = [1]; +for (const c in arr) { + +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts b/tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts index f12f85e4705f7..c6cbeef28f9d3 100644 --- a/tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts +++ b/tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts @@ -1,3 +1,5 @@ +// @noImplicitAny: true + var aNumber: number; for (aNumber in {}) { } diff --git a/tests/cases/fourslash/forIn.ts b/tests/cases/fourslash/forIn.ts index e24e161d96b8c..855d35917c1de 100644 --- a/tests/cases/fourslash/forIn.ts +++ b/tests/cases/fourslash/forIn.ts @@ -5,4 +5,4 @@ goTo.marker(); -verify.quickInfoIs('var p: any', ""); +verify.quickInfoIs('var p: string', "");