From f77bf65059c15e3a9d73fff1569863d43140970d Mon Sep 17 00:00:00 2001 From: Marco Ippolito Date: Sun, 27 Oct 2024 08:52:50 -0500 Subject: [PATCH] doc: add suggested tsconfig for type stripping PR-URL: https://github.com/nodejs/node/pull/55534 Reviewed-By: Zeyu "Alex" Yang Reviewed-By: Yagiz Nizipli Reviewed-By: Benjamin Gruenbaum Reviewed-By: Chemi Atlow Reviewed-By: Gireesh Punathil --- doc/api/typescript.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/api/typescript.md b/doc/api/typescript.md index bad8f44001c04e..3b3f615953cb93 100644 --- a/doc/api/typescript.md +++ b/doc/api/typescript.md @@ -68,6 +68,21 @@ By intentionally not supporting syntaxes that require JavaScript code generation, and by replacing inline types with whitespace, Node.js can run TypeScript code without the need for source maps. +Type stripping works with most versions of TypeScript +but we recommend version 5.7 or newer with the following `tsconfig.json` settings: + +```json +{ + "compilerOptions": { + "target": "esnext", + "module": "nodenext", + "allowImportingTsExtensions": true, + "rewriteRelativeImportExtensions": true, + "verbatimModuleSyntax": true + } +} +``` + ### Determining module system Node.js supports both [CommonJS][] and [ES Modules][] syntax in TypeScript