Skip to content

Remove undefined from optional properties when inferring to index signatures #43086

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

Merged
merged 2 commits into from
Mar 6, 2021

Conversation

ahejlsberg
Copy link
Member

Fixes #43045.

let a1 = foo(x1); // string | number
let a2 = foo(x2); // string | number | undefined
let a3 = foo(x3); // string | number
let a4 = foo(x4); // string | number
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm - seems like this is the only questionable one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectively, because we don't have a separate missing type, undefined represents the missing state in optional properties, so we really should remove undefined when we're inferring to an index signature as index signatures represent the type of those properties that are present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like things are getting a bit untenable without missing; any plausible implementation of foo with a legal x4 could return undefined. We should revisit it.

@DanielRosenwasser
Copy link
Member

@typescript-bot test this
@typescript-bot user test this
@typescript-bot run dt
@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 5, 2021

Heya @DanielRosenwasser, I've started to run the parallelized Definitely Typed test suite on this PR at 85815b0. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 5, 2021

Heya @DanielRosenwasser, I've started to run the extended test suite on this PR at 85815b0. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 5, 2021

Heya @DanielRosenwasser, I've started to run the parallelized community code test suite on this PR at 85815b0. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 5, 2021

Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at 85815b0. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 5, 2021

Heya @DanielRosenwasser, I've started to run the abridged perf test suite on this PR at 85815b0. You can monitor the build here.

Update: The results are in!

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Mar 5, 2021

Check with @andrewbranch too since he made the corresponding change.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..43086

