Microsoft/TypeScript
GitHub ã§èŠãIntersection with a mapped type breaks bypassing private assignability.
Open
#61,743 opened on 2025幎5æ21æ¥
Domain: IntersectionHelp WantedPossible Improvement
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
private assignability intersection mapped type
ð Version & Regression Information
Latest as of today.
⯠Playground Link
ð» Code
Given
declare class X {
private a: number;
b: string;
}
You're allowed to do:
type Y = { a: number } & { b: string };
declare let y: Y;
let x: X = y as Y & X;
But fails with:
type Z = Pick<{ a: number }, 'a'> & { b: string };
declare let z: Z;
let x: X = z as Z & X;
ð Actual behavior
X bypasses private assignability, but the identical type Y errors.
ð Expected behavior
Either neither type is allowed to bypass private assignability, or both types are, since they're identical.
Additional information about the issue
No response