Code Highlighting Broken for Generic Functions with Default Values in .tsx Files

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

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

評価

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

調査の方向性

.tsx ファイルで例を再現し、同じコードを .ts ファイルで使用した場合のハイライトと比較します。デフォルト値を持つジェネリックパラメーターとアロー関数に関する TypeScript TextMate 文法ルールを調査します。.tsx の色が期待される TypeScript のハイライトと一致し、既存の .ts の動作に影響を与えなければ完了です。

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

説明

Does this issue occur when all extensions are disabled?: Yes

  • Version: 1.95.0-insider
  • Commit: 804f450ca900d24db25e7174e8b6dfb3fb2a318c
  • Date: 2024-10-22T13:30:10.100Z
  • Electron: 32.2.1
  • ElectronBuildId: 10427718
  • Chromium: 128.0.6613.186
  • Node.js: 20.18.0
  • V8: 12.8.374.38-electron.0
  • OS: Darwin x64 24.0.0

Describe the bug
In VSCode, when writing a generic function with default values in a .tsx file, code highlighting is broken and colors are displayed incorrectly. The same code works fine in a .ts file.

To Reproduce

  1. Open VSCode and create a new .tsx file.
  2. Write the following code:
const func = <T = string,>(args: T): string => {
  const t = typeof args;
  if (typeof t === 'string') {
    return t.split(',').join('_');
  }
  return '';
};
func('');

const add = (a: number, b: number) => {
  return a + b;
};
  1. Observe the code highlighting.

Expected behavior
Code highlighting should work correctly and match the behavior in .ts files.

Screenshots
In .tsx file:
Image
Pay attention to the screenshot where the generic default parameter definitions, colons, and arrow function arrows are all highlighted in red, while the colors of keywords such as const, if, and return are incorrect.

In .ts file:
Image

主要言語
TypeScript
スター
471
フォーク
149
PR マージ指標
30日以内にマージされた PR はありません

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

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

microsoft/TypeScript-TmLanguage のほかの issue

microsoft/TypeScript-TmLanguage の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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