Skip to content

Commit c3bf712

Browse files
committed
[javascript mode] Support TypeScript-style type casts
Issue codemirror#4759
1 parent 84b9ae4 commit c3bf712

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

mode/javascript/javascript.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
6161
"protected": kw("modifier"),
6262
"abstract": kw("modifier"),
6363

64-
// operators
65-
"as": operator,
66-
6764
// types
6865
"string": type, "number": type, "boolean": type, "any": type
6966
};
@@ -439,6 +436,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
439436
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
440437
if (type == ".") return cont(property, me);
441438
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
439+
if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
442440
}
443441
function quasi(type, value) {
444442
if (type != "quasi") return pass();

0 commit comments

Comments
 (0)