-
Notifications
You must be signed in to change notification settings - Fork 12.8k
add toString
definitions for base types that have them
#37839
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
Conversation
- RegExp: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString - Boolean: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString - Error: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString This came up as a result of the `@typescript-eslint/no-base-to-string` rule which aims to prevent you from accidentally using the `toString` method from the `Object` type so that your output is always nice. typescript-eslint/typescript-eslint#1655
@bradzacher can you open a bug for this? I think this needs some discussion on our side. @typescript-bot perf test this because I'm not sure what adding methods to a primitive's apparent type will do. |
Heya @sandersn, I've started to run the perf test suite on this PR at 6881e53. You can monitor the build here. Update: The results are in! |
@sandersn Here they are:Comparison Report - master..37839
System
Hosts
Scenarios
|
The bug this PR is for is waiting for feedback from the community, so I'm going to close it in the meantime to keep the number of open PRs manageable. We can re-open if that bug is accepted. |
This came up as a result of the
@typescript-eslint/no-base-to-string
rule which aims to prevent you from accidentally using thetoString
method from theObject
type so that your output doesn't leak any[object Object]
.typescript-eslint/typescript-eslint#1655
The rule relies upon every type that actually has a
toString
method declaring atoString
method.A few of our users ran into these cases that were reporting errors for them, even though they shouldn't.
I eyeballed the docs and the types and I am pretty certain that this completes the set of types that declare a
toString
.