this post was submitted on 14 Nov 2023
5 points (100.0% liked)

Programmer Humor

32415 readers
243 users here now

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

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] CanadaPlus@lemmy.sdf.org 0 points 1 year ago (1 children)

I've never used TS, and I'm not exactly sure what nest.js even does, but building a TypeScript project on top of a JavaScript library not designed for it seems like asking for trouble. Is that standard practice?

[–] sloppy_diffuser@sh.itjust.works 0 points 1 year ago* (last edited 1 year ago) (1 children)

Yes. As of this writing there are 7,738 type definitions in a central repo maintained by users for plain JavaScript packages.

https://github.com/DefinitelyTyped/DefinitelyTyped

Many package owners write type definitions included with their package that is written in JavaScript also.

[–] CanadaPlus@lemmy.sdf.org 0 points 11 months ago* (last edited 11 months ago) (1 children)

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.

[–] DrM@feddit.de 0 points 11 months ago

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