Syntax highlighting fails in TypeScript files when generics contain array types
Categories
(DevTools :: Debugger, defect, P3)
Tracking
(Not tracked)
People
(Reporter: pixelscript, Unassigned, NeedInfo)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
|
138.45 KB,
image/png
|
Details |
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:
- An inline type declaration for a variable
- The type being declared has a generic variable
- The generic variable is of an array type using the square bracket syntax
- 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.
Comment 1•1 month ago
|
||
The severity field is not set for this bug.
:bomsy, could you have a look please?
For more information, please visit BugBot documentation.
Comment 2•1 month ago
|
||
Might be related to codemirror 6 migration, do we still explicitly support typescript syntax highlighting?
Description
•