microsoft / microsoft/TypeScript
Missing error about inability to access conflicting private properties on generic types involving intersections
未关闭
还没有人认领这个 Issue。
Bug
Domain: Indexed Access Types
Help Wanted
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
🔎 Search Terms
accessibility private intersection never reduced conflicting
🕗 Version & Regression Information
- This changed in PR: https://github.com/microsoft/TypeScript/pull/37762 - the error was present before this PR, there was a test for it: https://github.com/microsoft/TypeScript/pull/37762/files#diff-ca0ed2db9207146d34393eb3428bf91872b53a7d882b1e010312ec6f02b9d08aL24
⏯ Playground Link
💻 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从提供的 TypeScript Playground 重现开始,将涉及交叉类型、私有属性和深层索引访问的别名与已经报告错误的案例进行比较。跟踪这些泛型约束周围的类型检查行为,并查看相关 issue 和回归 PR;当 Z、Z_、Z3 和 Z3_ 产生预期的可访问性错误时即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100