mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(parser): don't parse null as a literal type (#2572)
See playgrounds:
-
[oxc](https://oxc-project.github.io/oxc/playground/?code=3YCAAIDbgICAgICAgIC6nsrEgteLFrCnQnPuEizmC%2BDQ8C8bP9fXPj%2B7%2FjjmRZPvpAH3N7PfIPDu7RDOlrl79cHiork8WA08r39%2FqpCAgA%3D%3D)
-
[Babel](3a263be55b)
This commit is contained in:
parent
ad8ca2a066
commit
8a81851bf3
1 changed files with 2 additions and 1 deletions
|
|
@ -397,7 +397,8 @@ impl<'a> ParserImpl<'a> {
|
|||
Kind::Import => self.parse_ts_import_type(),
|
||||
Kind::Minus if self.peek_kind().is_number() => self.parse_ts_literal_type(),
|
||||
Kind::Question => self.parse_js_doc_unknown_or_nullable_type(),
|
||||
kind if kind.is_literal() => self.parse_ts_literal_type(),
|
||||
// null should not be parsed as a literal type
|
||||
kind if kind.is_literal() && kind != Kind::Null => self.parse_ts_literal_type(),
|
||||
_ => {
|
||||
if !self.peek_at(Kind::Dot) {
|
||||
let keyword = self.parse_ts_keyword_type();
|
||||
|
|
|
|||
Loading…
Reference in a new issue