Microsoft/TypeScript

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

Open

#62,294 opened on Aug 17, 2025

View on GitHub
ย (1 comment)ย (0 reactions)ย (0 assignees)TypeScriptย (48,455 stars)ย (6,726 forks)batch import
BugDomain: Indexed Access TypesHelp Wanted

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

Missing error about inability to access conflicting private properties on generic types involving intersections ยท Microsoft/TypeScript#62294 | Good First Issue