Skip to content

Exclude special index signature rule from strict subtype relation #53388

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 4 commits into from
Mar 23, 2023

Conversation

ahejlsberg
Copy link
Member

Fixes #53379.

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

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

Heya @ahejlsberg, I've started to run the diff-based top-repos suite on this PR at ae63c73. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at ae63c73. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the user test suite comparing main and refs/pull/53388/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @ahejlsberg, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@ahejlsberg ahejlsberg added this to the TypeScript 5.0.3 milestone Mar 20, 2023
@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..53388

Metric main 53388 Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 361,070k (± 0.01%) 361,067k (± 0.01%) ~ 361,029k 361,111k p=1.000 n=6
Parse Time 3.54s (± 0.70%) 3.51s (± 0.49%) -0.03s (- 0.94%) 3.49s 3.53s p=0.018 n=6
Bind Time 1.18s (± 0.44%) 1.18s (± 0.44%) ~ 1.18s 1.19s p=1.000 n=6
Check Time 9.48s (± 0.30%) 9.46s (± 0.33%) ~ 9.42s 9.51s p=0.252 n=6
Emit Time 7.89s (± 0.49%) 7.94s (± 0.72%) ~ 7.88s 8.04s p=0.171 n=6
Total Time 22.10s (± 0.17%) 22.09s (± 0.29%) ~ 22.00s 22.19s p=0.627 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 192,554k (± 0.02%) 192,500k (± 0.02%) ~ 192,422k 192,532k p=0.078 n=6
Parse Time 1.59s (± 0.40%) 1.60s (± 0.85%) ~ 1.58s 1.62s p=0.388 n=6
Bind Time 0.82s (± 0.50%) 0.82s (± 0.50%) ~ 0.82s 0.83s p=1.000 n=6
Check Time 10.12s (± 0.35%) 10.19s (± 0.58%) +0.07s (+ 0.64%) 10.11s 10.29s p=0.029 n=6
Emit Time 2.98s (± 1.01%) 2.99s (± 0.62%) ~ 2.97s 3.02s p=0.686 n=6
Total Time 15.52s (± 0.35%) 15.60s (± 0.35%) +0.08s (+ 0.52%) 15.52s 15.67s p=0.045 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,564k (± 0.01%) 345,561k (± 0.00%) ~ 345,534k 345,576k p=0.688 n=6
Parse Time 2.73s (± 0.54%) 2.72s (± 0.30%) ~ 2.71s 2.73s p=0.677 n=6
Bind Time 1.09s (± 0.69%) 1.09s (± 1.07%) ~ 1.08s 1.11s p=0.796 n=6
Check Time 7.70s (± 0.38%) 7.71s (± 0.34%) ~ 7.68s 7.74s p=0.520 n=6
Emit Time 4.45s (± 0.78%) 4.46s (± 0.80%) ~ 4.43s 4.53s p=0.686 n=6
Total Time 15.97s (± 0.48%) 15.98s (± 0.34%) ~ 15.93s 16.07s p=0.687 n=6
TFS - node (v16.17.1, x64)
Memory used 299,781k (± 0.01%) 299,809k (± 0.01%) +28k (+ 0.01%) 299,769k 299,834k p=0.045 n=6
Parse Time 2.17s (± 0.47%) 2.18s (± 0.79%) ~ 2.16s 2.20s p=0.452 n=6
Bind Time 1.25s (± 0.84%) 1.24s (± 1.35%) ~ 1.22s 1.26s p=0.742 n=6
Check Time 7.16s (± 0.42%) 7.19s (± 0.73%) ~ 7.14s 7.26s p=0.629 n=6
Emit Time 4.35s (± 1.03%) 4.36s (± 0.91%) ~ 4.31s 4.42s p=0.687 n=6
Total Time 14.93s (± 0.30%) 14.97s (± 0.58%) ~ 14.87s 15.11s p=0.571 n=6
material-ui - node (v16.17.1, x64)
Memory used 476,415k (± 0.01%) 476,455k (± 0.01%) ~ 476,380k 476,530k p=0.173 n=6
Parse Time 3.22s (± 0.42%) 3.23s (± 0.36%) ~ 3.22s 3.25s p=0.113 n=6
Bind Time 0.96s (± 0.54%) 0.95s (± 0.88%) ~ 0.95s 0.97s p=0.533 n=6
Check Time 17.97s (± 0.37%) 17.92s (± 0.36%) ~ 17.81s 17.99s p=0.261 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.14s (± 0.36%) 22.10s (± 0.34%) ~ 21.98s 22.19s p=0.336 n=6
xstate - node (v16.17.1, x64)
Memory used 550,611k (± 0.02%) 550,568k (± 0.02%) ~ 550,501k 550,756k p=0.336 n=6
Parse Time 3.95s (± 0.26%) 3.96s (± 0.35%) ~ 3.95s 3.98s p=0.086 n=6
Bind Time 1.79s (± 0.30%) 1.81s (± 0.45%) +0.01s (+ 0.65%) 1.80s 1.82s p=0.025 n=6
Check Time 3.01s (± 0.61%) 3.01s (± 0.50%) ~ 2.99s 3.03s p=1.000 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 8.85s (± 0.25%) 8.88s (± 0.21%) ~ 8.86s 8.91s p=0.086 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current 53388 6
Baseline main 6

