Why does 'any' exist in TypeScript? #typescript

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

love the fit. Going from typescript king to drip king

ayoaloko
Автор

Because every real language has a footgun.

davidspagnolo
Автор

Unknown should (my preference: must) be used over any

DanielAWhite
Автор

According to our front-end developers, the appropriate time to use any is any time you can't be bothered to create a type for a semi complicated value from the backend.

orterves
Автор

Looking forward to it. I hate the any keyword and I would never use it personally. But since you are saying it has its use cases, I am intrigued, coz you are the one whom I learned typescript from. 😂

BlurryBit
Автор

Any is litterally my nemesis at work atm, hehe. looking forward to the next vid.

KristianTheDesigner
Автор

never and unknown together are just better alternatives

nomadshiba
Автор

its so we can just put any everywhere and add typescript to our resume

not_hehe__
Автор

Typescript is hard to fathom for some juniors. Because they feel like they declare classes. But then suddenly at runtime they they a string instead of a number in a value because of their API returned it. And it contains other values not used.

Makes it really confusing for them. Sometimes I wish it wasn't so.

Zutraxi
Автор

It's better to use an occasional any than to ditch TypeScript because it's to frustrating.

rhatalos
Автор

I want to know if there is a better way to do things like:
const array: GenType<any, any>[] = [ ..stuff.. ]

We need 'any' to be able to put different GenType values into the array, but using 'any' breaks internal type checking in those items.

robertsandiford
Автор

TypeScript describes itself as a superset of JavaScript. In other words TS adds new features to JS, but still stays compatible with it. This is one of the reasons why TypeScript became so popular - it can be used seamlessly with JS, which means you can migrate from JS to TS at any moment and learning curve is very gradual. Hell, you can simply change file extension from ".js" to ".ts" and everything will work without any refactor. 100% strict & mandatory type checking would break this compatibility and make TS migration for most projects almost impossible. Just imagine rewriting a large project from JS to Dart.

ReasonX
Автор

Java have object type. It does same thing

nielubieyoutuba
Автор

Bad practice: Use "any" anywhere you like.

adtc
Автор

Why does Typescript exist in any?? How about that??

hn
Автор

JS itself is too dynamic for TypeScript to be fully type-safe. It's not so rare to have a function that takes literally just any type and determines what to do with it based on some internal checks...
For example, you might have a logger that concatenates multiple strings and numbers or extracts message and stack from errors, stringifies objects or transforms dates to your liking, then if none of the cases matched, logs the thing straight away. Strictly typing such a thing would just be a nightmare.

shapelessed
Автор

i dont understand a single part of this video

charleshautly