DEV Community

Discussion on: TypeScript?.. or JavaScript?

Collapse
f1lt3r profile image
Alistair MacDonald Author

Finally someone with a Typescript preference! :) good points. It would be surprising if Object Composition itself was responsible for getting people lost, are you certain it wasn't an organizational issue?

Collapse
dotintegral profile image
Artur Siery • Edited

Well, when you have 50+ contentful models with references to other models then yeah... From the data modeling point, the model makes sense. So I would argue that no, it was not an organisational issue. And honestly, if I have big project that I need to work on, I don't really want to spend precious brain power to memorize all of the models. I let TS hint me with fields ;-)

Thread Thread
f1lt3r profile image
Alistair MacDonald Author • Edited

Make sense. TS hinting is pretty great. Hinting tends to drive me nuts, but it is really useful in a larger/unfamiliar codebases. VS Code has some level of hinting for regular JavaScript. I find that I am still able to traverse the model to a satisfying degree (see image).

VS Code Hinting, Traversal, Peeking in Vanilla JS Projects

Thread Thread
dotintegral profile image
Artur Siery • Edited

JS Hinting is great, but it can only go as far as to the code/objects that you explicitly define. There is no way (unless I missed something) for VS Code to predict the structure of data incoming from API. With TS, you can just state that you expect data of this structure and hinting will work correctly. Granted, there is still possibility that you made mistake in typing the response, or the response changes after some time, but the same problems would occur in normal JS.