microsoft / microsoft/TypeScript
`export let` variable doesn't require the variable to be assigned within current file
未关闭
还没有人认领这个 Issue。
Domain: check: Control Flow
Help Wanted
Possible Improvement
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
🔎 Search Terms
export let, undefined, assignment, assigned
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
export let
⏯ Playground Link
No response
💻 Code
// a.ts
export let x: { foo(): void }
if (!!false) {
// @ts-expect-error Variable 'x' is used before being assigned.
x.foo()
}
// b.ts
import { x } from './a.ts'
// TS compiles, throws at runtime
x.foo()
🙁 Actual behavior
TS compiles, only throws at runtime.
🙂 Expected behavior
TS refuses to compile without ! non-null assertion, with error probably being reported in the exporting module a.ts rather than the importing module b.ts.
Additional information about the issue
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 a.ts 和 b.ts 中的跨文件示例开始,重现当前的编译和运行时行为。跟踪对导出的 x 进行的明确赋值检查及其在导入后的使用;完成的标准是编译器报告缺少赋值,而不是允许运行时失败。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100