Metric master 43086 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 348,535k (± 0.03%) 348,503k (± 0.02%) -32k (- 0.01%) 348,394k 348,634k
Parse Time 1.93s (± 0.80%) 1.91s (± 0.27%) -0.02s (- 1.09%) 1.90s 1.92s
Bind Time 0.83s (± 0.72%) 0.83s (± 0.84%) -0.00s (- 0.48%) 0.82s 0.85s
Check Time 5.06s (± 0.50%) 5.02s (± 0.42%) -0.04s (- 0.89%) 4.96s 5.06s
Emit Time 5.97s (± 0.85%) 5.91s (± 0.59%) -0.06s (- 1.09%) 5.85s 6.02s
Total Time 13.80s (± 0.50%) 13.66s (± 0.36%) -0.13s (- 0.97%) 13.58s 13.80s
Compiler-Unions - node (v10.16.3, x64)
Memory used 204,763k (± 0.03%) 204,674k (± 0.12%) -89k (- 0.04%) 203,762k 204,950k
Parse Time 0.78s (± 0.79%) 0.78s (± 0.86%) -0.00s (- 0.51%) 0.76s 0.79s
Bind Time 0.52s (± 1.39%) 0.52s (± 0.90%) -0.00s (- 0.38%) 0.51s 0.53s
Check Time 7.46s (± 0.49%) 7.43s (± 0.74%) -0.03s (- 0.39%) 7.32s 7.58s
Emit Time 2.59s (± 0.77%) 2.58s (± 0.47%) -0.01s (- 0.23%) 2.55s 2.61s
Total Time 11.35s (± 0.43%) 11.31s (± 0.50%) -0.04s (- 0.38%) 11.21s 11.47s
Monaco - node (v10.16.3, x64)
Memory used 356,625k (± 0.02%) 356,633k (± 0.02%) +8k (+ 0.00%) 356,434k 356,824k
Parse Time 1.57s (± 0.89%) 1.56s (± 0.33%) -0.01s (- 0.57%) 1.55s 1.57s
Bind Time 0.74s (± 1.05%) 0.73s (± 0.93%) -0.01s (- 0.94%) 0.72s 0.75s
Check Time 5.20s (± 0.56%) 5.19s (± 0.58%) -0.01s (- 0.12%) 5.10s 5.26s
Emit Time 3.14s (± 0.93%) 3.12s (± 0.79%) -0.02s (- 0.64%) 3.08s 3.20s
Total Time 10.65s (± 0.57%) 10.61s (± 0.36%) -0.04s (- 0.40%) 10.50s 10.67s
TFS - node (v10.16.3, x64)
Memory used 308,931k (± 0.02%) 308,989k (± 0.03%) +58k (+ 0.02%) 308,796k 309,303k
Parse Time 1.22s (± 0.82%) 1.21s (± 0.30%) -0.01s (- 0.90%) 1.20s 1.21s
Bind Time 0.70s (± 0.98%) 0.69s (± 0.98%) -0.00s (- 0.29%) 0.68s 0.71s
Check Time 4.69s (± 0.48%) 4.69s (± 0.76%) +0.00s (+ 0.04%) 4.62s 4.76s
Emit Time 3.24s (± 0.65%) 3.23s (± 1.45%) -0.01s (- 0.25%) 3.13s 3.30s
Total Time 9.85s (± 0.49%) 9.82s (± 0.76%) -0.02s (- 0.23%) 9.69s 9.97s
material-ui - node (v10.16.3, x64)
Memory used 501,518k (± 0.01%) 501,585k (± 0.02%) +67k (+ 0.01%) 501,400k 501,778k
Parse Time 2.00s (± 0.56%) 1.99s (± 0.86%) -0.01s (- 0.35%) 1.96s 2.03s
Bind Time 0.65s (± 1.30%) 0.65s (± 0.95%) +0.00s (+ 0.00%) 0.64s 0.67s
Check Time 14.28s (± 0.77%) 14.23s (± 0.80%) -0.05s (- 0.33%) 14.01s 14.55s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.92s (± 0.67%) 16.87s (± 0.74%) -0.05s (- 0.32%) 16.62s 17.23s
Angular - node (v12.1.0, x64)
Memory used 326,265k (± 0.03%) 326,149k (± 0.02%) -116k (- 0.04%) 325,972k 326,303k
Parse Time 1.92s (± 0.99%) 1.90s (± 0.46%) -0.02s (- 0.83%) 1.89s 1.93s
Bind Time 0.81s (± 0.68%) 0.81s (± 1.19%) -0.00s (- 0.37%) 0.79s 0.84s
Check Time 4.92s (± 0.52%) 4.93s (± 0.69%) +0.00s (+ 0.08%) 4.87s 5.01s
Emit Time 6.03s (± 0.57%) 6.00s (± 0.76%) -0.04s (- 0.65%) 5.94s 6.15s
Total Time 13.69s (± 0.41%) 13.63s (± 0.57%) -0.06s (- 0.40%) 13.53s 13.86s
Compiler-Unions - node (v12.1.0, x64)
Memory used 191,416k (± 0.03%) 191,370k (± 0.02%) -46k (- 0.02%) 191,274k 191,436k
Parse Time 0.77s (± 0.62%) 0.77s (± 0.84%) -0.01s (- 0.65%) 0.76s 0.78s
Bind Time 0.53s (± 0.89%) 0.52s (± 0.57%) -0.01s (- 2.26%) 0.51s 0.52s
Check Time 7.00s (± 0.52%) 6.87s (± 0.59%) -0.13s (- 1.91%) 6.80s 6.98s
Emit Time 2.57s (± 1.05%) 2.55s (± 0.46%) -0.02s (- 0.62%) 2.51s 2.57s
Total Time 10.87s (± 0.37%) 10.70s (± 0.46%) -0.17s (- 1.52%) 10.60s 10.82s
Monaco - node (v12.1.0, x64)
Memory used 339,033k (± 0.02%) 339,034k (± 0.04%) +1k (+ 0.00%) 338,846k 339,501k
Parse Time 1.55s (± 0.79%) 1.52s (± 0.66%) -0.03s (- 1.74%) 1.50s 1.54s
Bind Time 0.72s (± 0.31%) 0.72s (± 1.01%) -0.00s (- 0.42%) 0.70s 0.73s
Check Time 5.05s (± 0.39%) 5.00s (± 0.52%) -0.05s (- 1.07%) 4.95s 5.07s
Emit Time 3.16s (± 0.71%) 3.09s (± 0.68%) -0.07s (- 2.28%) 3.04s 3.12s
Total Time 10.48s (± 0.28%) 10.32s (± 0.43%) -0.16s (- 1.50%) 10.25s 10.43s
TFS - node (v12.1.0, x64)
Memory used 293,104k (± 0.02%) 293,153k (± 0.02%) +48k (+ 0.02%) 293,033k 293,350k
Parse Time 1.23s (± 0.99%) 1.22s (± 0.68%) -0.01s (- 0.82%) 1.19s 1.23s
Bind Time 0.68s (± 0.73%) 0.68s (± 0.65%) -0.00s (- 0.44%) 0.67s 0.69s
Check Time 4.61s (± 0.71%) 4.57s (± 0.40%) -0.04s (- 0.89%) 4.53s 4.62s
Emit Time 3.18s (± 0.71%) 3.11s (± 0.62%) -0.07s (- 2.08%) 3.06s 3.15s
Total Time 9.70s (± 0.58%) 9.58s (± 0.29%) -0.12s (- 1.20%) 9.53s 9.66s
material-ui - node (v12.1.0, x64)
Memory used 479,454k (± 0.02%) 479,495k (± 0.04%) +41k (+ 0.01%) 479,015k 479,783k
Parse Time 2.00s (± 0.41%) 2.00s (± 0.62%) -0.00s (- 0.10%) 1.98s 2.03s
Bind Time 0.64s (± 0.76%) 0.64s (± 0.52%) -0.00s (- 0.62%) 0.63s 0.65s
Check Time 12.89s (± 0.68%) 12.73s (± 0.85%) -0.16s (- 1.23%) 12.57s 13.10s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.54s (± 0.60%) 15.37s (± 0.68%) -0.17s (- 1.09%) 15.20s 15.71s
Angular - node (v14.15.1, x64)
Memory used 324,919k (± 0.01%) 324,919k (± 0.01%) +0k (+ 0.00%) 324,853k 324,999k
Parse Time 1.92s (± 0.91%) 1.90s (± 0.55%) -0.02s (- 0.99%) 1.88s 1.93s
Bind Time 0.85s (± 0.52%) 0.84s (± 0.59%) -0.01s (- 0.82%) 0.84s 0.86s
Check Time 4.91s (± 0.43%) 4.91s (± 0.36%) -0.00s (- 0.04%) 4.89s 4.98s
Emit Time 6.30s (± 0.42%) 6.26s (± 0.33%) -0.04s (- 0.67%) 6.22s 6.32s
Total Time 13.99s (± 0.28%) 13.92s (± 0.16%) -0.07s (- 0.50%) 13.87s 13.96s
Compiler-Unions - node (v14.15.1, x64)
Memory used 191,057k (± 0.02%) 191,070k (± 0.02%) +13k (+ 0.01%) 191,022k 191,181k
Parse Time 0.80s (± 0.77%) 0.79s (± 0.63%) -0.00s (- 0.50%) 0.78s 0.80s
Bind Time 0.55s (± 0.66%) 0.55s (± 0.54%) -0.00s (- 0.36%) 0.55s 0.56s
Check Time 6.99s (± 0.54%) 6.95s (± 0.44%) -0.04s (- 0.56%) 6.90s 7.03s
Emit Time 2.54s (± 0.65%) 2.53s (± 0.69%) -0.01s (- 0.39%) 2.49s 2.56s
Total Time 10.89s (± 0.35%) 10.83s (± 0.36%) -0.05s (- 0.49%) 10.76s 10.92s
Monaco - node (v14.15.1, x64)
Memory used 338,065k (± 0.01%) 338,066k (± 0.01%) +0k (+ 0.00%) 338,029k 338,103k
Parse Time 1.56s (± 0.62%) 1.56s (± 0.63%) +0.00s (+ 0.19%) 1.54s 1.59s
Bind Time 0.75s (± 0.64%) 0.74s (± 0.49%) -0.00s (- 0.40%) 0.74s 0.75s
Check Time 4.94s (± 0.55%) 4.95s (± 0.36%) +0.01s (+ 0.20%) 4.91s 4.99s
Emit Time 3.17s (± 0.67%) 3.15s (± 0.50%) -0.02s (- 0.60%) 3.12s 3.18s
Total Time 10.41s (± 0.39%) 10.40s (± 0.29%) -0.01s (- 0.10%) 10.34s 10.45s
TFS - node (v14.15.1, x64)
Memory used 292,237k (± 0.01%) 292,247k (± 0.01%) +11k (+ 0.00%) 292,206k 292,308k
Parse Time 1.25s (± 1.06%) 1.24s (± 0.88%) -0.01s (- 0.88%) 1.22s 1.27s
Bind Time 0.72s (± 1.11%) 0.71s (± 0.91%) -0.01s (- 0.84%) 0.70s 0.72s
Check Time 4.59s (± 0.37%) 4.56s (± 0.44%) -0.03s (- 0.70%) 4.53s 4.61s
Emit Time 3.26s (± 0.43%) 3.24s (± 0.48%) -0.03s (- 0.80%) 3.20s 3.27s
Total Time 9.83s (± 0.36%) 9.75s (± 0.34%) -0.07s (- 0.73%) 9.70s 9.83s
material-ui - node (v14.15.1, x64)
Memory used 477,872k (± 0.01%) 477,851k (± 0.05%) -22k (- 0.00%) 476,829k 478,026k
Parse Time 2.06s (± 0.74%) 2.05s (± 0.70%) -0.01s (- 0.49%) 2.02s 2.08s
Bind Time 0.69s (± 0.99%) 0.69s (± 0.71%) -0.00s (- 0.14%) 0.68s 0.70s
Check Time 12.86s (± 0.48%) 12.93s (± 0.86%) +0.07s (+ 0.55%) 12.80s 13.26s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.62s (± 0.41%) 15.68s (± 0.76%) +0.05s (+ 0.35%) 15.51s 16.02s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-198-generic
Architecturex64
Available Memory16 GB
Available Memory5 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
Benchmark Name Iterations
Current 43086 10
Baseline master 10

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..43086

