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
Не все знают, что среди тысяч багов TS в Issues проекта на Github есть и другие тикеты, которые полезно иногда найти и почитать.

С недавнего времени Google начал писать формальные отчёты о том, как прошло обновление до свежей версии TS, в которых указаны breaking changes, забытые в официальном changelog в блоге. Обновление на новую версию — три дня потерянного времени. Смотреть, как инженеры Google наступают на грабли за вас — бесценно.

Иногда могут закрадываться подозрения, что команда TS не делает вообще ничего полезного. В таком случае полезно посмотреть лог дизайн-митингов. Там обсуждаются самые важные изменения, которые, несомненно, затронут все аспекты вашей разработки: как правильно показывать подсказки с помощью JSDoc, и должны ли *.cts файлы считаться модулями.

Stay typesafe, stay informed!
Если вам кажется, что сообщения об ошибках в TS могли бы быть более понятными, вы не одни. Одного из соавторов xstate это утомило, и он сделал расширение для vscode, декодирующее ошибки с майкрософтового на английский. Штука, конечно, маргинально полезная, но кому-то, может, и поможет. Потестить без установки можно тут.
Forwarded from artalog (artalar)
Как же у меня бомбит с тайпскриптовых енумов.
Мало того что они используют зарезервированное в ЖС слово (что обязательно в какой-то момент сломается), так и реализованы криво и имеют плохой интероп с остальными типами / значениями и в общем ощущаются как очень странный костыль вместо юнионов.

Главная практическая проблема в них, для меня, в том что их нельзя мапить на уровне типов, те дженерик операции над енумами практически невозможны. Какие-то гиперболизированные, но бесполезные unique type, но иногда не unique 🤪
TypeScript - there is always a way to find a hack ©
Strict option does not override underlying options like noImplicitAny in extended configs
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.