Skip to content

Commit

Permalink
[jsx mode] Support trailing-comma generics syntax in JSX with TS
Browse files Browse the repository at this point in the history
Issue #7073
  • Loading branch information
lukehaas authored and marijnh committed Oct 27, 2023
1 parent 2329ebb commit bcb8626
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mode/jsx/jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions mode/jsx/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];")
})()

0 comments on commit bcb8626

Please sign in to comment.