Open Bug 2075755 Opened 2 months ago Updated 1 month ago

Syntax highlighting fails in TypeScript files when generics contain array types

Categories

(DevTools :: Debugger, defect, P3)

Firefox 153
defect

Tracking

(Not tracked)

People

(Reporter: pixelscript, Unassigned, NeedInfo)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached image example.png —

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:153.0) Gecko/20100101 Firefox/153.0

Steps to reproduce

Example TypeScript code:

// Declaring it first and then assigning is OK.
let test1: Map<string, number[]>;
test1 = new Map();

// Declaring and assigning with primitives is OK.
const test2: Map<string, string> = new Map();

// If the array type is not the first one, it's interesting.
const test3: Map<number[], string> = new Map();
//               |------|-< portion remains unhighlighted, rest is fine

// Aliasing the array type makes it OK
type Alias = number[];
const test4: Map<string, Alias> = new Map();

// Array type last causes breakage
const test5: Map<string, number[]> = new Map();
//                               ^ Highlight breaks here

// Sample code, not highlighted correctly
const lorem = 'ipsum';
if (lorem) {
    const a = 10 + 5;
    const b = -2;
    const c = a - b;
    console.log(c);
} else {
    console.log('Test code');
}

// Similar code repeated causes highlighting to return...
const test5Again: Map<string, number[]> = new Map();
//                    ^ Highlight returns here

// More sample code, highlighting restored
const ipsum = 'lorem';
if (ipsum) {
    const et = 'cetera';
} else {
    // pass
}

Run this through a TypeScript compiler with the sourceMaps flag set. Then, embed into a test web page, open it in Firefox, and inspect with the debugger.

Actual results

Certain constructions of correct TypeScript syntax break syntax highlighting, along with on-hover tooltips in the regions where highlighting is broken during breakpoint stepping.

Seems to happen particularly when all of the following features occur within the same line:

  1. An inline type declaration for a variable
  2. The type being declared has a generic variable
  3. The generic variable is of an array type using the square bracket syntax
  4. The declared variable is being assigned

Furthermore, if the breakage occurs twice in the same file, syntax highlighting resumes.

See screenshot for the results of the sample code.

Expected results

Syntax should be highlighted correctly, and breakpoint tooltips should function correctly.

The severity field is not set for this bug.
:bomsy, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(hmanilla)

Might be related to codemirror 6 migration, do we still explicitly support typescript syntax highlighting?

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: