-
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 a rule to the compiler options to disallow the assert
keyword for import attributes
#58453
Comments
I think the most likely course of action is to deprecate the syntax in 6.0 with a compat flag for a little bit. A lint rule is probably the best choice if you need to ban this right away in some other scenario |
π The
The |
@RyanCavanaugh Should the |
Perhaps something like |
The option name is open to discussion. However, it's more important to determine whether we need to add this new option or if this deprecation should be handled by the |
Sorry for the confusing metadata on this one. We think we'll just hold off on erroring until 6.0, at which point it'll become parsed-with-an-error, then just quit parsing at 6.5 |
Thanks for the update. It's great that TS can evolve by retiring syntax as well as retiring flags. Given that this leaves the hazard of TS emitting non-ideal (maybe even non-standard/non-executable) JS without any user guidance for the next 18 months, how would you feel about landing some mitigations earlier than 6.0? For example:
|
I'd need to understand how someone would be unintentionally writing |
Today Node LTS supports
So I think it's safe to say that anyone still using Both cases would benefit from TS guidance towards |
|
π Search Terms
"import assertions", "import attributes", "assert"
β Viability Checklist
β Suggestion
Currently Stage 3 Import Attributes deprecates the
assert
keywords and is working to remove them from the spec if possible. V8 will remove support for theassert
keywords, so Node.js and Chrome will follow suit.denoland/deno#17944 (comment)
I would like to remove support for the
assert
keywords from TypeScript as well, and would like to adddisallowAssertKeywords
to the compiler options as a beginning.FYI
JSR bans publishing of TypeScript/JavaScript files that use the
assert
keywords.jsr-io/jsr#427
I've made a PR for swc, but it is pending because I can't include features that are not in tsc.
swc-project/swc#8913
π Motivating Example
The following code will fail if the
disallowAssertKeywords
option is enabled.π» Use Cases
Deno / JSR
Deprecated the
assert
keywords cannot be rejectedN/A
The text was updated successfully, but these errors were encountered: