microsoft / microsoft/TypeScript
`export` modifier on `enum` disables `This condition will always return * ts2845`
未关闭
还没有人认领这个 Issue。
Bug
Domain: check: Control Flow
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
🔎 Search Terms
export enum ts2845
🕗 Version & Regression Information
5.4 doesn't flag it without the export modifier either.
⏯ Playground Link
💻 Code
// remove `export` modifier
export enum AdapterOutputType {
APP_PAGE,
PAGES,
}
declare const type: AdapterOutputType
const kind =
type === AdapterOutputType.APP_PAGE || AdapterOutputType.PAGES
// ~ should be flagged with: This condition will always return 'true'.(2845)
? 'left'
: 'right';
🙁 Actual behavior
No typechecking error
🙂 Expected behavior
ts2845 because the condition is always true.
Additional information about the issue
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先复现链接的 TypeScript Playground 案例,然后比较 AdapterOutputType 带有和不带有 export 修饰符时的诊断行为。跟踪枚举成员比较的类型检查路径,并验证错误条件会收到 TS2845,同时不会为有效案例引入诊断。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 描述清楚
- 新手友好度
- 56/100