microsoft / microsoft/TypeScript

Missing error about inability to access conflicting private properties on generic types involving intersections

Open
#62,294 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: Indexed Access Types Help Wanted
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
⏯ Playground Link

https://www.typescriptlang.org/play/?ts=6.0.0-dev.20250817#code/MYGwhgzhAECC0G8BQ1oAcBOBLAbmALgKbRgBci0AZgPbXkB2ArgLYBGhG0AvgNxJdIkoSDABCiFOmx4iJcgmiswGchHzZ6Ac258BSfAE80xABoAeACrRCADyL0AJjFgA+aAF5oAbQteARGB+ALoANNAAFFYAPtCiAJT+gUFBPNAA9GnWGBjUGBCChsbQAJqW1naEjs7QMaJunr4BwakZWTkYBUbEAFpltvZOcNAAZLH10I1JLZn01G25APydRd0A+n0VVUOjdR4TicH+rId+wCcOzemZILQA1mEA7sTAYPTWOJXQmnPAGGAAXgYSI4SMBgIQoNAHIRCGhoIx6LdZg83phqMYMPgsBDlj0AIwbAbOcaTS6tDjtXHQboAJkJlUGuwaBxSV3mHX0XWpAGZ6VtYGELDTykSxntIiMJjSEk1Wa1ZuylpyVtz1lZ+gznILhRqtkyIlZRkKZUkjiczkF-Bc5dc7o9nq93p9vtBfgCga8HKDwZDobD4YjkaichisTigA

💻 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.