Skip to content

Commit 2cb90ec

Browse files
committed
[javascript mode] Highlight type in generic call
Closes codemirror#5048.
1 parent b881f25 commit 2cb90ec

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

mode/javascript/javascript.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
438438
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
439439
if (type == "operator") {
440440
if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
441+
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, maybeoperatorNoComma);
441442
if (value == "?") return cont(expression, expect(":"), expr);
442443
return cont(expr);
443444
}

mode/javascript/test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@
371371
TS("arrow prop",
372372
"({[property a]: [def p] [operator =>] [variable-2 p]})")
373373

374+
TS("generic in function call",
375+
"[keyword this].[property a][operator <][type Type][operator >]([variable foo]);")
376+
374377
var jsonld_mode = CodeMirror.getMode(
375378
{indentUnit: 2},
376379
{name: "javascript", jsonld: true}

0 commit comments

Comments
 (0)