microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
98.28k stars 12.21k forks source link

fix53287 `mergeSymbol` checks if the resolved target can merge with the source #58326

Open iisaduan opened 2 weeks ago

iisaduan commented 2 weeks ago

Fixes https://github.com/microsoft/TypeScript/issues/53287

While investigating the original issue, I found that re-exporting an alias would circumvent any checks to determine whether or not the source and the target are allowed to merge at all.

This adds a check in mergeSymbol to check if the resolved target can merge with the source, and if they cannot merge, then we issue the same errors as if there was no reexporting.

Got lots of help from @sandersn looking over the new errors 🙂

iisaduan commented 2 weeks ago

@typescript-bot test it

typescript-bot commented 2 weeks ago

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 commented 2 weeks ago

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

There were interesting changes:

Branch only errors: Package: karma-chai-sinon Error: ``` Error: /mnt/vss/_work/1/DefinitelyTyped/types/karma-chai-sinon/index.d.ts 8:9 error TypeScript@local compile error: Duplicate identifier 'sinon' @definitelytyped/expect ✖ 1 problem (1 error, 0 warnings) at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240426/node_modules/@definitelytyped/dtslint/dist/index.js:194:28) at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240426/node_modules/@definitelytyped/dtslint/dist/index.js:186:20) ``` Package: bandagedbd__bdapi Error: ``` Error: /mnt/vss/_work/1/DefinitelyTyped/types/bandagedbd__bdapi/index.d.ts 9:11 error TypeScript@local compile error: Cannot redeclare block-scoped variable '_' @definitelytyped/expect 9:11 error TypeScript@local compile error: '_' is referenced directly or indirectly in its own type annotation @definitelytyped/expect ✖ 2 problems (2 errors, 0 warnings) at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240426/node_modules/@definitelytyped/dtslint/dist/index.js:194:28) at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240426/node_modules/@definitelytyped/dtslint/dist/index.js:186:20) ``` Package: regenerator-runtime Error: ``` Error: /mnt/vss/_work/1/DefinitelyTyped/types/regenerator-runtime/index.d.ts 1:21 error TypeScript@local compile error: Duplicate identifier 'regeneratorRuntime' @definitelytyped/expect 3:9 error TypeScript@local compile error: Duplicate identifier 'regeneratorRuntime' @definitelytyped/expect ✖ 2 problems (2 errors, 0 warnings) at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240426/node_modules/@definitelytyped/dtslint/dist/index.js:194:28) at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240426/node_modules/@definitelytyped/dtslint/dist/index.js:186:20) ```

You can check the log here.

typescript-bot commented 2 weeks ago

@iisaduan Here are the results of running the user tests comparing main and refs/pull/58326/merge:

Everything looks good!

typescript-bot commented 2 weeks ago

