Skip to content

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

Open

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

Activity

  1. hesam-oxe commented on May 12, 2026

    @hesam-oxe

    I'd like to investigate this. The issue is clear — Z, Z_, Z3,
    and Z3_ should all error when accessing private properties on
    intersection types, consistent with the other cases.

    I'll look at checker.ts around the indexed access type resolution
    and the intersection reduction logic from #37762.

    /assign

  2. hesam-oxe commented on Jun 11, 2026

    @hesam-oxe

    Mateusz Burzyński (@Andarist) Ryan Cavanaugh (@RyanCavanaugh) Apologies for the delay — I was deep in
    LLVM X86 backend fixes and OWASP security benchmarks and this
    slipped through the cracks.

    I've now opened PR #63548 with the fix. The check uses the
    existing isConflictingPrivateProperty helper that was already
    used in getReducedType — just wasn't being called in the indexed
    access path.

    Ready for review! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Indexed Access TypesThe issue relates to accessing subtypes via index accessHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions