Skip to content

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

Closed
wants to merge 3 commits into from
Closed

add toString definitions for base types that have them #37839

wants to merge 3 commits into from

Conversation

bradzacher
Copy link
Contributor

@bradzacher bradzacher commented Apr 8, 2020

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 doesn't leak any [object Object].
typescript-eslint/typescript-eslint#1655

The rule relies upon every type that actually has a toString method declaring a toString 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.

@sandersn
Copy link
Member

sandersn commented May 5, 2020

@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.

@sandersn sandersn self-assigned this May 5, 2020
@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 2020

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 sandersn added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 5, 2020
@typescript-bot
Copy link
Collaborator

@sandersn
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..37839

Metric master 37839 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 328,182k (± 0.01%) 327,085k (± 0.04%) -1,097k (- 0.33%) 326,624k 327,270k
Parse Time 1.65s (± 0.41%) 1.64s (± 0.64%) -0.01s (- 0.43%) 1.61s 1.66s
Bind Time 0.91s (± 0.85%) 0.89s (± 1.18%) -0.02s (- 1.76%) 0.87s 0.92s
Check Time 4.83s (± 0.63%) 4.79s (± 0.76%) -0.04s (- 0.79%) 4.70s 4.87s
Emit Time 5.45s (± 0.74%) 5.37s (± 1.45%) -0.07s (- 1.36%) 5.27s 5.59s
Total Time 12.83s (± 0.39%) 12.70s (± 0.74%) -0.13s (- 1.02%) 12.52s 12.92s
Monaco - node (v10.16.3, x64)
Memory used 327,191k (± 0.01%) 327,048k (± 0.01%) -143k (- 0.04%) 326,923k 327,149k
Parse Time 1.27s (± 0.69%) 1.27s (± 0.70%) +0.00s (+ 0.08%) 1.26s 1.30s
Bind Time 0.79s (± 0.57%) 0.78s (± 0.71%) -0.01s (- 1.27%) 0.77s 0.79s
Check Time 4.81s (± 0.32%) 4.78s (± 0.54%) -0.03s (- 0.69%) 4.72s 4.84s
Emit Time 2.95s (± 0.92%) 2.93s (± 0.94%) -0.02s (- 0.81%) 2.88s 2.99s
Total Time 9.83s (± 0.44%) 9.76s (± 0.47%) -0.07s (- 0.72%) 9.64s 9.86s
TFS - node (v10.16.3, x64)
Memory used 292,328k (± 0.01%) 291,994k (± 0.02%) -334k (- 0.11%) 291,911k 292,108k
Parse Time 0.96s (± 0.54%) 0.96s (± 0.62%) -0.01s (- 0.52%) 0.94s 0.97s
Bind Time 0.76s (± 0.49%) 0.75s (± 0.66%) -0.01s (- 1.19%) 0.74s 0.76s
Check Time 4.37s (± 0.55%) 4.30s (± 0.67%) -0.06s (- 1.47%) 4.25s 4.39s
Emit Time 3.09s (± 0.85%) 3.07s (± 0.55%) -0.02s (- 0.74%) 3.04s 3.11s
Total Time 9.18s (± 0.45%) 9.08s (± 0.43%) -0.10s (- 1.05%) 8.98s 9.19s
material-ui - node (v10.16.3, x64)
Memory used 449,348k (± 0.01%) 450,413k (± 0.01%) +1,065k (+ 0.24%) 450,240k 450,579k
Parse Time 1.79s (± 0.55%) 1.79s (± 0.45%) -0.00s (- 0.22%) 1.77s 1.81s
Bind Time 0.70s (± 0.64%) 0.69s (± 0.68%) -0.01s (- 1.15%) 0.68s 0.70s
Check Time 12.61s (± 0.65%) 12.71s (± 0.69%) +0.10s (+ 0.75%) 12.56s 12.89s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.11s (± 0.55%) 15.19s (± 0.60%) +0.08s (+ 0.54%) 15.04s 15.38s
Angular - node (v12.1.0, x64)
Memory used 303,705k (± 0.03%) 302,757k (± 0.03%) -948k (- 0.31%) 302,579k 302,933k
Parse Time 1.61s (± 0.55%) 1.59s (± 0.73%) -0.01s (- 0.68%) 1.58s 1.62s
Bind Time 0.89s (± 0.41%) 0.88s (± 0.95%) -0.02s (- 2.13%) 0.86s 0.90s
Check Time 4.73s (± 0.56%) 4.66s (± 0.54%) -0.07s (- 1.42%) 4.61s 4.72s
Emit Time 5.58s (± 0.44%) 5.49s (± 0.67%) -0.09s (- 1.65%) 5.39s 5.56s
Total Time 12.82s (± 0.22%) 12.62s (± 0.41%) -0.19s (- 1.51%) 12.50s 12.72s
Monaco - node (v12.1.0, x64)
Memory used 307,196k (± 0.02%) 307,018k (± 0.01%) -177k (- 0.06%) 306,958k 307,063k
Parse Time 1.23s (± 0.68%) 1.23s (± 0.89%) +0.00s (+ 0.24%) 1.21s 1.25s
Bind Time 0.76s (± 0.63%) 0.75s (± 1.10%) -0.00s (- 0.40%) 0.74s 0.78s
Check Time 4.65s (± 0.74%) 4.61s (± 0.65%) -0.04s (- 0.92%) 4.55s 4.69s
Emit Time 2.99s (± 0.69%) 2.97s (± 0.92%) -0.02s (- 0.67%) 2.92s 3.04s
Total Time 9.62s (± 0.42%) 9.56s (± 0.45%) -0.06s (- 0.64%) 9.45s 9.66s
TFS - node (v12.1.0, x64)
Memory used 274,567k (± 0.02%) 274,391k (± 0.02%) -176k (- 0.06%) 274,254k 274,484k
Parse Time 0.93s (± 1.06%) 0.94s (± 0.62%) +0.01s (+ 1.18%) 0.93s 0.96s
Bind Time 0.72s (± 1.54%) 0.71s (± 1.16%) -0.01s (- 1.52%) 0.70s 0.73s
Check Time 4.28s (± 0.66%) 4.25s (± 0.27%) -0.03s (- 0.68%) 4.23s 4.28s
Emit Time 3.14s (± 0.66%) 3.10s (± 1.07%) -0.04s (- 1.18%) 3.05s 3.19s
Total Time 9.08s (± 0.49%) 9.01s (± 0.36%) -0.06s (- 0.72%) 8.96s 9.10s
material-ui - node (v12.1.0, x64)
Memory used 426,772k (± 0.02%) 427,803k (± 0.01%) +1,031k (+ 0.24%) 427,728k 427,880k
Parse Time 1.76s (± 0.54%) 1.76s (± 0.48%) +0.00s (+ 0.23%) 1.74s 1.77s
Bind Time 0.64s (± 1.37%) 0.65s (± 1.05%) +0.00s (+ 0.47%) 0.63s 0.66s
Check Time 11.13s (± 0.52%) 11.29s (± 0.82%) +0.16s (+ 1.44%) 11.15s 11.51s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 13.54s (± 0.43%) 13.70s (± 0.68%) +0.16s (+ 1.20%) 13.55s 13.91s
Angular - node (v8.9.0, x64)
Memory used 323,181k (± 0.02%) 322,073k (± 0.02%) -1,108k (- 0.34%) 321,872k 322,228k
Parse Time 2.14s (± 0.75%) 2.11s (± 0.32%) -0.02s (- 1.03%) 2.10s 2.13s
Bind Time 0.94s (± 1.12%) 0.92s (± 0.53%) -0.02s (- 1.70%) 0.92s 0.94s
Check Time 5.50s (± 0.96%) 5.47s (± 0.86%) -0.03s (- 0.51%) 5.30s 5.53s
Emit Time 6.23s (± 0.93%) 6.25s (± 1.03%) +0.02s (+ 0.32%) 6.10s 6.42s
Total Time 14.81s (± 0.51%) 14.76s (± 0.41%) -0.04s (- 0.30%) 14.60s 14.84s
Monaco - node (v8.9.0, x64)
Memory used 325,836k (± 0.02%) 325,516k (± 0.01%) -320k (- 0.10%) 325,422k 325,605k
Parse Time 1.55s (± 0.26%) 1.56s (± 0.36%) +0.01s (+ 0.45%) 1.55s 1.57s
Bind Time 0.91s (± 0.95%) 0.90s (± 0.72%) -0.01s (- 1.10%) 0.89s 0.92s
Check Time 5.43s (± 0.41%) 5.43s (± 0.54%) -0.00s (- 0.07%) 5.34s 5.47s
Emit Time 3.52s (± 0.74%) 3.52s (± 0.52%) +0.01s (+ 0.26%) 3.48s 3.58s
Total Time 11.41s (± 0.36%) 11.41s (± 0.34%) +0.00s (+ 0.04%) 11.34s 11.51s
TFS - node (v8.9.0, x64)
Memory used 291,905k (± 0.02%) 291,524k (± 0.02%) -381k (- 0.13%) 291,437k 291,682k
Parse Time 1.26s (± 0.44%) 1.27s (± 0.64%) +0.01s (+ 0.72%) 1.25s 1.29s
Bind Time 0.76s (± 0.63%) 0.75s (± 0.82%) -0.01s (- 1.06%) 0.74s 0.76s
Check Time 5.09s (± 1.72%) 5.05s (± 1.64%) -0.04s (- 0.79%) 4.90s 5.22s
Emit Time 3.21s (± 2.64%) 3.23s (± 3.33%) +0.02s (+ 0.65%) 3.05s 3.48s
Total Time 10.31s (± 0.54%) 10.29s (± 0.42%) -0.02s (- 0.17%) 10.22s 10.44s
material-ui - node (v8.9.0, x64)
Memory used 452,156k (± 0.01%) 452,915k (± 0.01%) +758k (+ 0.17%) 452,821k 452,986k
Parse Time 2.12s (± 0.35%) 2.11s (± 0.39%) -0.01s (- 0.38%) 2.10s 2.13s
Bind Time 0.83s (± 0.90%) 0.82s (± 0.83%) -0.01s (- 1.33%) 0.80s 0.83s
Check Time 16.68s (± 0.62%) 16.71s (± 0.56%) +0.03s (+ 0.17%) 16.54s 16.89s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 19.63s (± 0.51%) 19.64s (± 0.46%) +0.01s (+ 0.06%) 19.49s 19.82s
Angular - node (v8.9.0, x86)
Memory used 186,078k (± 0.03%) 185,391k (± 0.03%) -687k (- 0.37%) 185,294k 185,489k
Parse Time 2.06s (± 0.66%) 2.07s (± 0.92%) +0.01s (+ 0.49%) 2.05s 2.13s
Bind Time 1.08s (± 0.41%) 1.08s (± 1.11%) +0.00s (+ 0.09%) 1.06s 1.12s
Check Time 5.06s (± 0.64%) 5.01s (± 0.81%) -0.05s (- 1.03%) 4.94s 5.13s
Emit Time 6.09s (± 1.05%) 6.09s (± 1.28%) -0.01s (- 0.08%) 6.01s 6.37s
Total Time 14.29s (± 0.45%) 14.24s (± 0.96%) -0.05s (- 0.36%) 14.10s 14.75s
Monaco - node (v8.9.0, x86)
Memory used 185,596k (± 0.02%) 185,355k (± 0.03%) -241k (- 0.13%) 185,253k 185,513k
Parse Time 1.61s (± 0.92%) 1.60s (± 0.65%) -0.01s (- 0.68%) 1.58s 1.63s
Bind Time 0.77s (± 0.98%) 0.77s (± 0.61%) -0.00s (- 0.52%) 0.76s 0.78s
Check Time 5.49s (± 0.44%) 5.47s (± 0.66%) -0.01s (- 0.24%) 5.40s 5.58s
Emit Time 2.89s (± 1.08%) 2.88s (± 1.06%) -0.00s (- 0.10%) 2.82s 2.97s
Total Time 10.76s (± 0.45%) 10.73s (± 0.53%) -0.03s (- 0.26%) 10.61s 10.88s
TFS - node (v8.9.0, x86)
Memory used 167,163k (± 0.03%) 166,930k (± 0.03%) -234k (- 0.14%) 166,833k 167,034k
Parse Time 1.29s (± 0.43%) 1.30s (± 0.47%) +0.01s (+ 0.85%) 1.28s 1.31s
Bind Time 0.72s (± 0.51%) 0.72s (± 0.55%) +0.01s (+ 0.70%) 0.71s 0.73s
Check Time 4.70s (± 0.57%) 4.69s (± 0.73%) -0.01s (- 0.17%) 4.58s 4.75s
Emit Time 3.04s (± 2.72%) 3.02s (± 1.93%) -0.02s (- 0.79%) 2.92s 3.23s
Total Time 9.74s (± 0.90%) 9.73s (± 0.55%) -0.02s (- 0.16%) 9.62s 9.84s
material-ui - node (v8.9.0, x86)
Memory used 256,157k (± 0.02%) 256,437k (± 0.01%) +280k (+ 0.11%) 256,378k 256,498k
Parse Time 2.19s (± 0.73%) 2.19s (± 0.57%) -0.00s (- 0.18%) 2.16s 2.22s
Bind Time 0.70s (± 1.26%) 0.69s (± 1.16%) -0.01s (- 1.71%) 0.67s 0.70s
Check Time 15.37s (± 0.90%) 15.30s (± 0.55%) -0.07s (- 0.48%) 15.12s 15.46s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 18.26s (± 0.81%) 18.17s (± 0.47%) -0.09s (- 0.50%) 17.99s 18.34s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-166-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v8.9.0, x64)
  • material-ui - node (v8.9.0, x86)
Benchmark Name Iterations
Current 37839 10
Baseline master 10

@sandersn
Copy link
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.

@sandersn sandersn closed this May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants