3 ms·
> 2. Fast, owing to Node.js/V8's insane optimization level But you need to convert the TS to JS, and the TS compiler takes like 3 seconds to start on my laptop
by arp242 3y ago
> 2. Fast, owing to Node.js/V8's insane optimization level
But you need to convert the TS to JS, and the TS compiler takes like 3 seconds to start on my laptop (orders of magnitude slower than any other compiler I know, although you can speed it up a bit if you disable type checking, but that, well, removes type checking).
- a_wild_dandan 3y agoYou don't need a compiler. The vanilla `node` binary works fine with a few trivial syntactic changes. It sucks that your compiler's slow! Check out `swc` if you prefer speedy compilation.
- arp242 3y agoswc doesn't do type checking, so while useful in some cases it's not really a replacement for tsc.
- tom_ 3y agoDoes node do static type checking?
- a_wild_dandan 3y agoNope! `node` is just a binary that executes JS code (e.g. the above code, mod a few syntax choice tweaks). Since JS has no static types, `node` has no types to check. Other languages can be compiled (perhaps "transpiled") to JS, some of which have static type mechanisms. One of those other languages, TypeScript, has static types. There are tools to compile TypeScript into JS: `swc`, `tsc`, etc. There are also tools to statically type check TypeScript (`deno`, `tsc`, etc). Personally, I use `swc` for speedy TS compilation. I use my IDE's `tsc` language server for the separate job of highlighting type issues. But everyone has their preferred workflow!
- e12e 3y ago> But you need to convert the TS to JS Or use deno? Or bun?