Menu

Post image 1
Post image 2
Post image 3
Post image 4
1 / 4
0

TypeScript 5.8 Erasable Syntax: Running TS Directly in Node.js

www.sitepoint.com·SitePoint Team·22 days ago
#hmFJMbtA
#toc#x3c#clip0_119_2072#type#node#erasable
Reading 0:00
15s threshold

How to Run TypeScript Directly in Node.js with Erasable Syntax Install Node.js 23.6+ (or 22.6+ with --experimental-strip-types ) and TypeScript 5.8+. Add "erasableSyntaxOnly": true and "verbatimModuleSyntax": true to your tsconfig.json compiler options. Set "module": "nodenext" and "noEmit": true in tsconfig.json . Replace all enum declarations with as const objects and derived union types. Convert constructor parameter properties to explicit property declarations and assignments. Refactor value-bearing namespace blocks into standard ES module exports. Run your TypeScript files directly with node src/server.ts — no build step required. Verify type safety by running tsc --noEmit in CI, since Node.js strips types without checking them. TypeScript 5.8 introduced the --erasableSyntaxOnly compiler flag, which validates whether TypeScript code contains only type constructs that can be stripped away without altering runtime behavior.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More