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

util: fix TypeError when console.log a static property name in class #42790

Closed
wants to merge 2 commits into from

Conversation

cola119
Copy link
Member

@cola119 cola119 commented Apr 20, 2022

Fixed #42773

Constructor name from getConstructorName will be converted to string by template literal (${constructor}) in a subsequent process.

In this case, getConstructorName need to convert symbol to string by Symbol.prototype.toString beforehand since ${Symbol()} throws TypeError (spec).

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Apr 20, 2022
@meixg meixg added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 20, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 20, 2022
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

This is definitely the right spot where to fix it!

Ti improve it further, we could just use String(). That way other types are also handled properly.

Comment on lines 582 to 583
const name = descriptor.value.name;
return typeof name === 'symbol' ? SymbolPrototypeToString(name) : name;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const name = descriptor.value.name;
return typeof name === 'symbol' ? SymbolPrototypeToString(name) : name;
return String(descriptor.value.name);

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you. That makes sense!

@cola119 cola119 requested a review from BridgeAR April 23, 2022 03:52
@watilde watilde added the request-ci Add this label to start a Jenkins CI on a PR. label May 19, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 19, 2022
@nodejs-github-bot
Copy link
Collaborator

@cola119
Copy link
Member Author

cola119 commented Jun 5, 2022

@jasnell @BridgeAR Could you please re-trigger the test and merge? Thank you in advance!

@BridgeAR BridgeAR added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jun 11, 2022
@panva panva added request-ci Add this label to start a Jenkins CI on a PR. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 16, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 16, 2022
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@panva panva closed this Jun 17, 2022
panva pushed a commit that referenced this pull request Jun 17, 2022
PR-URL: #42790
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@panva
Copy link
Member

panva commented Jun 17, 2022

Landed in 027c288

targos pushed a commit that referenced this pull request Jul 12, 2022
PR-URL: #42790
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
targos pushed a commit that referenced this pull request Jul 18, 2022
PR-URL: #42790
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
targos pushed a commit that referenced this pull request Jul 31, 2022
PR-URL: #42790
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
PR-URL: nodejs/node#42790
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError when console.log a static property name in class
7 participants