mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-13 06:20:23 -06:00
Type of for-in variable is keyof T when object type is a type parameter
This commit is contained in:
parent
c5558482b7
commit
1710df5f28
@ -3216,11 +3216,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// A variable declared in a for..in statement is always of type string
|
||||
// A variable declared in a for..in statement is of type string, or of type keyof T when the
|
||||
// right hand expression is of a type parameter type.
|
||||
if (declaration.parent.parent.kind === SyntaxKind.ForInStatement) {
|
||||
// const indexType = getIndexType(checkNonNullExpression((<ForInStatement>declaration.parent.parent).expression));
|
||||
// return indexType.flags & TypeFlags.Index ? indexType : stringType;
|
||||
return stringType;
|
||||
const indexType = getIndexType(checkNonNullExpression((<ForInStatement>declaration.parent.parent).expression));
|
||||
return indexType.flags & TypeFlags.Index ? indexType : stringType;
|
||||
}
|
||||
|
||||
if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user