microsoft / microsoft/TypeScript

skipLibChecks specificity

未关闭
#63,397 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Needs Proposal Suggestion
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

🔍 Search Terms

skipLibCheck specific files

✅ Viability Checklist
⭐ Suggestion

Currently skipLibCheck is an all or nothing proposition. You either suppress all errors from declaration files or you get errors from all declaration files. This is not really an accurate reflection of how declaration files are usually used. Almost all projects use declaration files from a trusted source, like npm. Errors from these files are usually not relevant and can be safely suppressed. Many projects however also have declaration files they write by hand (usually for interop with js files, or for libraries that are not typed) - these generally should be type checked since they are actively authored as part of the project.

Ideally skipLibCheck would allow us to more granularly control which declaration files are checked and which are not. This allows us to reap the performance benefits of skipLibCheck while not sacrificing type checking on authored code.

Proposal

One possible solution would be to allow skipLibCheck to be a list of glob patterns for which type checking should be skipped. This would be a simple solution allowing users to decide what declaration files they want and don't want checked.

While this solution is probably the simplest one to implement, we should consider other ones.

📃 Motivating Example

We have a custom build tool that uses the compiler API to force some declaration files to skip checking by setting their hasDefaultLib flag and using skipDefaultLibCheck instead of skipLibCheck. While this solution worked well in the past this is not really a supported solution which we expect will break (6.0 already breaks our current implementation - we have found an alternate implementation, 7.0 will make any sort of custom solution much more difficult)

💻 Use Cases
  1. What do you want to use this for?
    Improve build performance of TypeScript projects.

  2. What shortcomings exist with current approaches?
    You can suppress errors from all declaration files or from none. There is no granular control over it.

  3. What workarounds are you using in the meantime?
    Use the compiler API to control which declaration files are checked.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先审查该提案以及编译器选项 skipLibCheck 和 skipDefaultLibCheck 当前的行为。issue 没有列出任何文件或测试,因此在决定采用 glob 模式还是其他设计之前,先定位编译器选项的处理逻辑和相关测试覆盖范围。完成的标准是:能够对声明文件检查进行细粒度控制,同时保留所述的性能优势。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
compilers
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。