microsoft / microsoft/TypeScript-TmLanguage

TS Syntax highlight broken for multiline generic arguments of function in object

Open
#1,028 3 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

Type: Bug

When having a function with generic type params in an object and the generic type params wrap into multiple lines, the TS syntax highlighting is broken.

To reproduce, just paste the following code in a .ts file and see the broken output:

const myObj = {
  test<
    A extends Record<string, any>,
    C extends Record<string, any>,
    B extends Record<string, any>,
  >(a: A, b: B, c: C): Record<string, any>[] {
    if ('hello' in a) {
      console.log('Test');
    }
    return [a, b, c];
  },
};

For reference, I added the same function but outside of the object which shows the correct/broken highlight in comparison:
image

VS Code version: Code 1.88.1 (e170252f762678dec6ca2cc69aba1570769a5d39, 2024-04-10T17:42:52.765Z)
OS version: Darwin x64 22.6.0
Modes:

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

Reproduce the issue in a TypeScript file using the supplied object and multiline generic-function example, comparing it with the standalone function. Inspect the TypeScript TextMate grammar files for the rules handling generic arguments inside object members; done means the multiline version receives the same correct highlighting as the standalone function.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.