Skip to content

Commit 3e34c66

Browse files
module: unflag --experimental-strip-types
PR-URL: #56350 Fixes: nodejs/typescript#17 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Pietro Marchini <[email protected]>
1 parent be79f4a commit 3e34c66

22 files changed

+68
-127
lines changed

benchmark/ts/strip-typescript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
1212
filepath: [ts, js],
1313
n: [1e4],
1414
}, {
15-
flags: ['--experimental-strip-types', '--disable-warning=ExperimentalWarning'],
15+
flags: ['--disable-warning=ExperimentalWarning'],
1616
});
1717

1818
async function main({ n, filepath }) {

doc/api/cli.md

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ Any query parameter or hash in the URL will be accessible via [`import.meta.url`
778778

779779
```bash
780780
node --entry-url 'file:///path/to/file.js?queryparams=work#and-hashes-too'
781-
node --entry-url --experimental-strip-types 'file.ts?query#hash'
781+
node --entry-url 'file.ts?query#hash'
782782
node --entry-url 'data:text/javascript,console.log("Hello")'
783783
```
784784

@@ -878,8 +878,8 @@ On Windows, using `cmd.exe` a single quote will not work correctly because it
878878
only recognizes double `"` for quoting. In Powershell or Git bash, both `'`
879879
and `"` are usable.
880880

881-
It is possible to run code containing inline types by passing
882-
[`--experimental-strip-types`][].
881+
It is possible to run code containing inline types unless the
882+
[`--no-experimental-strip-types`][] flag is provided.
883883

884884
### `--experimental-async-context-frame`
885885

@@ -1040,17 +1040,6 @@ added:
10401040

10411041
Use this flag to enable [ShadowRealm][] support.
10421042

1043-
### `--experimental-strip-types`
1044-
1045-
<!-- YAML
1046-
added: v22.6.0
1047-
-->
1048-
1049-
> Stability: 1.1 - Active development
1050-
1051-
Enable experimental type-stripping for TypeScript files.
1052-
For more information, see the [TypeScript type-stripping][] documentation.
1053-
10541043
### `--experimental-test-coverage`
10551044

10561045
<!-- YAML
@@ -1110,7 +1099,7 @@ added: v22.7.0
11101099
> Stability: 1.1 - Active development
11111100
11121101
Enables the transformation of TypeScript-only syntax into JavaScript code.
1113-
Implies `--experimental-strip-types` and `--enable-source-maps`.
1102+
Implies `--enable-source-maps`.
11141103

11151104
### `--experimental-vm-modules`
11161105

@@ -1415,9 +1404,10 @@ added: v12.0.0
14151404

14161405
This configures Node.js to interpret `--eval` or `STDIN` input as CommonJS or
14171406
as an ES module. Valid values are `"commonjs"`, `"module"`, `"module-typescript"` and `"commonjs-typescript"`.
1418-
The `"-typescript"` values are available only in combination with the flag `--experimental-strip-types`.
1419-
The default is `"commonjs"` unless [`--experimental-default-type=module`][] is used.
1420-
If `--experimental-strip-types` is enabled and `--input-type` is not provided,
1407+
The `"-typescript"` values are not available with the flag `--no-experimental-strip-types`.
1408+
The default is `"commonjs"`.
1409+
1410+
If `--input-type` is not provided,
14211411
Node.js will try to detect the syntax with the following steps:
14221412

14231413
1. Run the input as CommonJS.
@@ -1712,6 +1702,21 @@ changes:
17121702

17131703
Disable the experimental [`node:sqlite`][] module.
17141704

1705+
### `--no-experimental-strip-types`
1706+
1707+
<!-- YAML
1708+
added: v22.6.0
1709+
changes:
1710+
- version: REPLACEME
1711+
pr-url: https://github.com/nodejs/node/pull/56350
1712+
description: Type stripping is enabled by default.
1713+
-->
1714+
1715+
> Stability: 1.1 - Active development
1716+
1717+
Disable experimental type-stripping for TypeScript files.
1718+
For more information, see the [TypeScript type-stripping][] documentation.
1719+
17151720
### `--no-experimental-websocket`
17161721

17171722
<!-- YAML
@@ -3145,7 +3150,6 @@ one is included in the list below.
31453150
* `--experimental-require-module`
31463151
* `--experimental-shadow-realm`
31473152
* `--experimental-specifier-resolution`
3148-
* `--experimental-strip-types`
31493153
* `--experimental-top-level-await`
31503154
* `--experimental-transform-types`
31513155
* `--experimental-vm-modules`
@@ -3184,6 +3188,7 @@ one is included in the list below.
31843188
* `--no-experimental-global-webcrypto`
31853189
* `--no-experimental-repl-await`
31863190
* `--no-experimental-sqlite`
3191+
* `--no-experimental-strip-types`
31873192
* `--no-experimental-websocket`
31883193
* `--no-extra-info-on-fatal-exception`
31893194
* `--no-force-async-hooks-checks`
@@ -3714,10 +3719,10 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
37143719
[`--env-file`]: #--env-fileconfig
37153720
[`--experimental-default-type=module`]: #--experimental-default-typetype
37163721
[`--experimental-sea-config`]: single-executable-applications.md#generating-single-executable-preparation-blobs
3717-
[`--experimental-strip-types`]: #--experimental-strip-types
37183722
[`--experimental-wasm-modules`]: #--experimental-wasm-modules
37193723
[`--heap-prof-dir`]: #--heap-prof-dir
37203724
[`--import`]: #--importmodule
3725+
[`--no-experimental-strip-types`]: #--no-experimental-strip-types
37213726
[`--openssl-config`]: #--openssl-configfile
37223727
[`--preserve-symlinks`]: #--preserve-symlinks
37233728
[`--print`]: #-p---print-script

doc/api/process.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,8 +2013,9 @@ added: v22.10.0
20132013
20142014
* {boolean|string}
20152015
2016-
A value that is `"strip"` if Node.js is run with `--experimental-strip-types`,
2017-
`"transform"` if Node.js is run with `--experimental-transform-types`, and `false` otherwise.
2016+
A value that is `"strip"` by default,
2017+
`"transform"` if Node.js is run with `--experimental-transform-types`, and `false` if
2018+
Node.js is run with `--no-experimental-strip-types`.
20182019
20192020
## `process.features.uv`
20202021

doc/api/test.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ By default, Node.js will run all files matching these patterns:
420420
* `**/test.{cjs,mjs,js}`
421421
* `**/test/**/*.{cjs,mjs,js}`
422422

423-
When [`--experimental-strip-types`][] is supplied, the following
424-
additional patterns are matched:
423+
Unless [`--no-experimental-strip-types`][] is supplied, the following
424+
additional patterns are also matched:
425425

426426
* `**/*.test.{cts,mts,ts}`
427427
* `**/*-test.{cts,mts,ts}`
@@ -3639,10 +3639,10 @@ Can be used to abort test subtasks when the test has been aborted.
36393639

36403640
[TAP]: https://testanything.org/
36413641
[TTY]: tty.md
3642-
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
36433642
[`--experimental-test-coverage`]: cli.md#--experimental-test-coverage
36443643
[`--experimental-test-module-mocks`]: cli.md#--experimental-test-module-mocks
36453644
[`--import`]: cli.md#--importmodule
3645+
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
36463646
[`--test-concurrency`]: cli.md#--test-concurrency
36473647
[`--test-coverage-include`]: cli.md#--test-coverage-include
36483648
[`--test-name-pattern`]: cli.md#--test-name-pattern

doc/api/typescript.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
<!-- YAML
44
changes:
5+
- version: REPLACEME
6+
pr-url: https://github.com/nodejs/node/pull/56350
7+
description: Type stripping is enabled by default.
58
- version: v22.7.0
69
pr-url: https://github.com/nodejs/node/pull/54283
710
description: Added `--experimental-transform-types` flag.
@@ -52,7 +55,7 @@ added: v22.6.0
5255

5356
> Stability: 1.1 - Active development
5457
55-
The flag [`--experimental-strip-types`][] enables Node.js to run TypeScript
58+
The flag [`--no-experimental-strip-types`][] prevents Node.js from running TypeScript
5659
files. By default Node.js will execute only files that contain no
5760
TypeScript features that require transformation, such as enums or namespaces.
5861
Node.js will replace inline type annotations with whitespace,
@@ -181,8 +184,8 @@ with `#`.
181184
[CommonJS]: modules.md
182185
[ES Modules]: esm.md
183186
[Full TypeScript support]: #full-typescript-support
184-
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
185187
[`--experimental-transform-types`]: cli.md#--experimental-transform-types
188+
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
186189
[`tsconfig` "paths"]: https://www.typescriptlang.org/tsconfig/#paths
187190
[`tsx`]: https://tsx.is/
188191
[`verbatimModuleSyntax`]: https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax

doc/node.1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@ Configures the type of test isolation used in the test runner.
191191
.It Fl -experimental-test-module-mocks
192192
Enable module mocking in the test runner.
193193
.
194-
.It Fl -experimental-strip-types
195-
Enable experimental type-stripping for TypeScript files.
196-
.
197194
.It Fl -experimental-transform-types
198195
Enable transformation of TypeScript-only syntax into JavaScript code.
199196
.
@@ -221,6 +218,9 @@ Disable top-level await keyword support in REPL.
221218
.It Fl -no-experimental-sqlite
222219
Disable the experimental node:sqlite module.
223220
.
221+
.It Fl -no-experimental-strip-types
222+
Disable experimental type-stripping for TypeScript files.
223+
.
224224
.It Fl -experimental-vm-modules
225225
Enable experimental ES module support in VM module.
226226
.

src/node_options.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
884884
AddOption("--experimental-strip-types",
885885
"Experimental type-stripping for TypeScript files.",
886886
&EnvironmentOptions::experimental_strip_types,
887-
kAllowedInEnvvar);
887+
kAllowedInEnvvar,
888+
true);
888889
Implies("--experimental-strip-types", "--experimental-detect-module");
889890

890891
AddOption("--experimental-transform-types",

src/node_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class EnvironmentOptions : public Options {
250250

251251
std::vector<std::string> preload_esm_modules;
252252

253-
bool experimental_strip_types = false;
253+
bool experimental_strip_types = true;
254254
bool experimental_transform_types = false;
255255

256256
std::vector<std::string> user_argv;

test/es-module/test-esm-loader-entry-url.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('--entry-url', { concurrency: true }, () => {
8484

8585
for (const url of typescriptUrls) {
8686
await assertSpawnedProcess(
87-
['--entry-url', '--experimental-strip-types', fixtures.fileURL(url)],
87+
['--entry-url', fixtures.fileURL(url)],
8888
{},
8989
{
9090
...experimentalFeatureWarning,

test/es-module/test-esm-resolve-type.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ try {
188188
[ 'qmod', 'index.js', 'imp.js', 'commonjs', 'module', 'module', '?k=v'],
189189
[ 'hmod', 'index.js', 'imp.js', 'commonjs', 'module', 'module', '#Key'],
190190
[ 'qhmod', 'index.js', 'imp.js', 'commonjs', 'module', 'module', '?k=v#h'],
191-
[ 'ts-mod-com', 'index.js', 'imp.ts', 'module', 'commonjs', undefined],
191+
[ 'ts-mod-com', 'index.js', 'imp.ts', 'module', 'commonjs', 'commonjs-typescript'],
192192
].forEach((testVariant) => {
193193
const [
194194
moduleName,

0 commit comments

Comments
 (0)