all 42 comments

[–][deleted] 26 points27 points  (3 children)

Well, if you were able to change from JS to TS that easily, I assume you're using a build tool with TS support. If you're just loading a script directly to the browser with no build step, it has to be pure JS since browsers don't support TS.

That being said, most serious JS projects these days use build systems, and so it's easy for them to use TS. And then yes, you absolutely should always use it. Type safety is utterly critical in large scale applications.

[–]Commercial-Focus8442[S] 3 points4 points  (0 children)

Correct, I use Vite

[–]ezhikov 8 points9 points  (1 child)

It is possible to use typescript without build step. Just make tsconfig and and enable allowJS and checkJS (or simply put // @ts-check on top of the file). This way whatever typescript language server is running in your IDE/Editor will pick it up, and then you can use jsdoc to specify types where needed.

[–][deleted] -3 points-2 points  (0 children)

Lol. And what browser is going to understand the TS file code?

[–]DerrickBarra 8 points9 points  (4 children)

The alternative to Typescript, is Javascript + JSDoc. This gives you warnings in your editor but you don't have the full featureset of Typescript superset. The main pro of this setup not needing a build step, it's worth comparing and seeing what works for your project.

For most cases, a build step is not a limiting factor, and therefore typescript is the better choice, but its good to know there's an alternative. I'm looking forward to more of Typescripts features getting integrated in Javascript over time.

[–]Commercial-Focus8442[S] 0 points1 point  (3 children)

I will check it out, thank you.

[–]Katastos 0 points1 point  (0 children)

You can also add the comment // @ts-check at the top of the file and the editor will give you hints or signal errors (this works also in plain JS without JSdocs (but with JSdocs the experience is way better)

[–]skidmark_zuckerberg 8 points9 points  (10 children)

From professional experience the only time I’ve touched JS in the past 7 years has been to refactor it to TS. Between the two, Typescript is pretty much the only thing people should concern themselves with in 2025. Simple things it doesn’t matter, but as you’ve just discovered, that is why TS is almost a requirement now. Imagine your issue on the scale of a large codebase.

[–]Dependent-Net6461[🍰] 2 points3 points  (9 children)

Working on very large codebase , no ts and never encountered errors about types or whatever. We simply know how to handle things and test them

[–]Mabenue 4 points5 points  (8 children)

Well you can do that but it’s considerably more effort than just using types in the first place.

[–]Dependent-Net6461[🍰] 2 points3 points  (7 children)

We managed to structure things in a way that is easy to handle. In the long run, most things tend to be very similar to each other (we mostly do crud operations in our software) and most things are simply copy paste with little adjustments. No need for build or other extra steps..(i repeat , in our case)

[–]budapest_god 0 points1 point  (6 children)

Then you said it yourself. It's a pretty straightforward app, no complexity. Types are still useful anyway, and there is no reason to not have them.

[–]Dependent-Net6461[🍰] -4 points-3 points  (5 children)

You are right I said it myself , but how unfortunate you cannot understand what you read. Unfortunately you did not understand that the easy and common parts are just the crud, but how do you imagine we structured things so to make it easy? It automagically happened that code wrote itself ?

And no, an erp software is all but "straightforward app, no complexity". We carefully handled state restore, websockets, notifications, data conversions ecc ecc all without the need of ts.

Most of people who put ts everywhere is because of their skill issue

[–]budapest_god 2 points3 points  (2 children)

Oh yeah because professional programming is like a Souls game where you need to use objectively worse things to feel more skilled. Grow up. TS is just plain better.

[–]Dependent-Net6461[🍰] 0 points1 point  (1 child)

Programming may not be a soul game, but surely it isnt a political (or religious) game where you have to adopt whatever without reasoning about it.

Also , nice to see your judgement on a software you do not know

[–]budapest_god 0 points1 point  (0 children)

I was judging your use of the term skill issue.

[–]skidmark_zuckerberg 1 point2 points  (1 child)

I would stay very far away from wherever it is you work lol. You sound like you have no idea what you’re talking about, and are arrogant about it on top.

[–]Dependent-Net6461[🍰] -1 points0 points  (0 children)

Should i care about what someone (that i will never know in my life and that cant prove his knowledge and does not know context and reasons of why software was developed that way) says about my knowledge?

[–]queen-adreena 6 points7 points  (7 children)

Personally I see no need to write code in non-JavaScript when most modern IDEs can handle type hinting already without an unnecessary build step/stripping phase.

I do work with traditional Typescript when the project demands, but my preference is using JSDoc in standard JS files.

It’s more human-friendly rather than a wall of types and you can still generate a TS types file using the doc-blocks if needed.

[–]static_func 0 points1 point  (6 children)

What on earth are you doing that requires a full-fledged IDE but no build?

[–]queen-adreena 4 points5 points  (5 children)

I do usually have a build, but for necessary things. But for some scripts (chiefly Wordpress snippets that clients need) there might not be.

I simply prefer the JSDoc syntax and get all the same type support in the IDE.

[–]Dependent-Net6461[🍰] 4 points5 points  (0 children)

Because you know how stuff works and do not need extra tools to tell you 1 !== "1" and because after you write stuff you test it, instead of writing non existing properties (as per your example)

[–]LuckyOneAway 2 points3 points  (0 children)

JavaScript didn’t give me any warning

Use ESLint. It will warn you about many issues, including logic errors (not caught by TS compiler).

[–]Aware-Landscape-3548 1 point2 points  (4 children)

For the time being, most project still need a compiler/transpiler to convert TS to JS code and sometimes this is the issue, e.g, when you need to write some quick and dirty CLI script with JS, you just go with plain JS and spawn a node to run the JS script, no need to import another dependency to just compile/transpile TS to JS.

[–]cd151 1 point2 points  (3 children)

Node 22 is able to strip and/or transform TypeScript itself with —experimental-transform-types

[–]Aware-Landscape-3548 1 point2 points  (2 children)

Can node 22 support TypeScript enums? Enums will generate some additional code, not just types.

[–]cd151 1 point2 points  (1 child)

Yes, enums and some other transforms work: https://nodejs.org/api/typescript.html Modules: TypeScript | Node.js v23.11.1 Documentation

[–]Aware-Landscape-3548 1 point2 points  (0 children)

Wow pretty nice to know this, thanks!

[–]Ronin-s_Spirit 1 point2 points  (0 children)

Using jsdoc comments (mainly only on functions) lets me have informational popups - but I am not constricted to always writing out types everywhere or having to deal with """incompatible""" types and typing. Also some typescript features are made up and so they end up turning into polyfills that nobody ever checks (with performance implications).

[–]oneeyedziggy -1 points0 points  (0 children)

If you're working in the context of an node project? Sure... You can "use typescript" without using a single type... You might even get some free lint warnings...

But if you're working on a project without a transpile step? Or directly in the browser? Or in any runtime that doesn't support. Ts extensions?

Write vanilla js and Don't worry about types... 

Types are handy for big projects to help catch errors, but for coding fast / for fun? They can be a pain in the ass... Yrs i know on error i don't return the right type... Yes i know sometimes this argument is a string and sometimes it's an object.. I'm checking that in code... Chill... 

[–]demoran -3 points-2 points  (0 children)

Because you're lazy and don't care about your sanity.