@iisaduan 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,154 62,154 ~ ~ ~ p=1.000 n=6
Types 50,273 50,273 ~ ~ ~ p=1.000 n=6
Memory used 194,541k (± 0.96%) 192,791k (± 0.74%) ~ 192,101k 195,677k p=0.173 n=6
Parse Time 1.35s (± 1.95%) 1.36s (± 1.18%) ~ 1.33s 1.38s p=0.739 n=6
Bind Time 0.72s (± 0.57%) 0.72s (± 0.57%) ~ 0.72s 0.73s p=1.000 n=6
Check Time 9.58s (± 0.54%) 9.60s (± 0.43%) ~ 9.52s 9.63s p=0.296 n=6
Emit Time 2.62s (± 0.82%) 2.62s (± 0.37%) ~ 2.61s 2.63s p=0.805 n=6
Total Time 14.27s (± 0.39%) 14.30s (± 0.32%) ~ 14.23s 14.35s p=0.377 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 945,172 945,172 ~ ~ ~ p=1.000 n=6
Types 408,068 408,068 ~ ~ ~ p=1.000 n=6
Memory used 1,222,038k (± 0.00%) 1,221,992k (± 0.01%) ~ 1,221,865k 1,222,117k p=0.378 n=6
Parse Time 6.91s (± 0.28%) 6.90s (± 0.61%) ~ 6.84s 6.96s p=0.572 n=6
Bind Time 1.87s (± 0.88%) 1.87s (± 0.53%) ~ 1.86s 1.88s p=0.934 n=6
Check Time 31.56s (± 0.54%) 31.32s (± 0.17%) -0.25s (- 0.78%) 31.26s 31.41s p=0.020 n=6
Emit Time 14.67s (± 0.56%) 14.58s (± 0.39%) ~ 14.50s 14.66s p=0.054 n=6
Total Time 55.01s (± 0.47%) 54.66s (± 0.19%) -0.35s (- 0.63%) 54.48s 54.80s p=0.031 n=6
mui-docs - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 1,954,602 1,954,602 ~ ~ ~ p=1.000 n=6
Types 676,397 676,397 ~ ~ ~ p=1.000 n=6
Memory used 1,753,365k (± 0.00%) 1,753,357k (± 0.00%) ~ 1,753,336k 1,753,405k p=0.810 n=6
Parse Time 6.89s (± 0.12%) 6.88s (± 0.43%) ~ 6.82s 6.90s p=0.354 n=6
Bind Time 2.30s (± 0.35%) 2.30s (± 0.27%) ~ 2.29s 2.31s p=0.432 n=6
Check Time 56.85s (± 0.48%) 56.82s (± 0.35%) ~ 56.61s 57.03s p=0.809 n=6
Emit Time 0.14s 0.14s (± 5.31%) ~ 0.13s 0.15s p=0.598 n=6
Total Time 66.19s (± 0.41%) 66.15s (± 0.28%) ~ 65.94s 66.35s p=0.810 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,214,779 1,214,782 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Types 257,315 257,316 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,322,738k (± 0.03%) 2,322,276k (± 0.03%) ~ 2,321,392k 2,323,433k p=0.575 n=6
Parse Time 5.04s (± 1.37%) 5.05s (± 0.88%) ~ 4.99s 5.12s p=0.936 n=6
Bind Time 1.88s (± 0.92%) 1.88s (± 0.87%) ~ 1.86s 1.90s p=0.871 n=6
Check Time 34.04s (± 0.30%) 34.03s (± 0.32%) ~ 33.96s 34.24s p=0.936 n=6
Emit Time 2.74s (± 2.33%) 2.76s (± 1.94%) ~ 2.65s 2.79s p=1.000 n=6
Total Time 43.73s (± 0.39%) 43.75s (± 0.25%) ~ 43.63s 43.95s p=0.810 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,214,779 1,214,782 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Types 257,315 257,316 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,397,465k (± 0.03%) 2,396,917k (± 0.02%) ~ 2,396,150k 2,397,356k p=0.128 n=6
Parse Time 6.30s (± 1.11%) 6.34s (± 1.03%) ~ 6.25s 6.40s p=0.298 n=6
Bind Time 2.00s (± 2.23%) 2.01s (± 1.77%) ~ 1.97s 2.06s p=0.936 n=6
Check Time 40.58s (± 0.22%) 40.61s (± 0.19%) ~ 40.49s 40.70s p=0.521 n=6
Emit Time 3.20s (± 1.81%) 3.23s (± 2.96%) ~ 3.06s 3.31s p=0.378 n=6
Total Time 52.10s (± 0.28%) 52.22s (± 0.22%) ~ 52.08s 52.37s p=0.298 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 256,043 256,046 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Types 103,601 103,602 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 423,971k (± 0.01%) 423,981k (± 0.01%) ~ 423,957k 424,018k p=0.229 n=6
Parse Time 3.48s (± 1.45%) 3.48s (± 0.72%) ~ 3.45s 3.52s p=1.000 n=6
Bind Time 1.30s (± 1.26%) 1.30s (± 0.97%) ~ 1.28s 1.32s p=0.864 n=6
Check Time 18.16s (± 0.24%) 18.16s (± 0.31%) ~ 18.10s 18.24s p=0.936 n=6
Emit Time 1.41s (± 1.37%) 1.40s (± 1.16%) ~ 1.38s 1.43s p=0.560 n=6
Total Time 24.36s (± 0.35%) 24.34s (± 0.19%) ~ 24.27s 24.40s p=0.936 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,824 224,824 ~ ~ ~ p=1.000 n=6
Types 93,390 93,390 ~ ~ ~ p=1.000 n=6
Memory used 369,279k (± 0.01%) 369,288k (± 0.01%) ~ 369,202k 369,335k p=0.471 n=6
Parse Time 3.69s (± 0.61%) 3.67s (± 0.56%) ~ 3.64s 3.70s p=0.075 n=6
Bind Time 1.94s (± 0.92%) 1.92s (± 1.17%) ~ 1.90s 1.96s p=0.224 n=6
Check Time 19.46s (± 0.69%) 19.43s (± 0.55%) ~ 19.26s 19.52s p=0.575 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 25.09s (± 0.54%) 25.02s (± 0.49%) ~ 24.81s 25.12s p=0.471 n=6
vscode - node (v18.15.0, x64)
Errors 4 4 ~ ~ ~ p=1.000 n=6
Symbols 2,796,261 2,796,261 ~ ~ ~ p=1.000 n=6
Types 950,064 950,064 ~ ~ ~ p=1.000 n=6
Memory used 2,924,835k (± 0.01%) 2,924,849k (± 0.00%) ~ 2,924,612k 2,924,958k p=0.936 n=6
Parse Time 13.49s (± 0.22%) 13.49s (± 0.48%) ~ 13.41s 13.59s p=0.871 n=6
Bind Time 4.10s (± 0.70%) 4.09s (± 0.27%) ~ 4.07s 4.10s p=0.805 n=6
Check Time 72.93s (± 0.26%) 72.91s (± 0.49%) ~ 72.46s 73.32s p=0.936 n=6
Emit Time 20.87s (± 9.44%) 20.23s (± 7.76%) ~ 19.48s 23.43s p=0.575 n=6
Total Time 111.39s (± 1.75%) 110.72s (± 1.32%) ~ 109.48s 113.62s p=0.810 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 265,853 265,853 ~ ~ ~ p=1.000 n=6
Types 108,438 108,438 ~ ~ ~ p=1.000 n=6
Memory used 410,417k (± 0.02%) 410,417k (± 0.02%) ~ 410,334k 410,603k p=0.936 n=6
Parse Time 4.88s (± 0.82%) 4.86s (± 0.55%) ~ 4.83s 4.89s p=0.453 n=6
Bind Time 2.08s (± 0.66%) 2.08s (± 1.10%) ~ 2.06s 2.11s p=0.742 n=6
Check Time 21.13s (± 0.50%) 21.14s (± 0.65%) ~ 20.91s 21.31s p=0.748 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 28.10s (± 0.48%) 28.09s (± 0.51%) ~ 27.85s 28.29s p=1.000 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 523,981 523,981 ~ ~ ~ p=1.000 n=6
Types 178,708 178,708 ~ ~ ~ p=1.000 n=6
Memory used 461,341k (± 0.03%) 461,238k (± 0.01%) ~ 461,165k 461,309k p=0.128 n=6
Parse Time 4.02s (± 0.70%) 3.99s (± 0.47%) ~ 3.97s 4.02s p=0.147 n=6
Bind Time 1.47s (± 0.51%) 1.47s (± 0.79%) ~ 1.46s 1.49s p=0.734 n=6
Check Time 22.49s (± 0.65%) 22.40s (± 0.52%) ~ 22.27s 22.62s p=0.470 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.97s (± 0.51%) 27.87s (± 0.38%) ~ 27.73s 28.05s p=0.375 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 commented 2 weeks ago

