diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c579fadf9a0..b59395fe87c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22590,8 +22590,8 @@ namespace ts { // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.InstantiableNonPrimitive)) { - error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); + if (rightType === neverType || !isTypeAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.InstantiableNonPrimitive)) { + error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f0ce19ea1b3..5674e6dce0c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1372,7 +1372,7 @@ "category": "Error", "code": 2406 }, - "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { + "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type '{0}'.": { "category": "Error", "code": 2407 }, diff --git a/tests/baselines/reference/for-inStatements.errors.txt b/tests/baselines/reference/for-inStatements.errors.txt index c5ca29d2150..2ae4cdb79f0 100644 --- a/tests/baselines/reference/for-inStatements.errors.txt +++ b/tests/baselines/reference/for-inStatements.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(33,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'. tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(50,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'. -tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(79,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-inStatements.ts(79,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'Color.Blue'. ==== tests/cases/conformance/statements/for-inStatements/for-inStatements.ts (3 errors) ==== @@ -88,5 +88,5 @@ tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(79,15): for (var x in Color) { } for (var x in Color.Blue) { } ~~~~~~~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'Color.Blue'. \ 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 f98349973a3..3d7dd1c79f3 100644 --- a/tests/baselines/reference/for-inStatementsInvalid.errors.txt +++ b/tests/baselines/reference/for-inStatementsInvalid.errors.txt @@ -2,19 +2,19 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(2 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(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(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(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, but here has type 'void'. +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, but here has type 'string'. +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, but here has type 'string'. +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, but here has type 'string'. +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, but here has type 'string'. +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, but here has type 'string'. +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, but here has type 'number'. tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(31,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'. -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(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, but here has type 'number'. +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, but here has type 'number'. tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(48,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'. -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(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, but here has type 'number'. +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, but here has type 'number'. ==== tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts (17 errors) ==== @@ -40,26 +40,26 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6 function fn(): void { } for (var x in fn()) { } ~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'void'. var c : string, d:string, e; for (var x in c || d) { } ~~~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'string'. for (var x in e ? c : d) { } ~~~~~~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'string'. for (var x in 42 ? c : d) { } ~~~~~~~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'string'. for (var x in '' ? c : d) { } ~~~~~~~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'string'. for (var x in 42 ? d[x] : c[x]) { } 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. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'string'. for (var x in ((x: T) => x)) { } for (var x in function (x: string, y: number) { return x + y }) { } @@ -68,7 +68,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6 biz() : number{ 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. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'. for (var x in this.biz) { } for (var x in this) { } ~ @@ -81,7 +81,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6 for (var x in this.baz) { } for (var x in this.baz()) { } ~~~~~~~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'. return null; } @@ -91,7 +91,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6 boz() { 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. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'. for (var x in this.biz) { } for (var x in this) { } ~ @@ -100,7 +100,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6 for (var x in super.biz) { } for (var x in super.biz()) { } ~~~~~~~~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'. return null; } } @@ -113,5 +113,5 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6 for (var x in i[42]) { } ~~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/forIn2.errors.txt b/tests/baselines/reference/forIn2.errors.txt index f6a0b34e3e6..7bf5f95e4a0 100644 --- a/tests/baselines/reference/forIn2.errors.txt +++ b/tests/baselines/reference/forIn2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/forIn2.ts(1,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/forIn2.ts(1,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type '1'. ==== tests/cases/compiler/forIn2.ts (1 errors) ==== for (var i in 1) { ~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type '1'. } \ No newline at end of file diff --git a/tests/baselines/reference/forInStatement2.errors.txt b/tests/baselines/reference/forInStatement2.errors.txt index 575936eab5e..5ab7742707b 100644 --- a/tests/baselines/reference/forInStatement2.errors.txt +++ b/tests/baselines/reference/forInStatement2.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/forInStatement2.ts(2,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/forInStatement2.ts(2,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'. ==== tests/cases/compiler/forInStatement2.ts (1 errors) ==== var expr: number; for (var a in expr) { ~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'. } \ No newline at end of file diff --git a/tests/baselines/reference/neverTypeErrors1.errors.txt b/tests/baselines/reference/neverTypeErrors1.errors.txt index e0746084de0..c0dd83fb1cc 100644 --- a/tests/baselines/reference/neverTypeErrors1.errors.txt +++ b/tests/baselines/reference/neverTypeErrors1.errors.txt @@ -9,9 +9,10 @@ tests/cases/conformance/types/never/neverTypeErrors1.ts(13,5): error TS2322: Typ tests/cases/conformance/types/never/neverTypeErrors1.ts(17,5): error TS2322: Type '1' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(20,16): error TS2534: A function returning 'never' cannot have a reachable end point. tests/cases/conformance/types/never/neverTypeErrors1.ts(23,17): error TS2488: Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator. +tests/cases/conformance/types/never/neverTypeErrors1.ts(24,17): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'never'. -==== tests/cases/conformance/types/never/neverTypeErrors1.ts (11 errors) ==== +==== tests/cases/conformance/types/never/neverTypeErrors1.ts (12 errors) ==== function f1() { let x: never; x = 1; @@ -57,4 +58,7 @@ tests/cases/conformance/types/never/neverTypeErrors1.ts(23,17): error TS2488: Ty for (const n of f4()) {} ~~~~ !!! error TS2488: Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator. + for (const n in f4()) {} + ~~~~ +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'never'. \ No newline at end of file diff --git a/tests/baselines/reference/neverTypeErrors1.js b/tests/baselines/reference/neverTypeErrors1.js index f05a3ce1c61..751975019ba 100644 --- a/tests/baselines/reference/neverTypeErrors1.js +++ b/tests/baselines/reference/neverTypeErrors1.js @@ -22,6 +22,7 @@ function f4(): never { } for (const n of f4()) {} +for (const n in f4()) {} //// [neverTypeErrors1.js] @@ -46,3 +47,4 @@ function f4() { for (var _i = 0, _a = f4(); _i < _a.length; _i++) { var n = _a[_i]; } +for (var n in f4()) { } diff --git a/tests/baselines/reference/neverTypeErrors1.symbols b/tests/baselines/reference/neverTypeErrors1.symbols index f565a4bf7b5..6c545be1d61 100644 --- a/tests/baselines/reference/neverTypeErrors1.symbols +++ b/tests/baselines/reference/neverTypeErrors1.symbols @@ -48,3 +48,7 @@ for (const n of f4()) {} >n : Symbol(n, Decl(neverTypeErrors1.ts, 22, 10)) >f4 : Symbol(f4, Decl(neverTypeErrors1.ts, 17, 1)) +for (const n in f4()) {} +>n : Symbol(n, Decl(neverTypeErrors1.ts, 23, 10)) +>f4 : Symbol(f4, Decl(neverTypeErrors1.ts, 17, 1)) + diff --git a/tests/baselines/reference/neverTypeErrors1.types b/tests/baselines/reference/neverTypeErrors1.types index 89dbf92e8f5..8fab8212f66 100644 --- a/tests/baselines/reference/neverTypeErrors1.types +++ b/tests/baselines/reference/neverTypeErrors1.types @@ -62,3 +62,8 @@ for (const n of f4()) {} >f4() : never >f4 : () => never +for (const n in f4()) {} +>n : string +>f4() : never +>f4 : () => never + diff --git a/tests/baselines/reference/neverTypeErrors2.errors.txt b/tests/baselines/reference/neverTypeErrors2.errors.txt index 4f5845917c5..b81323cbfbc 100644 --- a/tests/baselines/reference/neverTypeErrors2.errors.txt +++ b/tests/baselines/reference/neverTypeErrors2.errors.txt @@ -9,9 +9,10 @@ tests/cases/conformance/types/never/neverTypeErrors2.ts(13,5): error TS2322: Typ tests/cases/conformance/types/never/neverTypeErrors2.ts(17,5): error TS2322: Type '1' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(20,16): error TS2534: A function returning 'never' cannot have a reachable end point. tests/cases/conformance/types/never/neverTypeErrors2.ts(23,17): error TS2488: Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator. +tests/cases/conformance/types/never/neverTypeErrors2.ts(24,17): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'never'. -==== tests/cases/conformance/types/never/neverTypeErrors2.ts (11 errors) ==== +==== tests/cases/conformance/types/never/neverTypeErrors2.ts (12 errors) ==== function f1() { let x: never; x = 1; @@ -57,4 +58,7 @@ tests/cases/conformance/types/never/neverTypeErrors2.ts(23,17): error TS2488: Ty for (const n of f4()) {} ~~~~ !!! error TS2488: Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator. + for (const n in f4()) {} + ~~~~ +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'never'. \ No newline at end of file diff --git a/tests/baselines/reference/neverTypeErrors2.js b/tests/baselines/reference/neverTypeErrors2.js index dfe9f32b627..17a8a9eba98 100644 --- a/tests/baselines/reference/neverTypeErrors2.js +++ b/tests/baselines/reference/neverTypeErrors2.js @@ -22,6 +22,7 @@ function f4(): never { } for (const n of f4()) {} +for (const n in f4()) {} //// [neverTypeErrors2.js] @@ -46,3 +47,4 @@ function f4() { for (var _i = 0, _a = f4(); _i < _a.length; _i++) { var n = _a[_i]; } +for (var n in f4()) { } diff --git a/tests/baselines/reference/neverTypeErrors2.symbols b/tests/baselines/reference/neverTypeErrors2.symbols index ec6b0086ee7..3a450b60efd 100644 --- a/tests/baselines/reference/neverTypeErrors2.symbols +++ b/tests/baselines/reference/neverTypeErrors2.symbols @@ -48,3 +48,7 @@ for (const n of f4()) {} >n : Symbol(n, Decl(neverTypeErrors2.ts, 22, 10)) >f4 : Symbol(f4, Decl(neverTypeErrors2.ts, 17, 1)) +for (const n in f4()) {} +>n : Symbol(n, Decl(neverTypeErrors2.ts, 23, 10)) +>f4 : Symbol(f4, Decl(neverTypeErrors2.ts, 17, 1)) + diff --git a/tests/baselines/reference/neverTypeErrors2.types b/tests/baselines/reference/neverTypeErrors2.types index 510f32506bb..5bfae1f5201 100644 --- a/tests/baselines/reference/neverTypeErrors2.types +++ b/tests/baselines/reference/neverTypeErrors2.types @@ -62,3 +62,8 @@ for (const n of f4()) {} >f4() : never >f4 : () => never +for (const n in f4()) {} +>n : string +>f4() : never +>f4 : () => never + diff --git a/tests/baselines/reference/symbolType13.errors.txt b/tests/baselines/reference/symbolType13.errors.txt index 68981d0072b..9f1688fe935 100644 --- a/tests/baselines/reference/symbolType13.errors.txt +++ b/tests/baselines/reference/symbolType13.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/Symbols/symbolType13.ts(4,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. -tests/cases/conformance/es6/Symbols/symbolType13.ts(5,11): 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/es6/Symbols/symbolType13.ts(6,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/es6/Symbols/symbolType13.ts(5,11): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType13.ts(6,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'symbol'. ==== tests/cases/conformance/es6/Symbols/symbolType13.ts (3 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/es6/Symbols/symbolType13.ts(6,15): error TS2407: The rig !!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. for (x in s) { } ~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'symbol'. for (var y in s) { } ~ -!!! 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 +!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'symbol'. \ No newline at end of file diff --git a/tests/cases/conformance/types/never/neverTypeErrors1.ts b/tests/cases/conformance/types/never/neverTypeErrors1.ts index 20c9daf9e3b..44435d5203d 100644 --- a/tests/cases/conformance/types/never/neverTypeErrors1.ts +++ b/tests/cases/conformance/types/never/neverTypeErrors1.ts @@ -21,3 +21,4 @@ function f4(): never { } for (const n of f4()) {} +for (const n in f4()) {} diff --git a/tests/cases/conformance/types/never/neverTypeErrors2.ts b/tests/cases/conformance/types/never/neverTypeErrors2.ts index 66f12d7d322..c9c37dcb15d 100644 --- a/tests/cases/conformance/types/never/neverTypeErrors2.ts +++ b/tests/cases/conformance/types/never/neverTypeErrors2.ts @@ -23,3 +23,4 @@ function f4(): never { } for (const n of f4()) {} +for (const n in f4()) {}