@@ -345,15 +345,14 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
345345 if ( type == "for" ) return cont ( pushlex ( "form" ) , forspec , statement , poplex ) ;
346346 if ( type == "class" || ( isTS && value == "interface" ) ) { cx . marked = "keyword" ; return cont ( pushlex ( "form" ) , className , poplex ) ; }
347347 if ( type == "variable" ) {
348- if ( isTS && value == "type" ) {
349- cx . marked = "keyword"
350- return cont ( typeexpr , expect ( "operator" ) , typeexpr , expect ( ";" ) ) ;
351- } else if ( isTS && value == "declare" ) {
348+ if ( isTS && value == "declare" ) {
352349 cx . marked = "keyword"
353350 return cont ( statement )
354- } else if ( isTS && ( value == "module" || value == "enum" ) && cx . stream . match ( / ^ \s * \w / , false ) ) {
351+ } else if ( isTS && ( value == "module" || value == "enum" || value == "type" ) && cx . stream . match ( / ^ \s * \w / , false ) ) {
355352 cx . marked = "keyword"
356- return cont ( pushlex ( "form" ) , pattern , expect ( "{" ) , pushlex ( "}" ) , block , poplex , poplex )
353+ if ( value == "enum" ) return cont ( enumdef ) ;
354+ else if ( value == "type" ) return cont ( typeexpr , expect ( "operator" ) , typeexpr , expect ( ";" ) ) ;
355+ else return cont ( pushlex ( "form" ) , pattern , expect ( "{" ) , pushlex ( "}" ) , block , poplex , poplex )
357356 } else if ( isTS && value == "namespace" ) {
358357 cx . marked = "keyword"
359358 return cont ( pushlex ( "form" ) , expression , block , poplex )
@@ -608,7 +607,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
608607 function maybeTypeDefault ( _ , value ) {
609608 if ( value == "=" ) return cont ( typeexpr )
610609 }
611- function vardef ( ) {
610+ function vardef ( _ , value ) {
611+ if ( value == "enum" ) { cx . marked = "keyword" ; return cont ( enumdef ) }
612612 return pass ( pattern , maybetype , maybeAssign , vardefCont ) ;
613613 }
614614 function pattern ( type , value ) {
@@ -680,8 +680,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
680680 }
681681 function classNameAfter ( type , value ) {
682682 if ( value == "<" ) return cont ( pushlex ( ">" ) , commasep ( typeparam , ">" ) , poplex , classNameAfter )
683- if ( value == "extends" || value == "implements" || ( isTS && type == "," ) )
683+ if ( value == "extends" || value == "implements" || ( isTS && type == "," ) ) {
684+ if ( value == "implements" ) cx . marked = "keyword" ;
684685 return cont ( isTS ? typeexpr : expression , classNameAfter ) ;
686+ }
685687 if ( type == "{" ) return cont ( pushlex ( "}" ) , classBody , poplex ) ;
686688 }
687689 function classBody ( type , value ) {
@@ -745,6 +747,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
745747 if ( type == "]" ) return cont ( ) ;
746748 return pass ( commasep ( expressionNoComma , "]" ) ) ;
747749 }
750+ function enumdef ( ) {
751+ return pass ( pushlex ( "form" ) , pattern , expect ( "{" ) , pushlex ( "}" ) , commasep ( enummember , "}" ) , poplex , poplex )
752+ }
753+ function enummember ( ) {
754+ return pass ( pattern , maybeAssign ) ;
755+ }
748756
749757 function isContinuedStatement ( state , textAfter ) {
750758 return state . lastType == "operator" || state . lastType == "," ||
0 commit comments