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.9
Code
export interface Dict<T> { [key: string]: T; } type a = Dict<boolean>; type b = keyof a;
Expected behavior:
b should be string
b
string
Actual behavior:
b is string | number
string | number
Maybe there is a simple fix to this but I cannot find anything. My temporary fix is to use "keyofStringsOnly": true.
"keyofStringsOnly": true
Playground Link:
http://www.typescriptlang.org/play/#src=export%20interface%20Dict%3CT%3E%20%7B%0D%0A%20%20%5Bkey%3A%20string%5D%3A%20T%3B%0D%0A%7D%0D%0A%0D%0Atype%20a%20%3D%20Dict%3Cboolean%3E%3B%0D%0A%0D%0Atype%20b%20%3D%20keyof%20a%3B
Related Issues:
#24560 may be the same but I cannot tell.
The text was updated successfully, but these errors were encountered:
My use case works with Extract.
Extract
export const keys = Object.keys as <T>(o: T) => (Extract<keyof T, string>)[];
#12253
Sorry, something went wrong.
No branches or pull requests
TypeScript Version: 2.9
Code
Expected behavior:
b
should bestring
Actual behavior:
b
isstring | number
Maybe there is a simple fix to this but I cannot find anything. My temporary fix is to use
"keyofStringsOnly": true
.Playground Link:
http://www.typescriptlang.org/play/#src=export%20interface%20Dict%3CT%3E%20%7B%0D%0A%20%20%5Bkey%3A%20string%5D%3A%20T%3B%0D%0A%7D%0D%0A%0D%0Atype%20a%20%3D%20Dict%3Cboolean%3E%3B%0D%0A%0D%0Atype%20b%20%3D%20keyof%20a%3B
Related Issues:
#24560 may be the same but I cannot tell.
The text was updated successfully, but these errors were encountered: