-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module: add --experimental-strip-input-types #56273
module: add --experimental-strip-input-types #56273
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but then dont see how it can ever be enabled by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-types
as it is because when using--eval
it will ALWAYS emit an experimental warning and treat the input astypescript
regardless.This flag specifically enables the input of
--eval
to be treated as typescript that otherwise will be treated as javascript.Once
--experimental-strip-types
is stable we can unflag this too.I tested this PR with
--experimental-strip-types
unflagged 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-types
is no longer sufficient for input 🤷🏼♂️ but I don't see another way.