Metric master 43086 Delta Best Worst
Angular - node (v14.15.1, x64)
Memory used 324,919k (± 0.01%) 324,883k (± 0.01%) -36k (- 0.01%) 324,859k 324,934k
Parse Time 1.92s (± 0.91%) 1.89s (± 0.34%) -0.03s (- 1.41%) 1.88s 1.91s
Bind Time 0.85s (± 0.52%) 0.85s (± 0.55%) -0.00s (- 0.23%) 0.84s 0.86s
Check Time 4.91s (± 0.43%) 4.90s (± 0.37%) -0.01s (- 0.24%) 4.87s 4.96s
Emit Time 6.30s (± 0.42%) 6.24s (± 0.37%) -0.06s (- 0.97%) 6.19s 6.31s
Total Time 13.99s (± 0.28%) 13.88s (± 0.18%) -0.11s (- 0.76%) 13.83s 13.95s
Compiler-Unions - node (v14.15.1, x64)
Memory used 191,057k (± 0.02%) 191,048k (± 0.02%) -9k (- 0.00%) 190,953k 191,126k
Parse Time 0.80s (± 0.77%) 0.79s (± 0.60%) -0.01s (- 0.75%) 0.79s 0.81s
Bind Time 0.55s (± 0.66%) 0.55s (± 0.40%) -0.00s (- 0.54%) 0.55s 0.56s
Check Time 6.99s (± 0.54%) 6.97s (± 0.45%) -0.02s (- 0.30%) 6.90s 7.02s
Emit Time 2.54s (± 0.65%) 2.55s (± 1.54%) +0.01s (+ 0.20%) 2.49s 2.69s
Total Time 10.89s (± 0.35%) 10.86s (± 0.29%) -0.03s (- 0.23%) 10.79s 10.93s
Monaco - node (v14.15.1, x64)
Memory used 338,065k (± 0.01%) 338,052k (± 0.01%) -14k (- 0.00%) 337,994k 338,086k
Parse Time 1.56s (± 0.62%) 1.55s (± 0.54%) -0.01s (- 0.51%) 1.53s 1.57s
Bind Time 0.75s (± 0.64%) 0.75s (± 0.67%) -0.00s (- 0.27%) 0.74s 0.76s
Check Time 4.94s (± 0.55%) 4.94s (± 0.48%) -0.00s (- 0.04%) 4.90s 5.00s
Emit Time 3.17s (± 0.67%) 3.15s (± 0.90%) -0.02s (- 0.63%) 3.07s 3.19s
Total Time 10.41s (± 0.39%) 10.38s (± 0.38%) -0.03s (- 0.30%) 10.30s 10.47s
TFS - node (v14.15.1, x64)
Memory used 292,237k (± 0.01%) 292,264k (± 0.01%) +28k (+ 0.01%) 292,217k 292,299k
Parse Time 1.25s (± 1.06%) 1.25s (± 1.24%) -0.00s (- 0.08%) 1.22s 1.29s
Bind Time 0.72s (± 1.11%) 0.71s (± 0.78%) -0.01s (- 0.84%) 0.70s 0.73s
Check Time 4.59s (± 0.37%) 4.58s (± 0.46%) -0.02s (- 0.35%) 4.52s 4.62s
Emit Time 3.26s (± 0.43%) 3.25s (± 0.40%) -0.02s (- 0.52%) 3.21s 3.28s
Total Time 9.83s (± 0.36%) 9.78s (± 0.32%) -0.04s (- 0.45%) 9.73s 9.85s
material-ui - node (v14.15.1, x64)
Memory used 477,872k (± 0.01%) 477,826k (± 0.05%) -46k (- 0.01%) 476,793k 477,984k
Parse Time 2.06s (± 0.74%) 2.05s (± 0.57%) -0.00s (- 0.15%) 2.04s 2.09s
Bind Time 0.69s (± 0.99%) 0.70s (± 0.80%) +0.00s (+ 0.43%) 0.69s 0.71s
Check Time 12.86s (± 0.48%) 12.89s (± 0.64%) +0.03s (+ 0.20%) 12.79s 13.17s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.62s (± 0.41%) 15.64s (± 0.53%) +0.02s (+ 0.14%) 15.53s 15.93s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-198-generic
Architecturex64
Available Memory16 GB
Available Memory5 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v14.15.1, x64)
Benchmark Name Iterations
Current 43086 10
Baseline master 10

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Object spread incorrectly introduces undefined value type in TS 4.2
5 participants