I hate Typescript for promising me that nobody can put cyanide on the list, but in reality it disallows ME from putting cyanide on the list, but everyone else from the outside is still allowed to do so by using the API which is plain JavaScript again
The main problem with JavaScript and TypeScript is that there is such a little entrybarrier to it, that way too many people use it without understanding it. The amount of times that we had major issues in production because someone doesn’t understand TypeScript is not countable anymore and our project went live only 4 months ago.
For example, when you use nest.js and want to use a boolean value as a query parameter.
You see this code. You don’t see anything wrong with it. The architect looks at it in code review and doesn’t see anything wrong with it. But then you do a GET https://something.com/valueOfMyBoolean?myBoolean=false and you get “myBoolean is true” and if you do typeOf(myBoolean) you will see that, despite you declaring it twice, myBoolean is not a boolean but a string. But when running the unit-tests, myBoolean is a boolean.
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?
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
I hate Typescript for promising me that nobody can put cyanide on the list, but in reality it disallows ME from putting cyanide on the list, but everyone else from the outside is still allowed to do so by using the API which is plain JavaScript again
Honestly, programming is great for teaching you that you are the stupid one. This is still a feature.
The main problem with JavaScript and TypeScript is that there is such a little entrybarrier to it, that way too many people use it without understanding it. The amount of times that we had major issues in production because someone doesn’t understand TypeScript is not countable anymore and our project went live only 4 months ago.
For example, when you use nest.js and want to use a boolean value as a query parameter.
As an example:
You see this code. You don’t see anything wrong with it. The architect looks at it in code review and doesn’t see anything wrong with it. But then you do a
GET https://something.com/valueOfMyBoolean?myBoolean=false
and you get “myBoolean is true” and if you do typeOf(myBoolean) you will see that, despite you declaring it twice, myBoolean is not a boolean but a string. But when running the unit-tests, myBoolean is a boolean.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?
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.
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