Skip to content

Commit

Permalink
Fix `Error: Negative numbers should be created in combination with cr…
Browse files Browse the repository at this point in the history
…eatePrefixUnaryExpression` (#46)

* Fix error

* Fix

* Apply @Fireboltofdeath comment
  • Loading branch information
st-Wook authored Apr 25, 2024
1 parent c188370 commit 3a07f67
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/util/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export namespace f {
}

export function number(value: number | string, flags?: ts.TokenFlags) {
return factory.createNumericLiteral(value, flags);
return +value < 0
? factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, factory.createNumericLiteral(-value, flags))
: factory.createNumericLiteral(value, flags);
}

export function identifier(name: string, unique = false) {
Expand Down

0 comments on commit 3a07f67

Please sign in to comment.