3 ms·
You'll like https://www.npmjs.com/package/ts-node https://www.npmjs.com/package/ts-node - it allows zero processing use of typescript
by gunn 6y ago
You'll like https://www.npmjs.com/package/ts-node https://www.npmjs.com/package/ts-node - it allows zero processing use of typescript
- desert_boi 6y agoZero processing is a little generous, for things like like ES Module support (and interop), ts-node can be a struggle to get going.
- gunn 6y agoAs in .mjs files? Personally, I just want to import my own .js / .ts files and external npm packages which works well - https://github.com/gunn/covid-19-scripts/blob/023579e1cf/get-population-data.ts https://github.com/gunn/covid-19-scripts/blob/023579e1cf/get... The catch for me is that it's probably not suitable for a sever in production as mentioned elsewhere in this thread.
- bgdam 6y agoWord of warning though - ts-node can be excruciatingly slow. We recently switched a project from using ts-node in our dev environment to compiling with tsc and running with node, and shaved around 5 minutes from our startup time.
- lioeters 6y agoWell, that answers something I was wondering about recently. I noticed in a couple of popular TypeScript (+React fullstack) boilerplates, that they were using ts-node to run the server in production. Unlike babel-node, there's no mention in the documentation to avoid using it in production - but I figured there'd be performance impact, since it's transpiling on the fly (I suppose just once per require).
- dgellow 6y agoYou had 5 minutes startup time?!
- z3t4 6y agoMore then one second and people will test their code less often. Five minutes and people start relying on the type-checker. Like with the chicken and egg problem, what came first, the type-checker or the need to have a type checker?
- torb-xyz 6y agoIt doesn't really help that much with TypeScript native NPM-packages being published with JS and D.TS (TypeScript-definitions) instead of the original source, does it?)