From e0ac82efb99e44efe105e91257f51bd4200926c4 Mon Sep 17 00:00:00 2001 From: Marco Ippolito Date: Fri, 9 Aug 2024 12:34:09 +0200 Subject: [PATCH] module: add --experimental-enable-transformation for strip-types --- doc/api/cli.md | 10 ++ doc/api/typescript.md | 38 ++++-- doc/node.1 | 3 + lib/internal/main/eval_string.js | 4 +- lib/internal/modules/cjs/loader.js | 16 +-- lib/internal/modules/esm/get_format.js | 6 +- lib/internal/modules/esm/translators.js | 8 +- lib/internal/modules/helpers.js | 39 +++++- src/node_options.cc | 6 + src/node_options.h | 1 + test/es-module/test-typescript-transform.mjs | 124 ++++++++++++++++++ .../transformation/test-complex-stacktrace.ts | 67 ++++++++++ .../ts/transformation/test-decorator.ts | 10 ++ .../ts/transformation/test-enum-stacktrace.ts | 4 + .../typescript/ts/transformation/test-enum.ts | 4 + .../ts/transformation/test-legacy-module.ts | 12 ++ .../ts/transformation/test-namespace.ts | 7 + .../ts/transformation/test-unused-import.ts | 3 + 18 files changed, 324 insertions(+), 38 deletions(-) create mode 100644 test/es-module/test-typescript-transform.mjs create mode 100644 test/fixtures/typescript/ts/transformation/test-complex-stacktrace.ts create mode 100644 test/fixtures/typescript/ts/transformation/test-decorator.ts create mode 100644 test/fixtures/typescript/ts/transformation/test-enum-stacktrace.ts create mode 100644 test/fixtures/typescript/ts/transformation/test-enum.ts create mode 100644 test/fixtures/typescript/ts/transformation/test-legacy-module.ts create mode 100644 test/fixtures/typescript/ts/transformation/test-namespace.ts create mode 100644 test/fixtures/typescript/ts/transformation/test-unused-import.ts diff --git a/doc/api/cli.md b/doc/api/cli.md index c0dfcd418b96a1..78d342f0f90cda 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -933,6 +933,15 @@ files with no extension will be treated as WebAssembly if they begin with the WebAssembly magic number (`\0asm`); otherwise they will be treated as ES module JavaScript. +### `--experimental-enable-transformation` + + + +Enables the transformation of TypeScript-only syntax into JavaScript code. +Implies `--experimental-strip-types`. + ### `--experimental-eventsource`