microsoft / microsoft/TypeScript-TmLanguage
TextMate tokenizer enters incorrect scope after typeof a < "u" in JavaScript, affecting subsequent function declarations
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 471
- Forks
- 149
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example in a JavaScript file and use “Developer: Inspect Editor Tokens and Scopes” to compare the two function declarations. Trace the TextMate grammar rules handling typeof a < "u" and the following declaration; done means the second function receives the same scopes as the first and tokenizer state no longer leaks into subsequent code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100