microsoft / microsoft/TypeScript
Missing error about inability to access conflicting private properties on generic types involving intersections
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
🔎 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided TypeScript Playground reproduction and compare the aliases involving intersections, private properties, and deep indexed access with the cases that already report errors. Trace the type-checking behavior around these generic constraints and review the related issue and regression PR; done means Z, Z_, Z3, and Z3_ produce the expected accessibility errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100