Developer Information:

Download Benchmark

@ahejlsberg
Copy link
Member Author

Tests and performance are unchanged, except for a new error in typeorm. In that code, FindOptionsWhere<any> is resolved to { [x: string]: any }. The error is caused by the fact that any[] is no longer a strict subtype of { [x: string]: any }, so the type in the false branch becomes any[] | FindOptionsWhere<any>, correctly revealing that where might be a zero length array in the false branch. So, new error seems entirely reasonable.

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2023

Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at ae63c73. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2023

Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/150747/artifacts?artifactName=tgz&fileId=9EB6E7523EC88284C829E71D1C2E037D04E39129FD4B4A6E11C3B33AB1354E9102&fileName=/typescript-5.1.0-insiders.20230322.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@DanielRosenwasser
Copy link
Member

@ahejlsberg sounds like what you're saying is that TypeORM is supposed to still handle the 0-length case, and can do so by

Would you be able to add an equivalentish test case to document this?

function foo(obj: Record<string, any> | Record<string, any>[]) {
    if (Array.isArray(obj) && obj.length) {
        for (let key in obj) {
            if (obj[key] !== undefined) {
                console.log(obj[key])
            }
        }
    }
    else {
        for (let key in obj) {
            if (obj[key] !== undefined) {
                console.log(obj[key])
            }
        }
    }
}

function bar(obj: Record<string, any> | Record<string, any>[]) {
    if (Array.isArray(obj)) {
        for (let key in obj) {
            if (obj[key] !== undefined) {
                console.log(obj[key])
            }
        }
    }
    else {
        for (let key in obj) {
            if (obj[key] !== undefined) {
                console.log(obj[key])
            }
        }
    }
}

@DanielRosenwasser
Copy link
Member

Confirmed in the test playground that foo has errors, but bar is fine.

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Mar 22, 2023

I've added the tests, I'm running a task to update the baselines.

@DanielRosenwasser
Copy link
Member

the heck?

@DanielRosenwasser
Copy link
Member

@typescript-bot cherry-pick this to release-5.0

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2023

Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into release-5.0 on this PR at 37911f8. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, I've opened #53445 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Mar 22, 2023
Component commits:
e2aa5c6 Exclude special index signature rule from strict subtype relation

ae63c73 Add tests

54703cd Add more test cases.

37911f8 Accepted baselines.
@ahejlsberg ahejlsberg merged commit 25550bd into main Mar 23, 2023
@ahejlsberg ahejlsberg deleted the fix53379 branch March 23, 2023 14:03
DanielRosenwasser added a commit that referenced this pull request Mar 23, 2023
drivron pushed a commit to scenari/typescript that referenced this pull request Sep 14, 2023
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.

Assertion function & Type guards for Record types broken on 5.0
3 participants