Skip to content

Commit 24cd553

Browse files
committed
Fixed -Infinity case
1 parent ed2cc57 commit 24cd553

File tree

1 file changed

+5
-3
lines changed
  • src/compiler/transformers

1 file changed

+5
-3
lines changed

src/compiler/transformers/ts.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,9 +1898,11 @@ export function transformTypeScript(context: TransformationContext) {
18981898
: factory.createBinaryExpression(factory.createNumericLiteral(0), SyntaxKind.SlashToken, factory.createNumericLiteral(0));
18991899
}
19001900
if (!isFinite(value)) {
1901-
return resolver.isNameReferencingGlobalValueAtLocation("Infinity", member)
1902-
? factory.createIdentifier("Infinity")
1903-
: factory.createBinaryExpression(value < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(1)) : factory.createNumericLiteral(1), SyntaxKind.SlashToken, factory.createNumericLiteral(0));
1901+
if (resolver.isNameReferencingGlobalValueAtLocation("Infinity", member)) {
1902+
return value < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createIdentifier("Infinity")) : factory.createIdentifier("Infinity");
1903+
}
1904+
const dividend = value < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(1)) : factory.createNumericLiteral(1);
1905+
return factory.createBinaryExpression(dividend, SyntaxKind.SlashToken, factory.createNumericLiteral(0));
19041906
}
19051907
return factory.createNumericLiteral(value);
19061908
}

0 commit comments

Comments
 (0)