microsoft / microsoft/TypeScript
`isolatedModules` does not generate the same code
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
🔎 Search Terms
isolatedModules
const enum
inlining
generated code
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
const enum NotSoAwesomeConstEnum {
SomeValue,
AnotherOne
}
function dosomething(state: NotSoAwesomeConstEnum): void {
switch (state) {
case NotSoAwesomeConstEnum.SomeValue:
console.log('SomeValue');
break;
case NotSoAwesomeConstEnum.AnotherOne:
console.log('AnotherOne');
break;
}
}
🙁 Actual behavior
The emitted code is not the same when using isolatedModules.
🙂 Expected behavior
The emitted code should be the same when using isolatedModules as it is described as nothing else but a check
Setting the isolatedModules flag tells TypeScript to warn you if you write certain code that can’t be correctly interpreted by a single-file transpilation process.
const enum values should be inlined even when using this flag. (Or an error should be emitted).
Additional information about the issue
From the documentation:
It does not change the behavior of your code, or otherwise change the behavior of TypeScript’s checking and emitting process.
Which is not true, at least for const enum as this prevents inlining.
See the playground link and https://github.com/microsoft/TypeScript/issues/16671#issuecomment-1686858424
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground から始め、const enum の例について isolatedModules を指定した場合と指定しない場合の出力コードを比較します。const enum の処理を担当するコンパイラーパスを追跡し、値をインライン化すべきか、エラーを報告すべきかを判断します。出力が一致するか、明確な診断が得られれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100