Skip to content

Commit 82d1245

Browse files
committed
[javascript mode] Fix typescript [key in ...] syntax (again)
Issue #5737 Issue #5909
1 parent 306c38e commit 82d1245

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mode/javascript/javascript.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
525525
cx.marked = "keyword"
526526
return cont(objprop)
527527
} else if (type == "[") {
528-
return cont(expression, maybetype, expect("]"), afterprop);
528+
return cont(expression, maybetypeOrIn, expect("]"), afterprop);
529529
} else if (type == "spread") {
530530
return cont(expressionNoComma, afterprop);
531531
} else if (value == "*") {
@@ -578,6 +578,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
578578
if (value == "?") return cont(maybetype);
579579
}
580580
}
581+
function maybetypeOrIn(type, value) {
582+
if (isTS && (type == ":" || value == "in")) return cont(typeexpr)
583+
}
581584
function mayberettype(type) {
582585
if (isTS && type == ":") {
583586
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)

0 commit comments

Comments
 (0)