{
  "type": "module",
  "source": "doc/api/typescript.md",
  "modules": [
    {
      "textRaw": "Modules: TypeScript",
      "name": "modules:_typescript",
      "modules": [
        {
          "textRaw": "Enabling",
          "name": "enabling",
          "desc": "<p>There are two ways to enable runtime TypeScript support in Node.js:</p>\n<ol>\n<li>\n<p>For <a href=\"#full-typescript-support\">full support</a> of all of TypeScript's syntax and features, including\nusing any version of TypeScript, use a third-party package.</p>\n</li>\n<li>\n<p>For lightweight support, you can use the built-in support for\n<a href=\"#type-stripping\">type stripping</a>.</p>\n</li>\n</ol>",
          "type": "module",
          "displayName": "Enabling"
        },
        {
          "textRaw": "Full TypeScript support",
          "name": "full_typescript_support",
          "desc": "<p>To use TypeScript with full support for all TypeScript features, including\n<code>tsconfig.json</code>, you can use a third-party package. These instructions use\n<a href=\"https://tsx.is/\"><code>tsx</code></a> as an example but there are many other similar libraries available.</p>\n<ol>\n<li>\n<p>Install the package as a development dependency using whatever package\nmanager you're using for your project. For example, with <code>npm</code>:</p>\n<pre><code class=\"language-bash\">npm install --save-dev tsx\n</code></pre>\n</li>\n<li>\n<p>Then you can run your TypeScript code via:</p>\n<pre><code class=\"language-bash\">npx tsx your-file.ts\n</code></pre>\n<p>Or alternatively, you can run with <code>node</code> via:</p>\n<pre><code class=\"language-bash\">node --import=tsx your-file.ts\n</code></pre>\n</li>\n</ol>",
          "type": "module",
          "displayName": "Full TypeScript support"
        },
        {
          "textRaw": "Type stripping",
          "name": "type_stripping",
          "meta": {
            "added": [
              "v22.6.0"
            ],
            "changes": []
          },
          "stability": 1,
          "stabilityText": ".0 - Early development",
          "desc": "<p>The flag <a href=\"cli.html#--experimental-strip-types\"><code>--experimental-strip-types</code></a> enables Node.js to run TypeScript\nfiles that contain only type annotations. Such files contain no TypeScript\nfeatures that require transformation, such as enums or namespaces. Node.js will\nreplace inline type annotations with whitespace, and no type checking is\nperformed. TypeScript features that depend on settings within <code>tsconfig.json</code>,\nsuch as paths or converting newer JavaScript syntax to older standards, are\nintentionally unsupported. To get fuller TypeScript support, including support\nfor enums and namespaces and paths, see <a href=\"#full-typescript-support\">Full TypeScript support</a>.</p>\n<p>The type stripping feature is designed to be lightweight.\nBy intentionally not supporting syntaxes that require JavaScript code\ngeneration, and by replacing inline types with whitespace, Node.js can run\nTypeScript code without the need for source maps.</p>",
          "modules": [
            {
              "textRaw": "Determining module system",
              "name": "determining_module_system",
              "desc": "<p>Node.js supports both <a href=\"modules.html\">CommonJS</a> and <a href=\"esm.html\">ES Modules</a> syntax in TypeScript\nfiles. Node.js will not convert from one module system to another; if you want\nyour code to run as an ES module, you must use <code>import</code> and <code>export</code> syntax, and\nif you want your code to run as CommonJS you must use <code>require</code> and\n<code>module.exports</code>.</p>\n<ul>\n<li><code>.ts</code> files will have their module system determined <a href=\"packages.html#determining-module-system\">the same way as <code>.js</code>\nfiles.</a> To use <code>import</code> and <code>export</code> syntax, add <code>\"type\": \"module\"</code> to the\nnearest parent <code>package.json</code>.</li>\n<li><code>.mts</code> files will always be run as ES modules, similar to <code>.mjs</code> files.</li>\n<li><code>.cts</code> files will always be run as CommonJS modules, similar to <code>.cjs</code> files.</li>\n<li><code>.tsx</code> files are unsupported.</li>\n</ul>\n<p>As in JavaScript files, <a href=\"esm.html#mandatory-file-extensions\">file extensions are mandatory</a> in <code>import</code> statements\nand <code>import()</code> expressions: <code>import './file.ts'</code>, not <code>import './file'</code>. Because\nof backward compatibility, file extensions are also mandatory in <code>require()</code>\ncalls: <code>require('./file.ts')</code>, not <code>require('./file')</code>, similar to how the\n<code>.cjs</code> extension is mandatory in <code>require</code> calls in CommonJS files.</p>\n<p>The <code>tsconfig.json</code> option <code>allowImportingTsExtensions</code> will allow the\nTypeScript compiler <code>tsc</code> to type-check files with <code>import</code> specifiers that\ninclude the <code>.ts</code> extension.</p>",
              "type": "module",
              "displayName": "Determining module system"
            },
            {
              "textRaw": "Unsupported TypeScript features",
              "name": "unsupported_typescript_features",
              "desc": "<p>Since Node.js is only removing inline types, any TypeScript features that\ninvolve <em>replacing</em> TypeScript syntax with new JavaScript syntax will error.\nThis is by design. To run TypeScript with such features, see\n<a href=\"#full-typescript-support\">Full TypeScript support</a>.</p>\n<p>The most prominent unsupported features that require transformation are:</p>\n<ul>\n<li><code>Enum</code></li>\n<li><code>experimentalDecorators</code></li>\n<li><code>namespaces</code></li>\n<li>parameter properties</li>\n</ul>\n<p>In addition, Node.js does not read <code>tsconfig.json</code> files and does not support\nfeatures that depend on settings within <code>tsconfig.json</code>, such as paths or\nconverting newer JavaScript syntax into older standards.</p>",
              "type": "module",
              "displayName": "Unsupported TypeScript features"
            },
            {
              "textRaw": "Importing types without `type` keyword",
              "name": "importing_types_without_`type`_keyword",
              "desc": "<p>Due to the nature of type stripping, the <code>type</code> keyword is necessary to\ncorrectly strip type imports. Without the <code>type</code> keyword, Node.js will treat the\nimport as a value import, which will result in a runtime error. The tsconfig\noption <a href=\"https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax\"><code>verbatimModuleSyntax</code></a> can be used to match this behavior.</p>\n<p>This example will work correctly:</p>\n<pre><code class=\"language-ts\">import type { Type1, Type2 } from './module.ts';\nimport { fn, type FnParams } from './fn.ts';\n</code></pre>\n<p>This will result in a runtime error:</p>\n<pre><code class=\"language-ts\">import { Type1, Type2 } from './module.ts';\nimport { fn, FnParams } from './fn.ts';\n</code></pre>",
              "type": "module",
              "displayName": "Importing types without `type` keyword"
            },
            {
              "textRaw": "Non-file forms of input",
              "name": "non-file_forms_of_input",
              "desc": "<p>Type stripping can be enabled for <code>--eval</code>. The module system\nwill be determined by <code>--input-type</code>, as it is for JavaScript.</p>\n<p>TypeScript syntax is unsupported in the REPL, STDIN input, <code>--print</code>, <code>--check</code>, and\n<code>inspect</code>.</p>",
              "type": "module",
              "displayName": "Non-file forms of input"
            },
            {
              "textRaw": "Source maps",
              "name": "source_maps",
              "desc": "<p>Since inline types are replaced by whitespace, source maps are unnecessary for\ncorrect line numbers in stack traces; and Node.js does not generate them. For\nsource maps support, see <a href=\"#full-typescript-support\">Full TypeScript support</a>.</p>",
              "type": "module",
              "displayName": "Source maps"
            },
            {
              "textRaw": "Type stripping in dependencies",
              "name": "type_stripping_in_dependencies",
              "desc": "<p>To discourage package authors from publishing packages written in TypeScript,\nNode.js will by default refuse to handle TypeScript files inside folders under\na <code>node_modules</code> path.</p>",
              "type": "module",
              "displayName": "Type stripping in dependencies"
            }
          ],
          "type": "module",
          "displayName": "Type stripping"
        }
      ],
      "type": "module",
      "displayName": "Modules: TypeScript"
    }
  ]
}