@@ -572,6 +572,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
572572 if ( type == "[" ) return cont ( pushlex ( "]" ) , commasep ( typeexpr , "]" , "," ) , poplex , afterType )
573573 if ( type == "{" ) return cont ( pushlex ( "}" ) , commasep ( typeprop , "}" , ",;" ) , poplex , afterType )
574574 if ( type == "(" ) return cont ( commasep ( typearg , ")" ) , maybeReturnType )
575+ if ( type == "<" ) return cont ( commasep ( typeexpr , ">" ) , typeexpr )
575576 }
576577 function maybeReturnType ( type ) {
577578 if ( type == "=>" ) return cont ( typeexpr )
@@ -588,9 +589,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
588589 return cont ( expression , maybetype , expect ( "]" ) , typeprop )
589590 }
590591 }
591- function typearg ( type ) {
592- if ( type == "variable" ) return cont ( typearg )
593- else if ( type == ":" ) return cont ( typeexpr )
592+ function typearg ( type , value ) {
593+ if ( type == "variable" && cx . stream . match ( / ^ \s * [ ? : ] / , false ) || value == "?" ) return cont ( typearg )
594+ if ( type == ":" ) return cont ( typeexpr )
595+ return pass ( typeexpr )
594596 }
595597 function afterType ( type , value ) {
596598 if ( value == "<" ) return cont ( pushlex ( ">" ) , commasep ( typeexpr , ">" ) , poplex , afterType )
0 commit comments