Skip to content
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

Narrow types by typeof operands with extra parenthesis #60928

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Jan 7, 2025

fixes #42203 , cc @RyanCavanaugh

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jan 7, 2025
return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) ||
isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right) ||
(isBooleanLiteral(expr.right) && isNarrowingExpression(expr.left) || isBooleanLiteral(expr.left) && isNarrowingExpression(expr.right));
const left = skipParentheses(expr.left);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rechecked all of the branches in the containing function. They should all now look through parenthesis - this was the only branch missing this

@gabritto
Copy link
Member

gabritto commented Jan 7, 2025

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 7, 2025

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

@gabritto Here are the results of running the user tests with tsc comparing main and refs/pull/60928/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @gabritto, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 34 34 ~ ~ ~ p=1.000 n=6
Symbols 62,363 62,363 ~ ~ ~ p=1.000 n=6
Types 50,395 50,395 ~ ~ ~ p=1.000 n=6
Memory used 194,830k (± 1.03%) 193,025k (± 0.01%) ~ 193,015k 193,041k p=1.000 n=6
Parse Time 1.31s (± 0.93%) 1.31s (± 0.93%) ~ 1.29s 1.32s p=1.000 n=6
Bind Time 0.72s (± 0.57%) 0.73s +0.01s (+ 1.62%) ~ ~ p=0.002 n=6
Check Time 9.79s (± 0.19%) 9.79s (± 0.19%) ~ 9.77s 9.82s p=0.684 n=6
Emit Time 2.74s (± 0.43%) 2.72s (± 0.23%) -0.02s (- 0.67%) 2.71s 2.73s p=0.019 n=6
Total Time 14.56s (± 0.13%) 14.54s (± 0.18%) ~ 14.51s 14.59s p=0.414 n=6
angular-1 - node (v18.15.0, x64)
Errors 37 37 ~ ~ ~ p=1.000 n=6
Symbols 947,936 947,936 ~ ~ ~ p=1.000 n=6
Types 410,955 410,955 ~ ~ ~ p=1.000 n=6
Memory used 1,225,814k (± 0.00%) 1,225,830k (± 0.00%) ~ 1,225,802k 1,225,919k p=0.936 n=6
Parse Time 6.63s (± 0.59%) 6.65s (± 0.71%) ~ 6.58s 6.69s p=0.627 n=6
Bind Time 1.89s (± 0.44%) 1.89s (± 0.29%) +0.01s (+ 0.53%) 1.89s 1.90s p=0.038 n=6
Check Time 31.99s (± 0.15%) 32.00s (± 0.31%) ~ 31.85s 32.12s p=0.748 n=6
Emit Time 15.19s (± 0.57%) 15.18s (± 0.30%) ~ 15.09s 15.22s p=0.199 n=6
Total Time 55.70s (± 0.26%) 55.72s (± 0.17%) ~ 55.62s 55.87s p=0.872 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,446,493 2,446,493 ~ ~ ~ p=1.000 n=6
Types 897,066 897,066 ~ ~ ~ p=1.000 n=6
Memory used 2,311,166k (± 0.00%) 2,311,143k (± 0.00%) ~ 2,311,102k 2,311,190k p=0.521 n=6
Parse Time 8.96s (± 0.46%) 8.95s (± 0.23%) ~ 8.91s 8.97s p=0.685 n=6
Bind Time 2.13s (± 0.89%) 2.12s (± 0.64%) ~ 2.10s 2.14s p=0.510 n=6
Check Time 73.11s (± 0.36%) 72.95s (± 0.34%) ~ 72.65s 73.27s p=0.575 n=6
Emit Time 0.28s (± 1.82%) 0.28s (± 2.70%) ~ 0.27s 0.29s p=0.241 n=6
Total Time 84.49s (± 0.32%) 84.31s (± 0.28%) ~ 84.00s 84.55s p=0.470 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,226,880 1,226,882 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Types 266,745 266,745 ~ ~ ~ p=1.000 n=6
Memory used 2,417,994k (± 6.14%) 2,418,472k (± 6.13%) +478k (+ 0.02%) 2,357,600k 2,721,208k p=0.045 n=6
Parse Time 5.24s (± 0.98%) 5.21s (± 1.47%) ~ 5.10s 5.32s p=0.689 n=6
Bind Time 1.77s (± 0.66%) 1.79s (± 0.91%) ~ 1.77s 1.81s p=0.085 n=6
Check Time 35.17s (± 0.50%) 35.14s (± 0.88%) ~ 34.56s 35.43s p=0.873 n=6
Emit Time 2.99s (± 2.64%) 2.97s (± 1.37%) ~ 2.90s 3.02s p=1.000 n=6
Total Time 45.17s (± 0.47%) 45.12s (± 0.71%) ~ 44.54s 45.42s p=0.936 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,226,880 1,226,882 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Types 266,745 266,745 ~ ~ ~ p=1.000 n=6
Memory used 2,790,457k (±14.24%) 3,032,969k (± 9.74%) ~ 2,429,131k 3,154,236k p=0.173 n=6
Parse Time 8.55s (± 1.96%) 8.59s (± 0.97%) ~ 8.46s 8.68s p=0.810 n=6
Bind Time 2.69s (± 2.12%) 2.67s (± 1.46%) ~ 2.60s 2.71s p=0.227 n=6
Check Time 53.07s (± 0.21%) 53.04s (± 0.38%) ~ 52.69s 53.25s p=0.810 n=6
Emit Time 4.41s (± 2.09%) 4.36s (± 1.36%) ~ 4.28s 4.45s p=0.378 n=6
Total Time 68.73s (± 0.41%) 68.67s (± 0.40%) ~ 68.17s 68.94s p=0.810 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,439 262,441 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Types 106,628 106,628 ~ ~ ~ p=1.000 n=6
Memory used 440,216k (± 0.02%) 440,199k (± 0.02%) ~ 440,096k 440,279k p=0.936 n=6
Parse Time 3.53s (± 0.93%) 3.53s (± 1.20%) ~ 3.47s 3.57s p=0.687 n=6
Bind Time 1.32s (± 0.93%) 1.30s (± 0.64%) ~ 1.29s 1.31s p=0.209 n=6
Check Time 19.01s (± 0.30%) 18.92s (± 0.45%) -0.09s (- 0.50%) 18.77s 19.00s p=0.045 n=6
Emit Time 1.54s (± 1.39%) 1.54s (± 0.89%) ~ 1.52s 1.56s p=1.000 n=6
Total Time 25.39s (± 0.25%) 25.30s (± 0.38%) ~ 25.14s 25.42s p=0.092 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 70 70 ~ ~ ~ p=1.000 n=6
Symbols 226,062 226,062 ~ ~ ~ p=1.000 n=6
Types 94,488 94,488 ~ ~ ~ p=1.000 n=6
Memory used 371,640k (± 0.04%) 371,751k (± 0.06%) ~ 371,588k 372,171k p=0.128 n=6
Parse Time 3.62s (± 1.28%) 3.61s (± 0.70%) ~ 3.57s 3.64s p=0.225 n=6
Bind Time 1.95s (± 0.72%) 1.96s (± 0.53%) ~ 1.95s 1.98s p=0.086 n=6
Check Time 20.45s (± 0.20%) 20.47s (± 0.10%) ~ 20.45s 20.49s p=0.565 n=6
Emit Time 0.00s (±244.70%) 0.00s ~ ~ ~ p=0.405 n=6
Total Time 26.02s (± 0.19%) 26.05s (± 0.10%) ~ 26.03s 26.09s p=0.226 n=6
vscode - node (v18.15.0, x64)
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 3,233,660 3,233,660 ~ ~ ~ p=1.000 n=6
Types 1,113,001 1,113,001 ~ ~ ~ p=1.000 n=6
Memory used 3,296,711k (± 0.01%) 3,297,113k (± 0.01%) ~ 3,296,572k 3,297,420k p=0.128 n=6
Parse Time 14.08s (± 0.13%) 14.13s (± 0.55%) ~ 14.03s 14.26s p=0.198 n=6
Bind Time 4.54s (± 2.42%) 4.62s (± 3.30%) ~ 4.46s 4.77s p=0.809 n=6
Check Time 87.41s (± 1.38%) 88.24s (± 3.27%) ~ 86.07s 93.67s p=0.689 n=6
Emit Time 28.58s (± 2.36%) 27.76s (± 2.55%) ~ 27.12s 28.71s p=0.054 n=6
Total Time 134.61s (± 0.44%) 134.74s (± 2.04%) ~ 131.98s 139.82s p=0.471 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 291,562 291,562 ~ ~ ~ p=1.000 n=6
Types 118,971 118,971 ~ ~ ~ p=1.000 n=6
Memory used 445,271k (± 0.01%) 445,370k (± 0.03%) ~ 445,223k 445,529k p=0.128 n=6
Parse Time 4.09s (± 0.87%) 4.08s (± 1.68%) ~ 3.97s 4.17s p=1.000 n=6
Bind Time 1.78s (± 1.35%) 1.78s (± 0.46%) ~ 1.77s 1.79s p=0.682 n=6
Check Time 18.75s (± 0.35%) 18.80s (± 0.26%) ~ 18.75s 18.87s p=0.332 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.61s (± 0.22%) 24.65s (± 0.45%) ~ 24.50s 24.79s p=0.688 n=6
xstate-main - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 555,017 555,017 ~ ~ ~ p=1.000 n=6
Types 186,115 186,115 ~ ~ ~ p=1.000 n=6
Memory used 494,037k (± 0.01%) 493,959k (± 0.03%) ~ 493,649k 494,101k p=0.471 n=6
Parse Time 3.42s (± 0.71%) 3.41s (± 1.00%) ~ 3.37s 3.45s p=0.567 n=6
Bind Time 1.18s (± 1.31%) 1.17s (± 1.21%) ~ 1.15s 1.19s p=0.324 n=6
Check Time 19.56s (± 0.42%) 19.80s (± 2.89%) ~ 19.49s 20.96s p=0.748 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.16s (± 0.34%) 24.38s (± 2.40%) ~ 24.03s 25.56s p=0.936 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@gabritto Here are the results of running the top 400 repos with tsc comparing main and refs/pull/60928/merge:

Everything looks good!

@gabritto gabritto merged commit a5196c7 into microsoft:main Jan 7, 2025
32 checks passed
@Andarist Andarist deleted the narrow-typeof-extra-parens branch January 7, 2025 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

typeof type narrowing acts differently with equivalent parentheses grouping
3 participants