Skip to content

Commit

Permalink
tsparser: handle unary plus and minus
Browse files Browse the repository at this point in the history
  • Loading branch information
eandre committed Jun 8, 2024
1 parent 6f1d8de commit fd5f92c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tsparser/src/parser/types/type_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,13 @@ impl<'a> Ctx<'a> {
// See https://www.typescriptlang.org/docs/handbook/2/typeof-types.html
ast::UnaryOp::TypeOf => Type::Basic(Basic::String),

ast::UnaryOp::Minus
| ast::UnaryOp::Plus
| ast::UnaryOp::Bang
ast::UnaryOp::Plus => Type::Basic(Basic::Number),
ast::UnaryOp::Minus => match self.expr(&expr.arg) {
Type::Literal(Literal::Number(num)) => Type::Literal(Literal::Number(-num)),
other => other,
},

ast::UnaryOp::Bang
| ast::UnaryOp::Tilde
| ast::UnaryOp::Delete => self.expr(&expr.arg),
},
Expand Down

0 comments on commit fd5f92c

Please sign in to comment.