microsoft / microsoft/TypeScript-TmLanguage
TextMate tokenizer enters incorrect scope after typeof a < "u" in JavaScript, affecting subsequent function declarations
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 471
- フォーク
- 149
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
VS Code Version
Version: 1.124.2 (user setup)
Commit: 6928394f91b684055b873eecb8bc281365131f1c
Date: 2026-06-12T00:12:36Z
Electron: 42.2.0
ElectronBuildId: 14159160
Chromium: 148.0.7778.97
Node.js: 24.15.0
V8: 14.8.178.14-electron.0
OS: Windows_NT x64 10.0.26200
Fresh install of VS Code with all default settings. No extensions installed, no custom configuration applied.
Also reproduced on VS Code for the Web (vscode.dev) with no extensions or custom configuration.
Reproducible Example
function bar() {
return "bar";
}
var a = typeof a < "u";
function foo() {
return "foo";
}
Steps to Reproduce
- Install VS Code with all default settings (no extensions, no custom configuration).
- Create a new
.jsfile. - Paste the code above.
- Run:
Developer: Inspect Editor Tokens and Scopes
- Inspect the first
functionkeyword (bardeclaration). - Inspect the second
functionkeyword (foodeclaration).
Actual Result
The first function declaration is tokenized correctly:
storage.type.function.js
meta.function.js
source.js
The second function declaration is tokenized incorrectly:
entity.name.type.js
meta.type.parameters.js
meta.var.expr.js
source.js
Syntax highlighting becomes incorrect for all code following:
var a = typeof a < "u";
Expected Result
The second function declaration should receive the same scopes as the first:
storage.type.function.js
meta.function.js
source.js
No tokenizer state should leak past the end of the variable declaration.
Additional Investigation
Replacing:
var a = typeof a < "u";
with:
var a = typeof a > "u";
Notes
- Reproduced on a fresh VS Code install with all default settings and no extensions.
- Reproduced across all built-in themes; the issue is not theme-specific.
- The JavaScript is syntactically valid.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、JavaScript ファイルで例を再現し、「Developer: Inspect Editor Tokens and Scopes」を使用して2つの関数宣言を比較します。typeof a < "u" とその後の宣言を処理する TextMate 文法のルールを追跡します。完了条件は、2つ目の関数が1つ目と同じ scopes を受け取り、tokenizer の状態が後続のコードに漏れなくなることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 68/100