From 3a07f675bb80828d2c305a7376cb30eeb21d6aad Mon Sep 17 00:00:00 2001 From: supertree-wook <88178296+st-Wook@users.noreply.github.com> Date: Thu, 25 Apr 2024 21:39:13 +0900 Subject: [PATCH] Fix `Error: Negative numbers should be created in combination with createPrefixUnaryExpression` (#46) * Fix error * Fix * Apply @Fireboltofdeath comment --- src/util/factory.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/factory.ts b/src/util/factory.ts index 079fcc4..078b8a4 100644 --- a/src/util/factory.ts +++ b/src/util/factory.ts @@ -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) {