microsoft / microsoft/TypeScript
Declare type to be an import depending on a string literal argument: typeof import(name);
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
Hello,
It's seems to be difficult to do but there's now a lot of possibilities with the typescript compiler that I wouldn't have thought possible before, so I prefer to ask.
Is there a chance to have this kind of definition:
declare function require(name: string): typeof import(name) | undefined;
I mean declaring the return type as the type coming from the import of module "name". So we could have the type returned by require:
var module = require("my module");
I guess if it's feasible, it will also be possible to add more typing on this kind of javascript code
define("myModule, ["deps1", "deps2", "deps3"], (deps1, deps2, deps3) => {
// deps1, deps2, deps3 have the right type !!
});
like this
define("myModule, ["deps1", "deps2", "deps3"], (deps1: typeof import("deps1"), deps2: typeof import("deps2"), deps3: : typeof import("deps3")) => {
// deps1, deps2, deps3 have the right type !!
});
Thanks for your help,
--
Laurent
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、TypeScript コンパイラーが typeof import(name) を文字列リテラルに依存させ、その結果を require と define の呼び出しに使用できるかどうかを調査します。issue の例を確認し、必要な言語および型チェックの変更を判断します。完了の条件は、要求されたモジュール型がリテラル引数から推論されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100