Open petamoriken opened 6 months ago
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
I think the most likely course of action is to deprecate the syntax in 6.0 with a compat flag for a little bit.
👍
The DENO_FUTURE=1
environment variable disables the assert
keywords in JavaScript, so I would like to gradually disable assert
keywords in TypeScript as well by adding the disallowAssertKeywords
option.
https://github.com/denoland/deno/pull/23541
A lint rule is probably the best choice if you need to ban this right away in some other scenario
The no-import-assertions
rule is already implemented in deno_lint and is enabled by default.
https://github.com/denoland/deno_lint/pull/1209
@RyanCavanaugh Should the disallowAssertKeywords
option be added, or would this be considered an addition to the list of deprecated items?
disallowAssertKeywords
sounds super generic and can mistakenly interpreted to refer to asserts
too. And "keywords" is pluralized, but I'm not sure to what other keyword this option refers to?
Perhaps something like disallowAssertImports
would be better?
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 ignoreDeprecations
option.
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:
assert
does not error but does show a red squiggly + quick fix in the IDEassert
is emitted as with
in the JSI'd need to understand how someone would be unintentionally writing assert
in an import
statement to prioritize those mitigations
Today Node LTS supports with
and Node Latest does not support assert
. In three weeks, Chrome will also not support assert
.
assert
arrived in Chrome 92 (2021-07-20) & Node 17.5 (2022-02-10)with
arrived in Chrome 123 (2024-03-19) & Node v18.20 (2024-03-06)assert
was removed in Chrome 126 (2024-06-05) & Node 22.0 (2024-04-24)So I think it's safe to say that anyone still using assert
in the TS 5.6 time-frame (Sept 2024?) is doing so unintentionally. Either due to carry-over from existing code, or someone is following out of date documentation.
Both cases would benefit from TS guidance towards with
. TC39 communications on this migration has limited reach, whereas TS can surface the forwards path readily.
In the TC39 meeting today we finally agreed to remove
assert
from the import attributes proposal.
🔍 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.https://github.com/denoland/deno/issues/17944#issuecomment-2027005952
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. https://github.com/jsr-io/jsr/pull/427I've made a PR for swc, but it is pending because I can't include features that are not in tsc. https://github.com/swc-project/swc/pull/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