Global declarations aren’t saved, but there is no other way to infer it. TS doesn’t respect JS standards.
Edit. TS claims to have a design goal of typing common JS patterns. The pattern in question is typeof of undeclared variable. Probably every reader used to do
It's currently possible to declare the variable globally by extending Window interface, but those declarations will be available — well — everywhere, including the modules that have nothing to do with them. Global variables, global declarations, all the globals are widely considered an antipattern for this reason.
Narrowing already makes it so that single variable can have several types in different parts of the code, but correctly typed typeof would also require dynamically changing a set of variables that are available in current scope.
It weren't us who made a decision about design goals, so the discussion on unintended consequences is under the feature request.
Edit. TS claims to have a design goal of typing common JS patterns. The pattern in question is typeof of undeclared variable. Probably every reader used to do
typeof window !== 'undefined'
at least once.It's currently possible to declare the variable globally by extending Window interface, but those declarations will be available — well — everywhere, including the modules that have nothing to do with them. Global variables, global declarations, all the globals are widely considered an antipattern for this reason.
Narrowing already makes it so that single variable can have several types in different parts of the code, but correctly typed typeof would also require dynamically changing a set of variables that are available in current scope.
It weren't us who made a decision about design goals, so the discussion on unintended consequences is under the feature request.
Extension persistently shows a type of expression on top of
https://marketplace.visualstudio.com/items?itemName=Orta.vscode-twoslash-queries
10x @dkzlv @khraks_mamtsov
// ?^
mark. It's indispensable for debugging of deeply nested type computations.https://marketplace.visualstudio.com/items?itemName=Orta.vscode-twoslash-queries
10x @dkzlv @khraks_mamtsov
No particularly life-changing features in this major version.
https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/
https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/
Microsoft News
Announcing TypeScript 5.0
Today we’re excited to announce the release of TypeScript 5.0! This release brings many new features, while aiming to make TypeScript smaller, simpler, and faster. We’ve implemented the new decorators standard, added functionality to better support ESM projects…
Here we gooo. Somebody started to work on an alternative standard library for TypeScript with sane types.
https://github.com/total-typescript/ts-reset
https://github.com/total-typescript/ts-reset
GitHub
GitHub - mattpocock/ts-reset: A 'CSS reset' for TypeScript, improving types for common JavaScript API's
A 'CSS reset' for TypeScript, improving types for common JavaScript API's - mattpocock/ts-reset
Checked exceptions are no more.
https://github.com/microsoft/TypeScript/issues/13219#issuecomment-1515037604
https://github.com/microsoft/TypeScript/issues/13219#issuecomment-1515037604
GitHub
Suggestion: `throws` clause and typed catch clause · Issue #13219 · microsoft/TypeScript
The typescript type system is helpful in most cases, but it can’t be utilized when handling exceptions. For example: function fn(num: number): void { if (num === 0) { throw "error: can't d...
Nobody cares about TS Playground anymore. TS team declared issue bankrupcy and closed all the issues.
https://github.com/microsoft/TypeScript-Website/issues/2804
https://github.com/microsoft/TypeScript-Website/issues/2804
GitHub
Next Steps for the TypeScript Website (April 2023 edition) · Issue #2804 · microsoft/TypeScript-Website
Next Steps on the TypeScript Website TL;DR We're taking this time to deliver a smaller, higher-quality, lower-cost version of the website that serves our needs while still leaving us time to do...
Mostly new JS features got support, and a particularly annoying old bug with union of arrays got fixed
https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/
https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/
TypeScript
Announcing TypeScript 5.2 - TypeScript
Today we’re excited to announce the release of TypeScript 5.2! If you’re not familiar with TypeScript, it’s a language that builds on top of JavaScript by making it possible to declare and describe types. Writing types in our code allows us to explain intent…
https://www.typescriptlang.org/play?#code/MYewdgzgLgBAtgUwE4HMEwLwwDwEEA0MAQgHwAUAhgFwwEwBGNRAlJiTGQN4B0vFhvbvQC+zANwAoCaEiwArphicAHjTKsM7AORbhkmdBgA3RSrUb2ABj3TwhgO6nVHCzChI5CG7dkxlixFQEMjlCQLQyI0J7ZmZuZXV9OxAAGwRuFJAUMmVuKBAAGRB7ZABhCghg2LEYAHpavzzC4rKK9ABLCBgwEFgKGAAzOTBgKHbwIA
https://github.com/microsoft/TypeScript/issues/10727
thanks to @pbdqo
https://github.com/microsoft/TypeScript/issues/10727
thanks to @pbdqo
Forwarded from TypeScript Stories
Somehow this sounds more scary than promising
https://fixupx.com/mitypescript/status/1856053317195223244?s=61&t=JbvNAsLXJkzYoNsyC-QjjA
https://fixupx.com/mitypescript/status/1856053317195223244?s=61&t=JbvNAsLXJkzYoNsyC-QjjA