@@ -60,6 +60,16 @@ export function createShorthandIdentifier(
6060 return identifier ;
6161}
6262
63+ const transformNumericLiteralExpression : FunctionVisitor < ts . NumericLiteral > = expression => {
64+ if ( expression . text === "Infinity" ) {
65+ const math = lua . createIdentifier ( "math" ) ;
66+ const huge = lua . createStringLiteral ( "huge" ) ;
67+ return lua . createTableIndexExpression ( math , huge , expression ) ;
68+ }
69+
70+ return lua . createNumericLiteral ( Number ( expression . text ) , expression ) ;
71+ } ;
72+
6373const transformObjectLiteralExpression : FunctionVisitor < ts . ObjectLiteralExpression > = ( expression , context ) => {
6474 let properties : lua . TableFieldExpression [ ] = [ ] ;
6575 const tableExpressions : lua . Expression [ ] = [ ] ;
@@ -142,7 +152,7 @@ export const literalVisitors: Visitors = {
142152 [ ts . SyntaxKind . NullKeyword ] : node => lua . createNilLiteral ( node ) ,
143153 [ ts . SyntaxKind . TrueKeyword ] : node => lua . createBooleanLiteral ( true , node ) ,
144154 [ ts . SyntaxKind . FalseKeyword ] : node => lua . createBooleanLiteral ( false , node ) ,
145- [ ts . SyntaxKind . NumericLiteral ] : node => lua . createNumericLiteral ( Number ( node . text ) , node ) ,
155+ [ ts . SyntaxKind . NumericLiteral ] : transformNumericLiteralExpression ,
146156 [ ts . SyntaxKind . StringLiteral ] : node => lua . createStringLiteral ( node . text , node ) ,
147157 [ ts . SyntaxKind . NoSubstitutionTemplateLiteral ] : node => lua . createStringLiteral ( node . text , node ) ,
148158 [ ts . SyntaxKind . ObjectLiteralExpression ] : transformObjectLiteralExpression ,
0 commit comments