Skip to content

Commit

Permalink
parser: ignore type args in typeof
Browse files Browse the repository at this point in the history
This has become more and more common. This only implements it in the parser, no time to do it properly
  • Loading branch information
oyvindberg committed Oct 13, 2023
1 parent ba8e12d commit 2ad4b50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3330,4 +3330,11 @@ export {};
),
)
}

test("ignore type args in typeof") {
shouldParseAs(
"""typeof genComponentStyleHook<ComponentName>""".stripMargin,
TsParser.tsType,
)(TsTypeQuery(TsQIdent(IArray(TsIdentSimple("genComponentStyleHook")))))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class TsParser(path: Option[(os.Path, Int)]) extends StdTokenParsers with Parser
| tsTypeFunction
| ("abstract".isDefined <~ "new") ~ tsTypeFunction ^^ TsTypeConstructor
| "unique" ~> "symbol" ~> success(TsTypeRef(NoComments, TsQIdent.symbol, Empty))
| "typeof" ~> qualifiedIdent ^^ TsTypeQuery
| "typeof" ~> tsTypeRef ^^ { case TsTypeRef(_, name, _) => TsTypeQuery(name) } // todo: targs may be used to with `typoeof f<asd>`
| tsTypeTuple
| "(" ~> tsType <~ ")"
| tsLiteral ^^ TsTypeLiteral
Expand Down

0 comments on commit 2ad4b50

Please sign in to comment.