mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 02:15:10 -05:00
Error on for (const x in never) (#22988)
* Error on `for (const x in never)` * Update diagnostic * Provide argument to diagnostic
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user