If you already have a subscription, you can sign in.
Enjoy free content straight from your inbox 💌
00:00
Node GS now supports TypeScript natively without any flags as long as you only use iris syntax. And what is Iris syntax? Well, you don't need to memorize it. As you can tell TypeScript to warn you if you use anything that a node will not be able to execute natively. As an example, before node GS 23, if a type annotation exists within our code, for example, here we are annotating message to be of type string and try to execute it through node. We get an error because node js, of course, does not understand type annotations. However, if you move over to node JS 23 and above and execute the same code, it executes flawlessly.
00:35
It'll warn you that this feature is experimental, but over time, this warning will go away. There is a limitation of this feature. It only supports type stripping and doesn't support features that require code generation. As an example, if you use an A number within type script, which is something that doesn't exist natively within JavaScript, and therefore would require code generation and try to execute it through node, node will error out. And this is not the only syntax that exists within TypeScript that is not native to JavaScript. Another example would be namespace. Fortunately, these aren't even features
01:07
that TypeScript developers use anymore. However, it would be great if we would get an error from TypeScript instead of it erroring out at execution With no JS for this, there is a flag within TypeScript 5.8 and above, which is I reasonable syntax only, which we can enable within the compiler options of our Ts config. Once this is enabled, you can see that now we are getting an error at compile time from TypeScript. That is, Innu is not something that is supported in Iris syntax only, so we can fix our code at compal time. For example, the alternative that most developers use instead
01:38
of INS is simply a literal string union and now we don't get any error from TypeScript. And similarly, node JS is happy to execute this code as well.