Comments (9)
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.
from typescript.
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?
from typescript.
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.
from typescript.
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
from typescript.
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.
denoland/deno#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.
denoland/deno_lint#1209
from typescript.
@RyanCavanaugh Should the disallowAssertKeywords
option be added, or would this be considered an addition to the list of deprecated items?
from typescript.
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
from typescript.
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:
- Soft deprecation:
assert
does not error but does show a red squiggly + quick fix in the IDE - Silent upgrade: Source TS using
assert
is emitted aswith
in the JS
from typescript.
I'd need to understand how someone would be unintentionally writing assert
in an import
statement to prioritize those mitigations
from typescript.
Related Issues (20)
- Method `concat` has wrong typization HOT 3
- Invalid type inference for optional chaining operator when nullish check is extracted to `const` varaiable HOT 2
- Inline type annotations for destructured properties using angle bracket syntax HOT 3
- Enum generic does not restrict union of possible objects where enum is defined HOT 8
- `const wrong = () => (1 < 3) as true // type: () => true` this should be an error. HOT 9
- "Organize Imports" should adjust specifiers based on preferences HOT 1
- TS 5.4.5: Return type for performance.getEntriesByType is inaccurate
- Lose generic when spreading `T | undefined` where T is a generic object type HOT 3
- [isolatedDeclarations][5.5] Optional parameter annotated with imported type has isolatedDeclarations error HOT 2
- Missing content in documentation FAQ section HOT 3
- Make property decorator fabrics share generics with corresponding methods HOT 2
- Generic type parameter not inferring properly HOT 1
- JSDoc `@private` on constructor without parameters is omitted in declaration files
- [API] Ability to check if a parameter is being passed to const type parameter
- Improve support for internal packages by resolving path aliases
- CommonJS globals permitted for ES module builds with no compiler error. HOT 4
- -
- Type predicate doesn't narrow down function overload (but assertion works) HOT 3
- Recursive type strangely resolved to never HOT 3
- [5.5 beta] The `moduleDetection` option is ignored for `verbatimModuleSyntax` error HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.