microsoft / microsoft/TypeScript

`${number}` template literal type does not allow "NaN" or "Infinity"

オープン
#42,996 コメント 4 件 リアクション 3 件 担当者 0 名 GitHub で見る

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

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Bug Report

🔎 Search Terms

NaN Infinity template literal types

🕗 Version & Regression Information

4.3.0-dev.20210226

⏯ Playground Link

Playground link with relevant code

💻 Code
const a: number = NaN //no error
const b: `${number}` = 'NaN' //Type '"NaN"' is not assignable to type '`${number}`'.

const c: number = Infinity //no error
const d: `${number}` = 'Infinity' //Type '"Infinity"' is not assignable to type '`${number}`'
🙁 Actual behavior

compile errors

🙂 Expected behavior

the strings "NaN" and "Infinity" should be valid `${number}`s because NaN and Infinity are valid numbers

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

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

はじめの一歩

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

調査の方向性

リンクされた TypeScript Playground と issue 内の ${number} の例から始めて、NaNInfinity のエラーを再現します。コンパイラーによるテンプレートリテラル型の処理を追跡し、続いて関連するコンパイラーテストを追加または更新して、既存の ${number} の動作を正しく維持したまま、両方の文字列が受け入れられるようにします。

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

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

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

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