Skip to content

Commit 9bf68be

Browse files
committed
fix: arrow fn in type args/params
1 parent a8a87bc commit 9bf68be

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

.changeset/tired-results-taste.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"htmljs-parser": patch
3+
---
4+
5+
Fix issue with arrow functions in type args/params.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
1╭─ <foo<{ bar: () => void }>/>
2+
│ ││ ││ ╰─ openTagEnd:selfClosed "/>"
3+
│ ││ │╰─ tagTypeArgs.value "{ bar: () => void }"
4+
│ ││ ╰─ tagTypeArgs "<{ bar: () => void }>"
5+
│ │╰─ tagName "foo"
6+
╰─ ╰─ openTagStart
7+
2╰─
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<foo<{ bar: () => void }>/>

src/states/EXPRESSION.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,16 @@ export const EXPRESSION: StateDefinition<ExpressionMeta> = {
212212
case CODE.CLOSE_PAREN:
213213
case CODE.CLOSE_SQUARE_BRACKET:
214214
case CODE.CLOSE_CURLY_BRACE:
215-
case expression.inType && CODE.CLOSE_ANGLE_BRACKET: {
215+
case CODE.CLOSE_ANGLE_BRACKET: {
216+
if (code === CODE.CLOSE_ANGLE_BRACKET) {
217+
if (
218+
!expression.inType ||
219+
this.lookAtCharCodeAhead(-1) === CODE.EQUAL
220+
) {
221+
break;
222+
}
223+
}
224+
216225
if (!expression.groupStack.length) {
217226
return this.emitError(
218227
expression,

0 commit comments

Comments
 (0)