@@ -159,6 +159,8 @@ export class LuaTransformer {
159159 return this . transformExportDeclaration ( node as ts . ExportDeclaration ) ;
160160 case ts . SyntaxKind . ImportDeclaration :
161161 return this . transformImportDeclaration ( node as ts . ImportDeclaration ) ;
162+ case ts . SyntaxKind . ImportEqualsDeclaration :
163+ return this . transformImportEqualsDeclaration ( node as ts . ImportEqualsDeclaration ) ;
162164 case ts . SyntaxKind . ClassDeclaration :
163165 return this . transformClassDeclaration ( node as ts . ClassDeclaration ) ;
164166 case ts . SyntaxKind . ModuleDeclaration :
@@ -458,6 +460,38 @@ export class LuaTransformer {
458460 }
459461 }
460462
463+ public transformImportEqualsDeclaration ( declaration : ts . ImportEqualsDeclaration ) : StatementVisitResult {
464+ const name = this . transformIdentifier ( declaration . name ) ;
465+ const expression = ts . isExternalModuleReference ( declaration . moduleReference )
466+ ? this . transformExternalModuleReference ( declaration . moduleReference )
467+ : this . transformEntityName ( declaration . moduleReference ) ;
468+
469+ return this . createHoistableVariableDeclarationStatement ( name , expression , declaration ) ;
470+ }
471+
472+ public transformExternalModuleReference (
473+ externalModuleReference : ts . ExternalModuleReference
474+ ) : ExpressionVisitResult {
475+ return tstl . createCallExpression (
476+ tstl . createIdentifier ( "require" ) ,
477+ [ this . transformExpression ( externalModuleReference . expression ) ] ,
478+ externalModuleReference
479+ ) ;
480+ }
481+
482+ private transformEntityName ( entityName : ts . EntityName ) : ExpressionVisitResult {
483+ return ts . isQualifiedName ( entityName )
484+ ? this . transformQualifiedName ( entityName )
485+ : this . transformIdentifierExpression ( entityName ) ;
486+ }
487+
488+ public transformQualifiedName ( qualifiedName : ts . QualifiedName ) : ExpressionVisitResult {
489+ const right = tstl . createStringLiteral ( this . getIdentifierText ( qualifiedName . right ) , qualifiedName . right ) ;
490+ const left = this . transformEntityName ( qualifiedName . left ) ;
491+
492+ return tstl . createTableIndexExpression ( left , right , qualifiedName ) ;
493+ }
494+
461495 public transformClassDeclaration (
462496 statement : ts . ClassLikeDeclaration ,
463497 nameOverride ?: tstl . Identifier
@@ -3755,7 +3789,7 @@ export class LuaTransformer {
37553789 }
37563790
37573791 public transformPropertyAccessExpression ( expression : ts . PropertyAccessExpression ) : ExpressionVisitResult {
3758- const property = expression . name . text ;
3792+ const property = this . getIdentifierText ( expression . name ) ;
37593793
37603794 // Check for primitive types to override
37613795 const type = this . checker . getTypeAtLocation ( expression . expression ) ;
0 commit comments