-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
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
Union of Record<string, string>
and interface can't be indexed by string
#51478
Comments
|
It would be wrong to infer const x = { key: 42, pigz: true }
const k = "pigz";
const obj: t = x;
console.log(obj[k]); // prints true (a boolean) at runtime. When you have something typed |
ah you're right, what i want is probably |
Wait, so you're trying to represent a type which is otherwise a Based on your use case, this appears to be a duplicate of #15151/#17867. |
@antonilol In this specific case, if all you care about is getting |
Bug Report
π Search Terms
π Version & Regression Information
error on all version ts playground let me choose
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Record<string, string> | { key: number }
can be indexed withstring
π Expected behavior
const v
's type was successfully inferred asstring | number
The text was updated successfully, but these errors were encountered: