microsoft / microsoft/TypeScript

`satisfies` does not work on a variable called `type`

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

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

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

説明

🔎 Search Terms

satisfies, type, ts1005

🕗 Version & Regression Information

This happens from 3.3.3333 to nightly.

satisfies was introduced in 4.9.

⏯ Playground Link

https://www.typescriptlang.org/play?#code/MYewdgzgLgBFCeAHApjAvDA5AD0wKDwRRggEMoBLCAMwuQhKgCcKwBzPIA

💻 Code
const type = 'x'

type satisfies string // '=' expected.(1005)
🙁 Actual behavior

Gives an '=' expected.(1005) error.

🙂 Expected behavior

For it to work like with any other variable of any other name, specially since it's a common variable name.

Additional information about the issue

This also happens with other TypeScript keywords like interface.

If I wrap type in parenthesis it works, is this expected behaviour? The Deno formatter removes it (prettier handles it correctly), should I report this to them.

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

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

はじめの一歩

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

調査の方向性

リンクされた Playground の再現例と、typeinterface などの TypeScript キーワードである識別子が続く satisfies 式の parser パスから始めます。示された snippet に対して動作を確認します。これらの変数名が、既存のキーワード構文を維持したまま、TS1005 なしで他の名前と同様にパースされれば完了です。

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

評価

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

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

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