Skip to content
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: wrap swc error in ERR_INVALID_TYPESCRIPT_SYNTAX #55316

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

marco-ippolito
Copy link
Member

This PR wraps swc errors in a Node error to provide a more consistent error handling.

Before this PR

marcoippolito@marcos-MacBook-Pro node % node --experimental-strip-types -p "enum Foo{}"

node:internal/deps/amaro/dist/index:226
          throw takeObject(r1);
          ^
  x TypeScript enum is not supported in strip-only mode
   ,----
 1 | enum Foo{}
   : ^^^^^^^^^^
   `----

(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js v22.8.0

After this PR

marcoippolito@marcos-MacBook-Pro node % ./node --experimental-strip-types -p "enum Foo{}"                      
node:internal/modules/helpers:390
    throw new ERR_INVALID_TYPESCRIPT_SYNTAX(error);
    ^

SyntaxError [ERR_INVALID_TYPESCRIPT_SYNTAX]:   x TypeScript enum is not supported in strip-only mode
   ,----
 1 | enum Foo{}
   : ^^^^^^^^^^
   `----

    at stripTypeScriptTypes (node:internal/modules/helpers:390:11)
    at node:internal/main/eval_string:27:3 {
  code: 'ERR_INVALID_TYPESCRIPT_SYNTAX'
}

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. labels Oct 8, 2024
@marco-ippolito marco-ippolito added the strip-types Issues or PRs related to strip-types support label Oct 8, 2024
Copy link
Contributor

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.90%. Comparing base (bbdfeeb) to head (902491b).
Report is 284 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55316      +/-   ##
==========================================
- Coverage   88.41%   87.90%   -0.52%     
==========================================
  Files         652      652              
  Lines      186612   186756     +144     
  Branches    36062    35789     -273     
==========================================
- Hits       165001   164170     -831     
- Misses      14885    15803     +918     
- Partials     6726     6783      +57     
Files with missing lines Coverage Δ
lib/internal/errors.js 94.29% <100.00%> (-2.69%) ⬇️
lib/internal/modules/helpers.js 98.20% <100.00%> (-0.82%) ⬇️

... and 110 files with indirect coverage changes

Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marco-ippolito marco-ippolito added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 8, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 8, 2024
@nodejs-github-bot
Copy link
Collaborator

@marco-ippolito marco-ippolito added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 8, 2024
@marco-ippolito marco-ippolito added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 9, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 9, 2024
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nodejs-github-bot
Copy link
Collaborator

@marco-ippolito marco-ippolito added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 9, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 10, 2024
@nodejs-github-bot nodejs-github-bot merged commit 31a37e7 into nodejs:main Oct 10, 2024
59 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 31a37e7

aduh95 pushed a commit that referenced this pull request Oct 11, 2024
PR-URL: #55316
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@aduh95 aduh95 mentioned this pull request Oct 11, 2024
louwers pushed a commit to louwers/node that referenced this pull request Nov 2, 2024
PR-URL: nodejs#55316
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@marco-ippolito marco-ippolito added the dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. label Nov 16, 2024
tpoisseau pushed a commit to tpoisseau/node that referenced this pull request Nov 21, 2024
PR-URL: nodejs#55316
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. errors Issues and PRs related to JavaScript errors originated in Node.js core. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. strip-types Issues or PRs related to strip-types support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants