Skip to main content
View on YouTube to comment and like!

Syntax Video

TypeScript in NodeJS has Arrived In Nightlies

Chapter 1 00:00

Transcript

something absolutely massive just dropped in nodejs you may have woken up this morning and checked out Twitter only to see that well experimental strip types has been added as an option to nodejs now this is in the node 23 nightly currently but what this means is that you can write typescript code using actual. TS files in nodejs without having to run any sort of compile step this is amazing and it's something that a lot of people have been very excited about ever since the proposal from tc39 for type annotations the dream of using typescript without any sort of compile step and what's really cool about this is that it uses s swc wasm typescript and if you've been paying attention to S swc at all you'll know that this is a really neat project and if you're a fan of s swc and maybe you've built something with it or you're building something with it or using it in your

applications it's a probably a good feeling to know that this thing isn't going anywhere because it's going to be used in node so what does this mean for typescript does this check your types no does not do any type checking you'll still need typescript to actually check your types but this means that we won't need to run a build process just to run this code in node now if we want to see this in action what you can do is scroll all the way to the bottom of this GitHub issue which this is again it's called add experimental strip types if you want to look this up at the very bottom here they link to a nightly that you can try out yourself or if you just want to give it a try and see that it works there's a Code sandbox here that shows this in action so so if you see this here we have an index.ts file this is using actual typescript types it's a TS file now if we head to the package.json you'll notice some things there is no typescript dependency and also you can tell that this code is running because

it's outputting the hello typescript here if we check out the start script you'll see that it's simply just running node nightly which is the equivalent if you're used to running node and they're running experimental strip types index.ts and this thing runs so this means you'll be able to run actual typescript files in node without a compile step that's incredible I think this is a massive step forward node has been absolutely on fire adding amazing things to the language lately and having typescript support directly in node is something that a lot of us have been waiting for and something a lot of us have been really hoping would come into the process because let's face it having a build process for everything isn't always the best right sometimes you just want to even get started writing a node file next thing you know you're installing a dependency to execute your typescript file or perhaps even having to use something like Dino just to use typescript without a build step so check

it out read through this GitHub issue I highly recommend uh getting a deep understanding of what's going on here but at the end of the day it's allowing you to use and import TTS files in your application one small tidbit is that I know some of you like to do your Imports without an extension on them this does require your Imports to have a TS extension on them to work so if you're the type of person that really enjoys that well uh you're going to have to get used to writing. TS unless you want a build step now I don't think that's a problem personally in fact I I don't care at all I like that it's explicit when you use a TS or something so for me it's not a big deal I know some people will have a bit of a rub with that but this is incredible it's now in node 23 which means that it will be coming down the line for normal everyday node users very soon sound off in the comments let me know what you think do you hate typescript are you upset that this was added to nodejs are you still resisting

types or does this now unlock typescript for you because you don't need a build process now to use these things I know me personally I was writing JS doc type style uh quite frequently to avoid adding a build process now I'm not going to have to do that and I'm stoked about it so let me know what you think down below I'm interested in hearing your thoughts on not only this addition to node but also the proposal from tc39 as always this is Scott from syntax peace

Quote it with credit and a link. Quoting Syntax