-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
lib: add parser.stripTypeScriptTypes #55282
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
7c1529b
to
ecc1d82
Compare
ecc1d82
to
56fcf17
Compare
I think it makes more sense for it to be just in its own API as a function, which can be used to strip the type before the text is passed into any of the |
56fcf17
to
80fa828
Compare
there's also #54250 |
eca9ab2
to
f41d422
Compare
Unfortunately it seems to have been stalled for a while. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #55282 +/- ##
==========================================
- Coverage 88.41% 88.41% -0.01%
==========================================
Files 652 654 +2
Lines 186856 186939 +83
Branches 36058 36072 +14
==========================================
+ Hits 165210 165275 +65
- Misses 14901 14902 +1
- Partials 6745 6762 +17
|
50afe56
to
9ab643f
Compare
I think this could be benefited from a dedicated module |
Maybe putting it on module also makes sense? Or module.typescript if we can foresee adding other typescript-related utilities in the future |
I'm ok with a new module, I think parser is ok, I'd like to hear more opinions about it |
If we decide to ship it I'll drop the vm commits |
If this needs to be a new module, then it should be added to node/lib/internal/bootstrap/realm.js Line 130 in b4e8f1b
require('parser') without the node: prefix, otherwise it breaks https://www.npmjs.com/package/parser or anyone creating an alias of parser in node_modules.
|
76ff249
to
4fbcb6c
Compare
@marco-ippolito do you see a different parser added into this new module soon? I don't think we should add a new module just for a single function. Why don't we put it under util? |
@anonrig I think there is the possibility of adding more functions to manipulate code. But imho this new feature does not belong in any of the current modules |
Certainly I think the scope of the new function is clear that it provides new functionality of parsing and manipulating JS source codes, without evaluating them. |
@marco-ippolito We have parseEnv method in node:util. So this means we will add that function to node:parser as well? |
Yes, it manipulates source code without evaluating it (even though its not js) |
1f6b897
to
777ea5d
Compare
Failed to start CI⚠ Something was pushed to the Pull Request branch since the last approving review. ✘ Refusing to run CI on potentially unsafe PRhttps://github.com/nodejs/node/actions/runs/11327838941 |
5956acc
to
ede9ffe
Compare
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.
I'm sorry for doing this, but I think we shouldn't introduce a new module just for a single method. This should live in node:util with similar functions like parseEnv.
@anonrig I feel like I motivated the decision in previous comment, that function that manipulate source code without evaluating should be moved to this module, like |
@marco-ippolito I think this is a textbook case for calling a vote. I dislike the use of name
|
Fixes: #54300