Skip to content

feat: support native Error causes - #141

Closed
legobeat wants to merge 7 commits into
MetaMask:mainfrom
legobeat:propagate-data-cause-es2022
Closed

feat: support native Error causes#141
legobeat wants to merge 7 commits into
MetaMask:mainfrom
legobeat:propagate-data-cause-es2022

Conversation

@legobeat

@legobeatlegobeat commented May 13, 2024

Copy link
Copy Markdown
Contributor

Alternative/follow-up to #140.

This utilizes the runtime Error constructor parameter options.cause to propagate data.cause. The explicit assignment of the property in #140 is preserved as fallback, which should make this change non-breaking.

This requires change tsconfig lib from ES2020 to ES2022 to be recognized. Alternatively, if allowing es2022 lib is not desired at this point, the cause prop could be explicitly added/shadowed like in #140.

Related

Based on

metamask-extension preview branch

@legobeatlegobeat changed the title Propagate data cause es2022feat: support native Error causesMay 13, 2024
Comment threadjest.config.js
functions: 94.44,
lines: 92.85,
statements: 92.85,
branches: 91.89,

@legobeatlegobeatMay 13, 2024

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

The reductions here arise from the fallback never triggering since native causes are not used in all tested environments.

Adding test-coverage for the fallback would involve some wider changes to the test suite, I believe.

@MrtenzMrtenz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this makes sense. When serialised, the cause is still serialised as data.cause, right?

@legobeat

legobeat commented May 16, 2024

Copy link
Copy Markdown
ContributorAuthor

I think this makes sense. When serialised, the cause is still serialised as data.cause, right?

That's the idea, yes!

rekmarks
rekmarks previously approved these changes May 27, 2024

@rekmarksrekmarks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@legobeat
legobeat requested a review from a teamMay 27, 2024 20:50
Comment threadtsconfig.json Outdated
@legobeat
legobeat requested a review from a teamMay 27, 2024 21:48
Comment threadtsconfig.json
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ES2020"],
"lib": ["ES2022"],

@mcmiremcmireMay 28, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, I'm not sure we can do this yet due to React Native not supporting ES2020+. There is a thread in chat about this. Search for "ES2020"; it should be the third message down. (I'll DM it to you.)

These changes look good to me otherwise, though.

@legobeatlegobeatMay 29, 2024

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@mcmire Since es2022 is not an option, which of the following is preferred?

@legobeat
legobeat requested a review from mcmireMay 29, 2024 01:59
@legobeat

Copy link
Copy Markdown
ContributorAuthor

Closing in favor of #140

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants

@legobeat@mcmire@Mrtenz@rekmarks