-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
const wrong = () => (1 < 3) as true // type: () => true
this should be an error.
#58636
Comments
Maybe I'm just slow today, but why should this trigger an error? |
@dragomirtitian This is just a guess but maybe OP expects an error because |
I should have been more clear. as @fatcerberus mentioned, I was expecting the above code to be an error, since the |
Note that all of these are valid... const a = false as true;
const b = 'x' as 'y';
const c = 1 as 2; |
Why is |
This is working as intended. Using a type assertion you tell the compiler "shh.. trust me, it's this type, I know what I'm doing..." @KDwevedi They surely mean the |
I'm amazed that people figured out what this issue meant. My brain was imploding trying to understand what could possibly have been the bug: "Why would the |
3 is always cutting in front of 1 and 2, he thinks he's so important having his visage plastered everywhere. Still better than that jerk 7. 6 still needs therapy to this day after witnessing |
This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
π Search Terms
π Version & Regression Information
β― Playground Link
https://
π» Code
π Actual behavior
This doesn't trigger a TS error.
π Expected behavior
It should.
Additional information about the issue
I know this would be a hard challenge to solve, but I thought you guys should at least know about it.
The text was updated successfully, but these errors were encountered: