microsoft / microsoft/TypeScript
Import assignment should work with esnext targets
オープン
まだ誰も着手していません。
Needs Proposal
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
Search Terms
import assignment
Suggestion
#22321 was closed by a bot that thought the issue was addressed, but it wasn't.
Import assignment should work with esnext targets
Use Cases
JS modules loaders for Node might not support importing CJS with import statements, so you would use require to import them. But we'd still like to bring in their types. This is what import assignment is designed for, it's just disallowed with esnext targets.
Examples
This:
import * as m from './a-module.js';
import cjs = require('some-cjs');
should emit:
import * as m from './a-module.js';
const cjs = require('some-cjs');
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. new expression-level syntax)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ファイルもテストも指定されていません。まず、esnext ターゲットに対する TypeScript の import 割り当て処理を追跡し、次に現在の出力を issue の例と比較してください。割り当てによって require ベースの宣言が出力され、既存の import が保持されれば作業は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100