Hacker News new | ask | show | jobs
by flohofwoe 675 days ago
I would recommend using Typescript and a strict linter if possible. TS is essentially modern Javascript plus static typing (so by learning TS, you also learn JS as a side effect), and strict linting rules will reject outdated Javascript features and nudge you towards the 'good parts'.

With those two things (a static type system layer, and strict linting) JS is actually a quite decent language nowawadays, especially in VSCode (e.g. see: https://code.visualstudio.com/docs/languages/typescript).

2 comments

I would also recommend Typescript. Anything important you need to know about Javascript, you will end up picking up along the way.

My main complaint: the default compiler settings are pretty loose, presumably in the interests of erring on the side of letting Javascript code through by default. I'd recommend going through the available project settings carefully and switching on more of the checks. eslint is also a good idea I think - and a similar comment applies. (I activated pretty much everything, and dialled it back as I found myself getting annoyed by things that felt like poor value for moneey.)

My biggest gripe with Typescript is how much more difficult (Except perhaps in Bun/Deno) it is to set up compared to vanilla JS.
npm install ts-node

ts-node ./my-typescript.ts

doesn't seem difficult...

Until you have to deal with Jest for testing, or React.
Even easier than that:

    npx tsx ./file.ts