microsoft / microsoft/TypeScript
raise a type error on attempt to strict-equal-compare a value of string | null to undefined
未关闭
还没有人认领这个 Issue。
Awaiting More Feedback
Suggestion
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
the following examples are almost certainly bugs:
declare var one: string | undefined;
// expected a type error: Operator '===' cannot be applied to types 'string | undefined' and 'null'
// actual no problem
if (one === null) {
// unreachable, because one can't ever be null, undefined was likely meant instead
}
declare var another: string | null;
// expected a type error: Operator '===' cannot be applied to types 'string | null' and 'undefined'
// actual no problem
if (another === undefined) {
// unreachable, because one can't ever be undefined, null was likely meant instead
}
consider raising a type error for the above situations
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先复现 issue 中的两个 TypeScript 示例,并检查编译器对涉及字符串联合类型以及 null 或 undefined 的严格相等比较的类型检查行为。完成的标准是两个不可能的比较都会产生类型错误,而有效的比较仍被接受;payload 未指明源文件或测试。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100