Why Typescript is bad
1.81K subscribers
72 photos
70 links
All topics related to TS

chat: @why_typescript_is_bad_chat
contact: @stuneak
Download Telegram
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 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 // ?^ 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
Variance annotations are unsound. Contravariant type variable can be pronounced to be covariant, and TS couldn't care less.

Code. Issue.

Also here is an example that actually crashes in runtime.
Forwarded from TypeScript Stories
3️⃣2️⃣
Wrong type inference with Capitalize and Uncapitalize utility types.

▶️ Playground
JSON.stringify can return undefined and it is ok??

Playground.
Eh?