Skip to content

Allow partial matches in discrimination logic #58970

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 4 commits into from
Closed

Conversation

ahejlsberg
Copy link
Member

Fixes #58603.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jun 22, 2024
@ahejlsberg
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 22, 2024

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

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

There were interesting changes:

Branch only errors:

Package: react-table
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/react-table/react-table-tests.tsx
  692:30  error  TypeScript@local compile error: 
Binding element 'value' implicitly has an 'any' type  @definitelytyped/expect
  693:25  error  TypeScript@local expected type to be:
  string
got:
  any                              @definitelytyped/expect
  726:30  error  TypeScript@local compile error: 
Binding element 'value' implicitly has an 'any' type  @definitelytyped/expect
  727:25  error  TypeScript@local expected type to be:
  number
got:
  any                              @definitelytyped/expect
  770:22  error  TypeScript@local compile error: 
Binding element 'value' implicitly has an 'any' type  @definitelytyped/expect
  771:17  error  TypeScript@local expected type to be:
  string
got:
  any                              @definitelytyped/expect
  784:22  error  TypeScript@local compile error: 
Binding element 'value' implicitly has an 'any' type  @definitelytyped/expect
  785:17  error  TypeScript@local expected type to be:
  number
got:
  any                              @definitelytyped/expect
  801:22  error  TypeScript@local compile error: 
Binding element 'value' implicitly has an 'any' type  @definitelytyped/expect
  802:17  error  TypeScript@local expected type to be:
  Data[] | undefined
got:
  any                  @definitelytyped/expect
  803:17  error  TypeScript@local expected type to be:
  number
got:
  any                              @definitelytyped/expect
  857:30  error  TypeScript@local compile error: 
Binding element 'value' implicitly has an 'any' type  @definitelytyped/expect
  858:25  error  TypeScript@local expected type to be:
  string
got:
  any                              @definitelytyped/expect

