[jsx mode] Support trailing-comma generics syntax in JSX with TS

Issue https://github.com/codemirror/codemirror5/pull/7073
This commit is contained in:
Luke Haas 2023-10-25 17:13:13 +01:00 committed by Marijn Haverbeke
parent 2329ebb19b
commit bcb86262e8
2 changed files with 3 additions and 1 deletions

View File

@ -103,7 +103,7 @@
}
function jsToken(stream, state, cx) {
if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) {
if (stream.peek() == "<" && !/,\s*>/.test(stream.string) && jsMode.expressionAllowed(stream, cx.state)) {
state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "", "")),
xmlMode, 0, state.context)
jsMode.skipExpression(cx.state)

View File

@ -95,4 +95,6 @@
"[bracket&tag <][tag MyComponent] [attribute foo]=[string \"bar\"] [bracket&tag />]; [comment //ok]",
"[bracket&tag <][tag MyComponent] [attribute foo]={[number 0]} [bracket&tag />]; [comment //error]")
TS("tsx_react_generics",
"[variable x] [operator =] [operator <] [variable T],[operator >] ([def v]: [type T]) [operator =>] [variable-2 v];")
})()