@iisaduan Here are the results of running the top 400 repos comparing main and refs/pull/58326/merge:

Something interesting changed - please have a look.

Details

actualbudget/actual

**2 of 4 projects failed to build with the old tsc and were ignored** ### [packages\/loot-core\/tsconfig.api.json](https://github.com/actualbudget/actual/blob/164dd399b0a5b2e5b3755d283020ba8f0eddc5b8/packages/loot-core/tsconfig.api.json) - `error TS2554: Expected 0 arguments, but got 1.` - [packages\/loot-core\/src\/server\/accounts\/rules.ts\#L39](https://github.com/actualbudget/actual/blob/164dd399b0a5b2e5b3755d283020ba8f0eddc5b8/packages/loot-core/src/server/accounts/rules.ts#L39) - [packages\/loot-core\/src\/server\/schedules\/app.ts\#L377](https://github.com/actualbudget/actual/blob/164dd399b0a5b2e5b3755d283020ba8f0eddc5b8/packages/loot-core/src/server/schedules/app.ts#L377) - [packages\/loot-core\/src\/server\/schedules\/find-schedules.ts\#L19](https://github.com/actualbudget/actual/blob/164dd399b0a5b2e5b3755d283020ba8f0eddc5b8/packages/loot-core/src/server/schedules/find-schedules.ts#L19) - `error TS2339: Property 'occurrences' does not exist on type 'Schedule'.` - [packages\/loot-core\/src\/server\/schedules\/app.ts\#L380](https://github.com/actualbudget/actual/blob/164dd399b0a5b2e5b3755d283020ba8f0eddc5b8/packages/loot-core/src/server/schedules/app.ts#L380) - [packages\/loot-core\/src\/server\/schedules\/find-schedules.ts\#L21](https://github.com/actualbudget/actual/blob/164dd399b0a5b2e5b3755d283020ba8f0eddc5b8/packages/loot-core/src/server/schedules/find-schedules.ts#L21)
iisaduan commented 1 week ago

@typescript-bot pack this

typescript-bot commented 1 week ago

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

Command Status Results
pack this ✅ Started ✅ Results
typescript-bot commented 1 week ago

Hey @iisaduan, 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/161623/artifacts?artifactName=tgz&fileId=0A48EC0B9A929F09DB33203B3AEB701FC87DBA101F38C8F5801425F36DA6779D02&fileName=/typescript-5.5.0-insiders.20240506.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/pr-build@5.5.0-pr-58326-8".;

iisaduan commented 1 week ago

Testing results analysis: The extra errors correctly identify wrong code.