Skip to content

Commit bcb8626

Browse files
lukehaasmarijnh
authored andcommitted
[jsx mode] Support trailing-comma generics syntax in JSX with TS
Issue #7073
1 parent 2329ebb commit bcb8626

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

mode/jsx/jsx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
}
104104

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

mode/jsx/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,6 @@
9595
"[bracket&tag <][tag MyComponent] [attribute foo]=[string \"bar\"] [bracket&tag />]; [comment //ok]",
9696
"[bracket&tag <][tag MyComponent] [attribute foo]={[number 0]} [bracket&tag />]; [comment //error]")
9797

98+
TS("tsx_react_generics",
99+
"[variable x] [operator =] [operator <] [variable T],[operator >] ([def v]: [type T]) [operator =>] [variable-2 v];")
98100
})()

0 commit comments

Comments
 (0)