microsoft / microsoft/TypeScript
Export Typescript libraries as individual interfaces as well
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Search Terms
export library interface
Suggestion
Right now Typescript declares it's libraries using d.ts (e.g. lib.dom.d.ts) so if you include this in your project you get the entire DOM library and it's interfaces. This is great however it makes development of isomorphic code harder.
Your only option is to add the dom library to your NodeJS project. This means that consumers could accidentally write unsafe code.
My proposal is really simple. Along with existing d.ts imports, we also export (in a separate file) the interfaces for those libraries
Use Cases
Isomorphic code could be be implemented in an easier way. Right now we need to either include the whole library or use dependency injection. Which is not always trivial.
Here is an example of an issue encountered from the puppeteer repo - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/24419#issuecomment-637700421
Examples
import { Window } from 'typescript/interface/lib.dom'; // proposed path
window.alert('something'); // this will throw TS errors
page.evaluate(() => {
// this will be fine and type checked according to window
(window as Window).alert('something');
});
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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、既存の lib.dom.d.ts 宣言と、提案されている typescript/interface/lib.dom パスを調べてください。issue では実装ファイルやテストは指定されていません。ライブラリのインターフェースを個別に公開し、利用者が DOM ライブラリ全体を含めずにインポートできるようになれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100