microsoft / microsoft/TypeScript

[ID-Prep] Type of variable is widened in declaration with !strictNullChecks

オープン
#57,441 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Domain: flag: isolatedDeclarations Help Wanted Possible Improvement
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

The [ID-prep] set of issues aligns Declaration Emit with the forthcoming Isolated Declarations feature.

🔎 Search Terms

const declaration widen

🕗 Version & Regression Information
  • This is the behavior in every version I tried
⏯ Playground Link

Playground Link

💻 Code
declare function f3<T>(a: T, b: T): T;
const x3 = f3("abc", "def");  // "abc" | "def"
🙁 Actual behavior

x3 is emitted as declare const x3: string; in declaration files but it's actually "abc" | "def" in source

🙂 Expected behavior

x3 is emitted as declare const x3: "abc" | "def"

Additional information about the issue

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされた TypeScript Playground の再現と、issue で説明されている declaration emit の動作から始めます。ジェネリック呼び出しから推論されたリテラルユニオンが、出力される declaration の型になるまでを追跡します。完了条件は、declaration が string に拡大されず、"abc" | "def" を保持することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。