Microsoft/TypeScript

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

Open

#62 294 ouverte le 17 août 2025

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
BugDomain: Indexed Access TypesHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

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

Guide contributeur