this post was submitted on 14 Nov 2023
808 points (94.6% liked)
Programmer Humor
41398 readers
596 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 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Web dev continues to be cursed, I guess.
If I really needed to use a JS library in TS, I'd have to build some sort of adapter between the two that crashes whenever the JS library (that doesn't know anything about your types) breaks the typing rules. Anything else will inevitably lead to the above "fun" kind of bugs.
I don't think that this would work, there are no types anymore during runtime because everything is translated into plain js on build. TypeScript only exists during development
It would be dependent on what I was doing exactly, but a lot of times I'd end up reimplementing the type system in the runtime code, basically. Maybe I'd test the data every time it returns from the library, which would be slow, but if performance is an issue and there's still no TS options I should really just be making my own libraries.
I really don't want to deal with the above kinds of bugs, yo. Bugs that are actually visible in the code are hard enough. Maybe I'd have to do it but I'd kick and scream the whole way there.