-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Use .toString() as functions' representation, fix #5140 #5189
Conversation
Use .toString() as functions' representation.
@@ -47,7 +47,7 @@ export class ModuleTokenFactory { | |||
|
|||
private replacer(key: string, value: any) { | |||
if (typeof value === 'function') { |
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.
We should check if the value
is a class here and use value.name
if so.
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.
To check if a value is a class, toString()
is still needed to be called.
I think there is no need to do so since the returned value is proceeded by a hash function immediately.
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.
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.
What I'm trying to say is that it would be great if we could still return value.name
for classes, not .toString()
.
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 mean,... How?
@@ -47,7 +47,7 @@ export class ModuleTokenFactory { | |||
|
|||
private replacer(key: string, value: any) { | |||
if (typeof value === 'function') { | |||
return value.name; | |||
return value.toString(); |
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.
We can very likely limit the number of characters (slice) to slightly optimize this process. ~50 should be enough to distinguish arrow functions
Use .toString() as functions' representation.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #5140
What is the new behavior?
Does this PR introduce a breaking change?
Other information