Skip to content

Commit bf3d21a

Browse files
committed
[javascript mode] Recognize TypeScript typeof in type position
Closes codemirror#5275
1 parent 2253635 commit bf3d21a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

mode/javascript/javascript.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -560,14 +560,13 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
560560
}
561561
}
562562
function typeexpr(type, value) {
563+
if (value == "keyof" || value == "typeof") {
564+
cx.marked = "keyword"
565+
return cont(value == "keyof" ? typeexpr : expression)
566+
}
563567
if (type == "variable" || value == "void") {
564-
if (value == "keyof") {
565-
cx.marked = "keyword"
566-
return cont(typeexpr)
567-
} else {
568-
cx.marked = "type"
569-
return cont(afterType)
570-
}
568+
cx.marked = "type"
569+
return cont(afterType)
571570
}
572571
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
573572
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)

0 commit comments

Comments
 (0)