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
wotan complains about the as string being a useless assertion. However when I remove it, the type of bar changes to unknown, making the last line illegal.
The text was updated successfully, but these errors were encountered:
TL;DR: this not only occurs when disabling no-misused-generics, but every time a call(like) expression has no inference candidate for a type parameter used in the return type. Instead of using the declared fallback the type is inferred from the contextual type. In this case the contextual type comes from the type assertion. If you remove the assertion, there's no contextual type and therefore the type parameter default applies.
You can work around this design limitation by providing the contextual type by any other means:
constbar: string=foo();// 'T' is inferred as 'string'
I don't think this can be fixed in this project. If you care enough about this issue, please consider opening a new issue with TypeScript.
Consider the following code:
wotan
complains about theas string
being a useless assertion. However when I remove it, the type ofbar
changes tounknown
, making the last line illegal.The text was updated successfully, but these errors were encountered: