microsoft / microsoft/TypeScript-TmLanguage

`extend` in generic function with parens split across lines breaks syntax highlighting

Open
#1,048 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
471
Forks
149
PR merge metrics
No merged PRs in 30d

Description

JavaScript and TypeScript Nightly version:

Not using that extension, but here's my VSCode info:

Version: 1.97.2 (Universal)
Commit: e54c774e0add60467559eb0d1e229c6452cf8447
Date: 2025-02-12T23:20:35.343Z
Electron: 32.2.7
ElectronBuildId: 10982180
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Darwin arm64 24.3.0

Code

const echo = <T extends number>(a
) => { 
  return a;
};

produces:

Image

Where return is colored incorrectly.

It works fine without the extend:

Image

Notably, this breaks the highlighting for the rest of the file.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided TypeScript snippet in VS Code and inspect the grammar rules handling generic function type parameters, the multiline parenthesized parameter list, and the arrow body. The issue is done when return and the rest of the file receive correct syntax highlighting for this form, without breaking the existing case where the parameter list stays on one line.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.