✖ 13 problems (13 errors, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: wechat-miniprogram
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/wechat-miniprogram/test/behavior.test.ts
  19:22  error  TypeScript@local compile error: 
Parameter 'newVal' implicitly has an 'any' type  @definitelytyped/expect
  19:30  error  TypeScript@local compile error: 
Parameter 'oldVal' implicitly has an 'any' type  @definitelytyped/expect
  21:17  error  TypeScript@local expected type to be:
  number
got:
  any                         @definitelytyped/expect
  23:17  error  TypeScript@local expected type to be:
  string
got:
  any                         @definitelytyped/expect

/mnt/vss/_work/1/DefinitelyTyped/types/wechat-miniprogram/test/component.test.ts
  31:22  error  TypeScript@local compile error: 
Parameter 'newVal' implicitly has an 'any' type  @definitelytyped/expect
  31:30  error  TypeScript@local compile error: 
Parameter 'oldVal' implicitly has an 'any' type  @definitelytyped/expect
  33:17  error  TypeScript@local expected type to be:
  number
got:
  any                         @definitelytyped/expect
  35:17  error  TypeScript@local expected type to be:
  number
got:
  any                         @definitelytyped/expect

✖ 8 problems (8 errors, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: angular-material
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/angular-material/angular-material-tests.ts
  206:19  error  TypeScript@local compile error: 
Parameter 'scope' implicitly has an 'any' type          @definitelytyped/expect
  206:26  error  TypeScript@local compile error: 
Parameter 'element' implicitly has an 'any' type        @definitelytyped/expect
  207:20  error  TypeScript@local compile error: 
Parameter 'scope' implicitly has an 'any' type          @definitelytyped/expect
  207:27  error  TypeScript@local compile error: 
Parameter 'element' implicitly has an 'any' type        @definitelytyped/expect
  208:20  error  TypeScript@local compile error: 
Parameter 'element' implicitly has an 'any' type        @definitelytyped/expect
  208:29  error  TypeScript@local compile error: 
Parameter 'removePromise' implicitly has an 'any' type  @definitelytyped/expect
  212:21  error  TypeScript@local compile error: 
Parameter 'scope' implicitly has an 'any' type          @definitelytyped/expect
  212:28  error  TypeScript@local compile error: 
Parameter 'element' implicitly has an 'any' type        @definitelytyped/expect
  213:22  error  TypeScript@local compile error: 
Parameter 'scope' implicitly has an 'any' type          @definitelytyped/expect
  213:29  error  TypeScript@local compile error: 
Parameter 'element' implicitly has an 'any' type        @definitelytyped/expect
  214:22  error  TypeScript@local compile error: 
Parameter 'element' implicitly has an 'any' type        @definitelytyped/expect
  214:31  error  TypeScript@local compile error: 
Parameter 'removePromise' implicitly has an 'any' type  @definitelytyped/expect

✖ 12 problems (12 errors, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

@ahejlsberg
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 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,292 +50 (+ 0.10%) ~ ~ p=0.001 n=6
Memory used 193,346k (± 0.96%) 192,141k (± 0.01%) ~ 192,128k 192,162k p=0.521 n=6
Parse Time 1.30s (± 1.35%) 1.30s (± 0.93%) ~ 1.28s 1.31s p=0.199 n=6
Bind Time 0.71s 0.71s ~ ~ ~ p=1.000 n=6
Check Time 9.44s (± 0.25%) 9.43s (± 0.53%) ~ 9.38s 9.51s p=0.466 n=6
Emit Time 2.76s (± 0.67%) 2.74s (± 0.30%) -0.03s (- 0.97%) 2.73s 2.75s p=0.014 n=6
Total Time 14.21s (± 0.27%) 14.17s (± 0.28%) ~ 14.12s 14.23s p=0.106 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 944,114 944,073 -41 (- 0.00%) ~ ~ p=0.001 n=6
Types 407,051 407,269 +218 (+ 0.05%) ~ ~ p=0.001 n=6
Memory used 1,218,360k (± 0.00%) 1,218,406k (± 0.00%) ~ 1,218,344k 1,218,441k p=0.093 n=6
Parse Time 6.66s (± 0.68%) 6.63s (± 0.39%) ~ 6.59s 6.66s p=0.334 n=6
Bind Time 1.86s (± 0.65%) 1.87s (± 1.45%) ~ 1.85s 1.92s p=0.933 n=6
Check Time 30.67s (± 0.21%) 30.67s (± 0.45%) ~ 30.46s 30.86s p=0.810 n=6
Emit Time 13.54s (± 0.63%) 13.56s (± 0.38%) ~ 13.48s 13.62s p=0.422 n=6
Total Time 52.73s (± 0.17%) 52.73s (± 0.28%) ~ 52.52s 52.91s p=1.000 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,134,511 2,134,511 ~ ~ ~ p=1.000 n=6
Types 927,068 927,109 +41 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,116,007k (± 0.00%) 2,116,054k (± 0.00%) ~ 2,115,962k 2,116,169k p=0.378 n=6
Parse Time 6.61s (± 0.43%) 6.59s (± 0.46%) ~ 6.57s 6.65s p=0.373 n=6
Bind Time 2.33s (± 1.03%) 2.35s (± 1.46%) ~ 2.31s 2.40s p=0.244 n=6
Check Time 70.44s (± 1.17%) 70.07s (± 1.20%) ~ 69.01s 70.83s p=0.810 n=6
Emit Time 0.13s (± 3.87%) 0.13s (± 3.10%) ~ 0.13s 0.14s p=0.595 n=6
Total Time 79.51s (± 1.00%) 79.14s (± 1.00%) ~ 78.13s 79.87s p=0.689 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,230,804 1,230,804 ~ ~ ~ p=1.000 n=6
Types 261,202 261,369 +167 (+ 0.06%) ~ ~ p=0.001 n=6
Memory used 2,345,939k (± 0.03%) 2,345,670k (± 0.05%) ~ 2,344,332k 2,346,893k p=0.810 n=6
Parse Time 5.02s (± 1.49%) 4.98s (± 0.91%) ~ 4.93s 5.04s p=0.575 n=6
Bind Time 1.90s (± 0.70%) 1.90s (± 0.55%) ~ 1.88s 1.91s p=0.737 n=6
Check Time 33.81s (± 0.23%) 33.80s (± 0.27%) ~ 33.69s 33.96s p=0.810 n=6
Emit Time 2.70s (± 1.27%) 2.74s (± 4.26%) ~ 2.56s 2.88s p=0.336 n=6
Total Time 43.46s (± 0.33%) 43.46s (± 0.33%) ~ 43.29s 43.63s 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,230,804 1,230,804 ~ ~ ~ p=1.000 n=6
Types 261,202 261,369 +167 (+ 0.06%) ~ ~ p=0.001 n=6
Memory used 2,422,357k (± 0.03%) 2,422,802k (± 0.04%) ~ 2,421,111k 2,423,497k p=0.173 n=6
Parse Time 6.15s (± 0.73%) 6.18s (± 0.81%) ~ 6.14s 6.28s p=0.810 n=6
Bind Time 2.02s (± 0.97%) 2.03s (± 0.81%) ~ 2.01s 2.05s p=1.000 n=6
Check Time 40.16s (± 0.45%) 40.12s (± 0.21%) ~ 39.99s 40.20s p=0.378 n=6
Emit Time 3.19s (± 1.88%) 3.12s (± 1.47%) -0.08s (- 2.40%) 3.06s 3.17s p=0.030 n=6
Total Time 51.56s (± 0.27%) 51.46s (± 0.24%) ~ 51.29s 51.65s p=0.261 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,574 258,574 ~ ~ ~ p=1.000 n=6
Types 104,825 104,968 +143 (+ 0.14%) ~ ~ p=0.001 n=6
Memory used 428,179k (± 0.01%) 428,256k (± 0.01%) +78k (+ 0.02%) 428,210k 428,281k p=0.010 n=6
Parse Time 3.33s (± 0.98%) 3.32s (± 0.44%) ~ 3.30s 3.34s p=0.744 n=6
Bind Time 1.32s (± 2.11%) 1.31s (± 0.75%) ~ 1.29s 1.32s p=0.326 n=6
Check Time 17.81s (± 0.23%) 17.83s (± 0.19%) ~ 17.78s 17.86s p=0.256 n=6
Emit Time 1.36s (± 0.86%) 1.39s (± 1.24%) +0.03s (+ 2.21%) 1.36s 1.41s p=0.019 n=6
Total Time 23.81s (± 0.32%) 23.84s (± 0.14%) ~ 23.79s 23.89s p=0.574 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,565 224,570 +5 (+ 0.00%) ~ ~ p=0.001 n=6
Types 93,734 93,775 +41 (+ 0.04%) ~ ~ p=0.001 n=6
Memory used 369,473k (± 0.04%) 369,496k (± 0.02%) ~ 369,388k 369,591k p=0.298 n=6
Parse Time 2.75s (± 1.03%) 2.75s (± 0.91%) ~ 2.72s 2.79s p=0.744 n=6
Bind Time 1.58s (± 0.65%) 1.58s (± 0.74%) ~ 1.57s 1.60s p=0.788 n=6
Check Time 15.42s (± 0.38%) 15.42s (± 0.10%) ~ 15.39s 15.43s p=0.870 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.75s (± 0.41%) 19.75s (± 0.18%) ~ 19.69s 19.80s p=0.747 n=6
vscode - node (v18.15.0, x64)
Errors 139 139 ~ ~ ~ p=1.000 n=6
Symbols 2,854,562 2,854,562 ~ ~ ~ p=1.000 n=6
Types 976,042 976,051 +9 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 3,045,675k (± 0.00%) 3,045,660k (± 0.00%) ~ 3,045,594k 3,045,729k p=0.689 n=6
Parse Time 13.55s (± 0.51%) 13.51s (± 0.26%) ~ 13.45s 13.55s p=0.260 n=6
Bind Time 4.25s (± 0.43%) 4.25s (± 0.32%) ~ 4.23s 4.26s p=0.681 n=6
Check Time 74.76s (± 2.09%) 74.58s (± 2.24%) ~ 73.69s 77.97s p=0.471 n=6
Emit Time 23.45s (± 6.41%) 23.64s (± 6.90%) ~ 20.35s 24.79s p=0.298 n=6
Total Time 116.00s (± 0.25%) 115.97s (± 0.31%) ~ 115.49s 116.28s p=0.748 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 267,117 267,117 ~ ~ ~ p=1.000 n=6
Types 108,775 108,774 -1 (- 0.00%) ~ ~ p=0.001 n=6
Memory used 411,597k (± 0.02%) 411,566k (± 0.02%) ~ 411,481k 411,723k p=0.689 n=6
Parse Time 4.72s (± 0.65%) 4.73s (± 0.77%) ~ 4.68s 4.78s p=0.872 n=6
Bind Time 2.08s (± 0.66%) 2.08s (± 0.47%) ~ 2.07s 2.09s p=0.801 n=6
Check Time 20.81s (± 0.55%) 20.72s (± 0.31%) ~ 20.63s 20.82s p=0.149 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.62s (± 0.52%) 27.53s (± 0.26%) ~ 27.43s 27.63s p=0.296 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 29 🔻+29 (+ ∞%) ~ ~ p=0.001 n=6
Symbols 523,955 524,489 +534 (+ 0.10%) ~ ~ p=0.001 n=6
Types 178,096 178,631 +535 (+ 0.30%) ~ ~ p=0.001 n=6
Memory used 461,830k (± 0.06%) 462,596k (± 0.06%) +766k (+ 0.17%) 462,130k 462,893k p=0.005 n=6
Parse Time 3.17s (± 0.79%) 3.15s (± 0.69%) ~ 3.12s 3.17s p=0.145 n=6
Bind Time 1.18s (± 0.35%) 1.17s (± 0.70%) ~ 1.16s 1.18s p=0.248 n=6
Check Time 17.88s (± 0.47%) 17.89s (± 0.33%) ~ 17.84s 18.00s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.23s (± 0.31%) 22.21s (± 0.24%) ~ 22.16s 22.31s p=0.295 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

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

Everything looks good!

@ahejlsberg
Copy link
Member Author

Hmm, using isEmptyIntersection won't work since apparently there are situations where we actually use object types as discriminants. For example, a union of object types and null or undefined is viewed as a discriminant property type, and intersections don't work to determine overlapping domains between object types.

@ahejlsberg
Copy link
Member Author

Closing this PR.

@ahejlsberg ahejlsberg closed this Jun 22, 2024
@sandersn sandersn removed this from PR Backlog Apr 22, 2025
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.

Type union not matched starting from TS 5.1
2 participants