-
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
Cannot implement generic type guarding function #18202
Comments
When comparing two generic signatures, the source is instantiated in the context of the target then both are compared (see #16368 for more details). since the generic type parameter The core of the issue here is that is equivalent to casting. i would argue, you are better off casting and avoiding the runtime cost of a function that can not verify the type anyways. Alternatively, just use |
The other reason this does not work is that type guards are not an inference position. now that we are inferring from return type position, seems like we should do this too. |
TypeScript Version: 2.5.2
Code
Expected behavior:
Class Checker should be treated as a valid implementation (used to be in Ts-2.3).
Actual behavior:
Compiler complains:
(...)
The text was updated successfully, but these errors were encountered: