-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
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.
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.
lib/internal/util/inspect.js
Outdated
const name = descriptor.value.name; | ||
return typeof name === 'symbol' ? SymbolPrototypeToString(name) : name; |
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.
const name = descriptor.value.name; | |
return typeof name === 'symbol' ? SymbolPrototypeToString(name) : name; | |
return String(descriptor.value.name); |
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.
Thank you. That makes sense!
PR-URL: #42790 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Landed in 027c288 |
PR-URL: #42790 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #42790 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #42790 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: nodejs/node#42790 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
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 bySymbol.prototype.toString
beforehand since${Symbol()}
throws TypeError (spec).