#Use typescript for npm scripts?

10 messages · Page 1 of 1 (latest)

candid dagger
#

I have a need to write a couple of typescript CLI scripts and be able to run them from npm run xyz. I can’t really use bash scripts for this one as I need some npm packages. What’s the best way of getting this running without messing up how Astro handles typescript files? Like I can’t imagine going and adding tsc as a dependency is a great idea as then I also need to deal with where tsc output is written etc

candid dagger
#

Would ts-node work for this? I checked and it detects your tsconfig so it will be in sync with that, and again it’s for local dev scripts not for prod

#

What do people think?

candid dagger
#

Hmm well ts-node doesn’t support files with .TS extension or seemingly any file extension, truly weird. Kind of stuck now.

hollow delta
candid dagger
#

Turns out you need a —esm flag for TS-node to work but tsx looks interesting

#

Terrible name

#

Have you used it, do you prefer it to ts node?

hollow delta
#

I've only used ts-node, since I haven't had to setup that in a while now

#

tsx claims to be better in all ways though