-
Notifications
You must be signed in to change notification settings - Fork 12.8k
[Feature Request] Flag for disabling implicit coerisions #39209
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
Comments
We're not going to add a flag that causes errors on |
It is not duplicate I am not taking about I want to enforce users to write by default safe code, that's all It is possible by enforcing users to use only let strange_number: any = 2;
let strange_string: string = "1";
console.log(String(strange_number) == strange_string); or let strange_number: any = 2;
let strange_string: string = "1";
console.log(Number(strange_number) == Number(strange_string)); |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
@RyanCavanaugh Have you seen my comment ? Will you remove tag |
@ahejlsberg I just want to call to you as Lead of the language ... Don't you think this Feature Request should be implemented ? This very useful that make |
@redradist We're tracking this adequately; thank you for the feedback. See also #38905 |
Search Terms
safe typescript, predictable behavior, no implicit coercion
Suggestion
I would like to suggest to introduce a new flag for disabling implicit type coercion at all
Something like this:
--predicatableJs
Or some other flag
Use Cases
To make
Typescript
even more safeI want to enforce my team to use only predictable features and if they want old style behavior, just to write another module or disable warning at the top of the file (in such way all reviewers of this files will see that)
Examples
Instead of writing either:
or
I want to enforce that this code produce error and compiles only if there is explicit cast:
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: