add toString definitions for base types that have them#37839
Closed
bradzacher wants to merge 3 commits intomicrosoft:masterfrom
bradzacher:base-toString
Closed
add toString definitions for base types that have them#37839bradzacher wants to merge 3 commits intomicrosoft:masterfrom bradzacher:base-toString
toString definitions for base types that have them#37839bradzacher wants to merge 3 commits intomicrosoft:masterfrom
bradzacher:base-toString
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
Member
|
@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. |
Collaborator
|
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! |
Collaborator
|
@sandersn Here they are:Comparison Report - master..37839
System
Hosts
Scenarios
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 tasks
Member
|
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. |
Collaborator
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This came up as a result of the
@typescript-eslint/no-base-to-stringrule which aims to prevent you from accidentally using thetoStringmethod from theObjecttype 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
toStringmethod declaring atoStringmethod.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.