You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ foo: number; bar: number; }'.
No index signature with a parameter of type 'string' was found on type '{ foo: number; bar: number; }'.
π Expected behavior
Indexing succeeds because in operator narrowed input to "foo" | "bar"
Additional information about the issue
I know that in the given example, data could simply be given a type of Record<string, number> but this is not an option when using JSON file imports.
The text was updated successfully, but these errors were encountered:
π Search Terms
index, object, literal
π Version & Regression Information
Tried 5.8.2 and 5.9.0-dev.20250323
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.8.2#code/MYewdgzgLgBAJgQygmBeGBvAUDGAzEEALhgEYAaHGAIwQCcSAmLAXwG4stRJYBLMAA4BXKCWh1+AczQwARARCyOvPDAAU-YXzDwkCAJSYq3aDABuCADZCApiTBCAttRt0ZiZAG1NIgLodcExBLGwA6SxBJNQtrG30OFiwgA
π» Code
π Actual behavior
π Expected behavior
Indexing succeeds because
in
operator narrowedinput
to"foo" | "bar"
Additional information about the issue
I know that in the given example, data could simply be given a type of
Record<string, number>
but this is not an option when using JSON file imports.The text was updated successfully, but these errors were encountered: