this post was submitted on 18 Oct 2023
341 points (96.2% liked)

Programmer Humor

31251 readers
489 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 4 years ago
MODERATORS
 
all 33 comments
sorted by: hot top controversial new old
[–] alokir 55 points 8 months ago (2 children)

It's a good way to get started, and then incrementally type as much as you can, preferably everything.

Later on, or if you start a new project with TypeScript, it's a good idea to turn on noImplicitAny and only allow explicit any in very specific framework level code, unit tests or if you interface with an untyped framework.

The hassle really pays off later.

[–] fusio 21 points 8 months ago

this is terrible advise - you should be using unknown. using any you're basically disabling TS and will be under the false assumption that your code is ok while it's most likely missing a lot of runtime checks

[–] [email protected] 11 points 8 months ago (1 children)
[–] some_designer_dude 8 points 8 months ago

But it’s “a colon any” 🧐

[–] [email protected] 7 points 8 months ago

I knew my any key would be useful one day.

[–] topinambour_rex 2 points 8 months ago

Why not use assembly ?

[–] [email protected] 2 points 8 months ago

Typing < type hinting

[–] ABC123itsEASY 1 points 8 months ago

Nah this isn't the way, friend. Instead of adding a bunch of useless anys all over the place, start typing in one part of the application and exclude the rest using a path pattern. Or simply allow .js and only change the extension for files you've typed. Doing this is just wasting time and creating false assurances of type safety.
It's not that hard to define correct, meaningful types. Often vscode already has implicitly determined them for you; just mouseover the variable.

[–] [email protected] -3 points 8 months ago

I wish I did that, at this point my TypeScript template errors are as long as C++'s ._.