File tree Expand file tree Collapse file tree 4 files changed +59
-0
lines changed
__tests__/fixtures/ts-static-const-arrow-function-return-type Expand file tree Collapse file tree 4 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " htmljs-parser " : patch
3+ ---
4+
5+ Fix issue where arrow functions content was being parsed as types.
Original file line number Diff line number Diff line change 1+ 1╭─ static const a = (a: number, b: number): string => {
2+ ╰─ ╰─ tagName "static"
3+ 2├─ if (a < b) {
4+ 3├─ return "foo";
5+ 4├─ } else {
6+ 5├─ return "bar";
7+ 6├─ }
8+ 7├─ };
9+ 8╭─
10+ ╰─ ╰─ openTagEnd
11+ 9╭─ static const b = (a: number, b: number): () => string => () => {
12+ ╰─ ╰─ tagName "static"
13+ 10├─ if (a < b) {
14+ 11├─ return "foo";
15+ 12├─ } else {
16+ 13├─ return "bar";
17+ 14├─ }
18+ 15├─ };
19+ 16╭─
20+ ╰─ ╰─ openTagEnd
21+ 17╭─ static const c = (a: number, b: number): string => a < b ? "foo" : "bar";
22+ ╰─ ╰─ tagName "static"
23+ 18╭─
24+ ╰─ ╰─ openTagEnd
25+ 19╭─ static const d = (a: number, b: number): () => string => () => a < b ? "foo" : "bar";
26+ ╰─ ╰─ tagName "static"
27+ 20╭─
28+ ╰─ ╰─ openTagEnd
Original file line number Diff line number Diff line change 1+ static const a = (a : number , b : number ): string => {
2+ if (a < b ) {
3+ return " foo" ;
4+ } else {
5+ return " bar" ;
6+ }
7+ };
8+
9+ static const b = (a : number , b : number ): () => string => () => {
10+ if (a < b ) {
11+ return " foo" ;
12+ } else {
13+ return " bar" ;
14+ }
15+ };
16+
17+ static const c = (a : number , b : number ): string => a < b ? " foo" : " bar" ;
18+
19+ static const d = (a : number , b : number ): () => string => () => a < b ? " foo" : " bar" ;
Original file line number Diff line number Diff line change @@ -150,6 +150,13 @@ export const EXPRESSION: StateDefinition<ExpressionMeta> = {
150150 case CODE . EQUAL :
151151 if ( expression . operators ) {
152152 if ( this . lookAtCharCodeAhead ( 1 ) === CODE . CLOSE_ANGLE_BRACKET ) {
153+ if (
154+ expression . inType &&
155+ ! expression . forceType &&
156+ this . getPreviousNonWhitespaceCharCode ( ) !== CODE . CLOSE_PAREN
157+ ) {
158+ expression . inType = false ;
159+ }
153160 this . pos ++ ;
154161 } else if ( ! ( expression . forceType || expression . groupStack . length ) ) {
155162 expression . inType = false ;
You can’t perform that action at this time.
0 commit comments