microsoft / microsoft/TypeScript
Split the "lib.dom.d.ts" definition file apart
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
Search Terms
lib.dom.d.ts, split, modular
Suggestion
I'm currently writing a TypeScript definition file for the API of a game, which will be submitted to DefinitelyTyped soon.
The API of the game exposes a Notification class to the global scope, which collides with the one in "lib.dom.d.ts" definition file. Not only that, but it also uses jQuery and XMLHttpRequest, forcing me to include that definition file.
Use Cases
By splitting the "lib.dom.d.ts" definition file apart, user can select only the APIs they need.
This change should not break the backward compatibility of old projects, although old versions of TypeScript will not support projects using the modular definition file.
Examples
For example, the "lib.dom.d.ts" definition file could be split up like this:
lib.dom.d.ts
|-- lib.dom.elements.d.ts
|-- lib.dom.notification.d.ts
|-- lib.dom.xhr.d.ts
`-- ... (other modules)
When some parts of the user's definition file collide with the "lib.dom.d.ts" definition file, the user can use the following instead:
{
"compilerOptions": {
"lib": [
"DOM.Elements",
"DOM.XHR",
... // (other modules except for "DOM.Notification")
]
...
}
...
}
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先检查现有的 lib.dom.d.ts 定义文件,以及 compilerOptions.lib 如何选择库定义。定义一种模块化拆分,使用户能够省略相互冲突的 API(例如 DOM.Notification),同时保留 lib.dom.d.ts 对现有项目的当前行为。完成的标准是,所提议的组织方式支持选择性 DOM API,且不会破坏向后兼容性。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100