Skip to content

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

@Andarist

Description

@Andarist

🔎 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 #62178

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions