Skip to content

Commit

Permalink
[javascript mode] Fix typescript [key in ...] syntax (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh authored and cone56 committed Jan 6, 2020
1 parent 750c7fe commit c4d8d5d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mode/javascript/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
cx.marked = "keyword"
return cont(objprop)
} else if (type == "[") {
return cont(expression, maybetype, expect("]"), afterprop);
return cont(expression, maybetypeOrIn, expect("]"), afterprop);
} else if (type == "spread") {
return cont(expressionNoComma, afterprop);
} else if (value == "*") {
Expand Down Expand Up @@ -578,6 +578,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (value == "?") return cont(maybetype);
}
}
function maybetypeOrIn(type, value) {
if (isTS && (type == ":" || value == "in")) return cont(typeexpr)
}
function mayberettype(type) {
if (isTS && type == ":") {
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
Expand Down

0 comments on commit c4d8d5d

Please sign in to comment.