Microsoft/TypeScript
在 GitHub 查看Missing error about inability to access conflicting private properties on generic types involving intersections
Open
#62,294 建立於 2025年8月17日
BugDomain: Indexed Access TypesHelp Wanted
倉庫指標
- Star
- (48,455 star)
- PR 合併指標
- (平均合併 6天 17小時) (30 天內合併 9 個 PR)
描述
🔎 Search Terms
accessibility private intersection never reduced conflicting
🕗 Version & Regression Information
- This changed in PR: https://github.com/microsoft/TypeScript/pull/37762 - the error was present before this PR, there was a test for it: https://github.com/microsoft/TypeScript/pull/37762/files#diff-ca0ed2db9207146d34393eb3428bf91872b53a7d882b1e010312ec6f02b9d08aL24
⏯ Playground Link
💻 Code
class A {
private a: { foo: number };
}
class B {
private a: { bar: string };
}
type X<T extends A> = [T["a"], (T | B)["a"]]; // errors
type Y<T extends A | B> = T["a"]; // error
type Z<T extends A & B> = T["a"]; // no error?
type Z_<T extends A & B> = T["a"]["b"]["c"]["d"]; // look, we can even go crazy and access deep unknown properties
type Z1<T extends A> = T["a"]; // error
type Z2<T extends B> = T["a"]; // error
type Z3<T extends A, T2 extends B> = (T & T2)["a"]; // no error?
type Z3_<T extends A, T2 extends B> = (T & T2)["a"]["b"]["c"]["d"]; // look, we can even go crazy and access deep unknown properties
🙁 Actual behavior
Z, Z_, Z3 and Z3_ have no errors
🙂 Expected behavior
I would expect the above type aliases to all contain errors
Additional information about the issue
somewhat related to https://github.com/microsoft/TypeScript/issues/62178