We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript Version: 2.2.0
Code
function foo<T>() { let x: { [P in keyof T]: number } let y: { [k: string]: number } = x; }
Expected behavior:
The assigment should be allowed.
Actual behavior:
The assignment isn't allowed.
This is despite this variant working just fine:
let x: {[P in 'one' | 'two']: number } = null; let y: { [k: string]: number } = x;
And this works too, as just as the documentation states, keyof T is a subtype of string for all T:
keyof T
string
T
function foo<T>() { let kt: keyof T = '' as keyof T; let sn: string = kt; }
The text was updated successfully, but these errors were encountered:
See #14548
Sorry, something went wrong.
No branches or pull requests
TypeScript Version: 2.2.0
Code
Expected behavior:
The assigment should be allowed.
Actual behavior:
The assignment isn't allowed.
This is despite this variant working just fine:
And this works too, as just as the documentation states,
keyof T
is a subtype ofstring
for allT
:The text was updated successfully, but these errors were encountered: