this post was submitted on 18 Oct 2023
341 points (96.2% liked)
Programmer Humor
32710 readers
232 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
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 explicitany
in very specific framework level code, unit tests or if you interface with an untyped framework.The hassle really pays off later.
But if your code ever integrates with javascript you still need any everywhere so it's pretty pointless
Not necessarily, depending on your situation you can type the JS code yourself.
If the team making the JS code were using jsdoc then the Typescript compiler can recognize the comments and use it for type checking.
In some instances the compiler can infer types from JS code to do some basic validation.
Even if the external JS code is recognized as
any
, your own code that's using it still has types, so it's better than nothing.