module: add --experimental-strip-input-types#56273
module: add --experimental-strip-input-types#56273marco-ippolito wants to merge 2 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
|
I wonder why do we have to emit the warning - can't we just strip it always for |
|
Also, alternatively we can just skip the entrypoint warning for |
|
Even if we dont emit a warning the syntax errors are wrapped by swc. |
Is that thrown during type stripping? If the error is identifyable I think we can just catch it in that case, and move on to parse/evaluate the original source? |
Yes the error is thrown during type stripping. |
588e2a7 to
c5704d8
Compare
|
Or a solution could be to wrap all |
| ### `--experimental-strip-input-types` | ||
|
|
||
| <!-- YAML | ||
| added: REPLACEME | ||
| --> | ||
|
|
||
| > Stability: 1.1 - Active development | ||
|
|
||
| Enable experimental type-stripping for `--eval`. | ||
| Implies [`--experimental-strip-types`][]. | ||
| For more information, see the [TypeScript type-stripping][] documentation. |
There was a problem hiding this comment.
Ideally this could just be a new value for --input-type, so like --input-type=strip-types; could that work? And I guess it would rely on syntax detection to determine format, or it would just always assume ESM since TypeScript syntax seems to be always ESM?
There was a problem hiding this comment.
Yeah but then dont see how it can ever be enabled by default.
There was a problem hiding this comment.
You could take the same approach as syntax detection: try to run as regular --eval, if it throws based on an exception that might’ve been caused by TypeScript syntax, retry as --input-type=strip-types.
There was a problem hiding this comment.
Yes thats what Im experimenting
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #56273 +/- ##
==========================================
- Coverage 88.55% 88.54% -0.01%
==========================================
Files 657 657
Lines 190243 190243
Branches 36536 36541 +5
==========================================
- Hits 168461 168450 -11
- Misses 14963 14968 +5
- Partials 6819 6825 +6
|
|
Found a workaround 😄 I'll open a new PR |
Refs: nodejs/typescript#17
We cannot unflag
--experimental-strip-typesas it is because when using--evalit will ALWAYS emit an experimental warning and treat the input astypescriptregardless.This flag specifically enables the input of
--evalto be treated as typescript that otherwise will be treated as javascript.Once
--experimental-strip-typesis stable we can unflag this too.I tested this PR with
--experimental-strip-typesunflagged and it goes smoothly.This is a breaking change (it's experimental so it should not matter too much but still) since now
--experimental-strip-typesis no longer sufficient for input 🤷🏼♂️ but I don't see another way.