Skip to content

Do not set valueDeclaration for intersection properties when one symbol does not have a valueDeclaration #61872

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mdm317
Copy link

@mdm317 mdm317 commented Jun 15, 2025

Fixes #61743
This issue arised because the intersection types are different.

declare class X {
	private a: number;
	b: string;
}
type Y = { a: number } & { b: string };
type Z = Pick<{ a: number }, 'a'> & { b: string };
type T1 = X & Y // T1 is never
type T2 = X & Z // but T2 is not never

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jun 15, 2025
@@ -15547,7 +15547,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
let firstValueDeclaration: Declaration | undefined;
let hasNonUniformValueDeclaration = false;
for (const prop of props) {
if (!firstValueDeclaration) {
if(!prop.valueDeclaration){
Copy link
Author

Choose a reason for hiding this comment

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

In isConflictingPrivateProperty, if symbols are not uniform and has private properties, determine property is conflict

    function isConflictingPrivateProperty(prop: Symbol) {
        // Return true for a synthetic property with multiple declarations, at least one of which is private.
        return !prop.valueDeclaration && !!(getCheckFlags(prop) & CheckFlags.ContainsPrivate);
    }

Currently, a intersection/uniform property is treated as uniform when one source property has a valueDeclaration, while another source property(mapped type) does not.
I think we should treat such properties as non-uniform instead.

@mdm317
Copy link
Author

mdm317 commented Jun 15, 2025

@microsoft-github-policy-service agree

@mdm317 mdm317 marked this pull request as ready for review June 15, 2025 16:20
@jakebailey
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 30, 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

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

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

@jakebailey
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,370 62,370 ~ ~ ~ p=1.000 n=6
Types 50,386 50,386 ~ ~ ~ p=1.000 n=6
Memory used 195,961k (± 0.76%) 195,909k (± 0.73%) ~ 193,004k 196,672k p=0.575 n=6
Parse Time 1.58s (± 1.68%) 1.60s (± 1.52%) ~ 1.56s 1.63s p=0.366 n=6
Bind Time 0.88s (± 1.24%) 0.87s (± 1.34%) ~ 0.85s 0.88s p=0.170 n=6
Check Time 11.76s (± 0.64%) 11.78s (± 0.42%) ~ 11.71s 11.85s p=0.748 n=6
Emit Time 3.34s (± 3.42%) 3.34s (± 3.63%) ~ 3.27s 3.58s p=0.683 n=6
Total Time 17.57s (± 0.96%) 17.59s (± 0.68%) ~ 17.48s 17.82s p=1.000 n=6
angular-1 - node (v18.15.0, x64)
Errors 56 56 ~ ~ ~ p=1.000 n=6
Symbols 948,753 948,753 ~ ~ ~ p=1.000 n=6
Types 410,846 410,846 ~ ~ ~ p=1.000 n=6
Memory used 1,225,205k (± 0.00%) 1,225,206k (± 0.00%) ~ 1,225,173k 1,225,238k p=0.630 n=6
Parse Time 7.90s (± 0.73%) 7.98s (± 0.51%) +0.07s (+ 0.93%) 7.93s 8.04s p=0.037 n=6
Bind Time 2.29s (± 0.36%) 2.28s (± 0.37%) ~ 2.27s 2.29s p=0.120 n=6
Check Time 38.09s (± 0.42%) 38.10s (± 0.25%) ~ 38.03s 38.28s p=0.808 n=6
Emit Time 17.82s (± 0.49%) 17.85s (± 0.54%) ~ 17.74s 17.98s p=0.748 n=6
Total Time 66.11s (± 0.36%) 66.20s (± 0.16%) ~ 66.09s 66.36s p=0.471 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,509,183 2,509,183 ~ ~ ~ p=1.000 n=6
Types 892,716 892,716 ~ ~ ~ p=1.000 n=6
Memory used 2,804,513k (± 0.00%) 2,804,431k (± 0.00%) ~ 2,804,343k 2,804,572k p=0.093 n=6
Parse Time 10.46s (± 0.24%) 10.46s (± 0.16%) ~ 10.43s 10.47s p=0.935 n=6
Bind Time 2.71s (± 1.01%) 2.73s (± 0.55%) ~ 2.70s 2.74s p=0.622 n=6
Check Time 100.98s (± 1.03%) 101.23s (± 1.15%) ~ 100.05s 103.13s p=0.873 n=6
Emit Time 0.36s (± 2.24%) 0.37s (± 2.29%) ~ 0.35s 0.37s p=0.485 n=6
Total Time 114.52s (± 0.91%) 114.78s (± 1.01%) ~ 113.58s 116.66s p=0.688 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,081 1,227,081 ~ ~ ~ p=1.000 n=6
Types 267,474 267,474 ~ ~ ~ p=1.000 n=6
Memory used 2,853,238k (±13.21%) 2,975,326k (±10.02%) ~ 2,365,962k 3,098,033k p=0.378 n=6
Parse Time 8.25s (± 1.50%) 8.27s (± 1.82%) ~ 7.97s 8.38s p=0.688 n=6
Bind Time 2.68s (± 1.74%) 2.65s (± 1.80%) ~ 2.59s 2.71s p=0.471 n=6
Check Time 53.00s (± 0.54%) 53.18s (± 0.17%) ~ 53.07s 53.31s p=0.575 n=6
Emit Time 4.31s (± 2.19%) 4.31s (± 1.95%) ~ 4.23s 4.44s p=0.630 n=6
Total Time 68.26s (± 0.65%) 68.41s (± 0.33%) ~ 68.10s 68.68s 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,227,081 1,227,081 ~ ~ ~ p=1.000 n=6
Types 267,474 267,474 ~ ~ ~ p=1.000 n=6
Memory used 2,430,272k (± 0.02%) 2,551,834k (±11.63%) ~ 2,429,873k 3,158,365k p=0.230 n=6
Parse Time 5.40s (± 0.83%) 5.38s (± 1.35%) ~ 5.31s 5.52s p=0.520 n=6
Bind Time 1.83s (± 0.80%) 1.83s (± 1.17%) ~ 1.80s 1.86s p=0.745 n=6
Check Time 35.27s (± 0.34%) 35.25s (± 0.78%) ~ 35.05s 35.80s p=0.230 n=6
Emit Time 3.04s (± 1.52%) 3.05s (± 1.05%) ~ 3.00s 3.09s p=0.686 n=6
Total Time 45.54s (± 0.26%) 45.51s (± 0.74%) ~ 45.32s 46.19s p=0.261 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,548 262,548 ~ ~ ~ p=1.000 n=6
Types 107,156 107,156 ~ ~ ~ p=1.000 n=6
Memory used 441,920k (± 0.03%) 441,879k (± 0.01%) ~ 441,822k 441,921k p=1.000 n=6
Parse Time 3.52s (± 0.80%) 3.54s (± 0.97%) ~ 3.51s 3.59s p=0.368 n=6
Bind Time 1.32s (± 1.04%) 1.32s (± 0.62%) ~ 1.31s 1.33s p=0.932 n=6
Check Time 18.85s (± 0.38%) 18.93s (± 0.50%) ~ 18.84s 19.08s p=0.261 n=6
Emit Time 1.54s (± 1.35%) 1.52s (± 1.73%) ~ 1.50s 1.56s p=0.366 n=6
Total Time 25.23s (± 0.39%) 25.31s (± 0.48%) ~ 25.18s 25.51s p=0.377 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 71 71 ~ ~ ~ p=1.000 n=6
Symbols 225,367 225,367 ~ ~ ~ p=1.000 n=6
Types 94,290 94,290 ~ ~ ~ p=1.000 n=6
Memory used 371,081k (± 0.01%) 371,190k (± 0.04%) ~ 371,056k 371,381k p=0.173 n=6
Parse Time 2.86s (± 1.75%) 2.88s (± 0.92%) ~ 2.86s 2.92s p=0.871 n=6
Bind Time 1.58s (± 0.48%) 1.60s (± 1.21%) +0.02s (+ 1.26%) 1.58s 1.63s p=0.046 n=6
Check Time 16.36s (± 0.25%) 16.35s (± 0.17%) ~ 16.32s 16.40s p=0.809 n=6
Emit Time 0.00s (±244.70%) 0.00s ~ ~ ~ p=0.405 n=6
Total Time 20.81s (± 0.27%) 20.84s (± 0.12%) ~ 20.80s 20.87s p=0.376 n=6
vscode - node (v18.15.0, x64)
Errors 33 33 ~ ~ ~ p=1.000 n=6
Symbols 3,499,297 3,499,297 ~ ~ ~ p=1.000 n=6
Types 1,177,214 1,177,214 ~ ~ ~ p=1.000 n=6
Memory used 3,549,844k (± 0.01%) 3,549,901k (± 0.00%) ~ 3,549,714k 3,550,073k p=0.471 n=6
Parse Time 15.06s (± 0.73%) 15.16s (± 0.60%) ~ 15.04s 15.27s p=0.093 n=6
Bind Time 4.91s (± 0.62%) 4.87s (± 0.30%) -0.04s (- 0.75%) 4.85s 4.89s p=0.007 n=6
Check Time 96.45s (± 3.21%) 95.93s (± 3.23%) ~ 93.85s 101.70s p=0.471 n=6
Emit Time 31.07s (± 7.59%) 31.07s (± 7.99%) ~ 29.41s 35.90s p=0.810 n=6
Total Time 147.48s (± 3.50%) 147.03s (± 2.46%) ~ 143.59s 152.71s p=0.936 n=6
webpack - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 318,019 318,019 ~ ~ ~ p=1.000 n=6
Types 137,705 137,705 ~ ~ ~ p=1.000 n=6
Memory used 472,117k (± 0.02%) 472,204k (± 0.03%) ~ 472,028k 472,417k p=0.298 n=6
Parse Time 4.32s (± 0.47%) 4.36s (± 0.76%) ~ 4.32s 4.41s p=0.050 n=6
Bind Time 1.76s (± 2.00%) 1.76s (± 1.29%) ~ 1.73s 1.79s p=0.744 n=6
Check Time 20.65s (± 0.50%) 20.72s (± 0.26%) ~ 20.64s 20.77s p=0.227 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 26.73s (± 0.44%) 26.83s (± 0.24%) ~ 26.75s 26.90s p=0.128 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 665,978 665,978 ~ ~ ~ p=1.000 n=6
Types 199,345 199,345 ~ ~ ~ p=1.000 n=6
Memory used 570,406k (± 0.01%) 570,405k (± 0.01%) ~ 570,284k 570,540k p=0.689 n=6
Parse Time 4.28s (± 0.38%) 4.26s (± 0.47%) ~ 4.24s 4.29s p=0.157 n=6
Bind Time 1.33s (± 0.57%) 1.33s (± 1.46%) ~ 1.31s 1.36s p=0.742 n=6
Check Time 19.91s (± 0.31%) 19.86s (± 0.25%) ~ 19.78s 19.91s p=0.127 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 25.52s (± 0.27%) 25.45s (± 0.28%) ~ 25.35s 25.54s p=0.128 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

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

Everything looks good!

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
None yet
Development

Successfully merging this pull request may close these issues.

Intersection with a mapped type breaks bypassing private assignability.
3 participants