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
typeMyType=[{foo: string}]|{bar: number};// This errors with type 'any' cannot be used as an index typetypeShouldError=MyType[any];// This does not error and silently creates an anytypeDoSomething<TextendsMyType>=T[any];typeWillBeAny=DoSomething<MyType>;
π Actual behavior
When using a generic type, typescript fails to error with error TS2538 which should say that type 'any' cannot be used as an index type, instead, it does not errors and silently turns the type indexed in [any] to a any itself.
π Expected behavior
I would expect typescript compilation to fail as it does when you directly access a type with any (in the example above as MyType[any] )
Additional information about the issue
This seems to be an issue from all versions I tested (several > 3.3). But I did not found an issue acknowledging this is either expected or indeed a bug.
The text was updated successfully, but these errors were encountered:
π Search Terms
TS2538 ts2538 silently fails
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.5.2#code/C4TwDgpgBAsiAq5oF4oG0DeAzA9jgXFAM7ABOAlgHYDmAvgLpQA+UGARgIamGUCuAtmwilaAbgBQ4gPRSo8ABbkiUYaRyllAd3LB5UUJCgByDpRBGoAY1OUcwKEKi8iEACZQOy01CquIAD30kcQNoAGV5HF4AG1cAUVI1UihUOERINFMQeglpWQUlKFccCGVbe1V1D0p3InJoiEpgaJArUggOYFLq6pAQpCgAERwwnH4IXSpqAB54FX8umuU0pAA+FLlMsxz+wwB1euiAIQgAQTMN4dHxyZpplchV0SA
π» Code
π Actual behavior
When using a generic type, typescript fails to error with error TS2538 which should say that
type 'any' cannot be used as an index type
, instead, it does not errors and silently turns the type indexed in[any]
to a any itself.π Expected behavior
I would expect typescript compilation to fail as it does when you directly access a type with any (in the example above as
MyType[any]
)Additional information about the issue
This seems to be an issue from all versions I tested (several > 3.3). But I did not found an issue acknowledging this is either expected or indeed a bug.
The text was updated successfully, but these errors were encountered: