-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
add an option that flags coercion #7746
Comments
Your first example is identical to a suggestion you've already logged. Your second example doesn't typecheck. |
|
another example out of the oven // before
declare function toBypassReasons(): string[];
let message = toBypassReasons().join(', ');
// after refactoring
interface BypassReason { reason: string; ruleKey: string; }
declare function toBypassReasons() : BypassReason[];
let message = toBypassReasons().join(', '); // <-- bug |
There is literally zero coercion in that example. You'd need completely different mechanics (somehow disallowing certain methods when a type parameter is one value vs another) to detect that "bug" vs the other two examples. |
closing in favor of #7989 |
Tracking a new issue at #9041 that solves some of these cases |
There is a category of bugs caused by unintended coercion at runtime. Such bugs can be found by the compiler. Having an option that bans such coercion would be a great addition.
examples of the problem:
The text was updated successfully, but these errors were encountered: