@@ -357,11 +357,28 @@ export class LuaTransformer {
357357 scope . importStatements = [ ] ;
358358 }
359359
360+ let shouldResolve = true ;
361+ const moduleOwnerSymbol = this . checker . getSymbolAtLocation ( statement . moduleSpecifier ) ;
362+ if ( moduleOwnerSymbol ) {
363+ for ( const declaration of moduleOwnerSymbol . declarations ) {
364+ if ( tsHelper . isNonNamespaceModuleDeclaration ( declaration ) ) {
365+ const type = this . checker . getTypeAtLocation ( declaration ) ;
366+ if ( type ) {
367+ const decorators = tsHelper . getCustomDecorators ( type , this . checker ) ;
368+ if ( decorators . has ( DecoratorKind . NoResolution ) ) {
369+ shouldResolve = false ;
370+ break ;
371+ }
372+ }
373+ }
374+ }
375+ }
376+
360377 const moduleSpecifier = statement . moduleSpecifier as ts . StringLiteral ;
361378 const importPath = moduleSpecifier . text . replace ( new RegExp ( '"' , "g" ) , "" ) ;
379+ const requireCall = this . createModuleRequire ( statement . moduleSpecifier as ts . StringLiteral , shouldResolve ) ;
362380
363381 if ( ! statement . importClause ) {
364- const requireCall = this . createModuleRequire ( statement . moduleSpecifier as ts . StringLiteral ) ;
365382 result . push ( tstl . createExpressionStatement ( requireCall ) ) ;
366383 if ( scope . importStatements ) {
367384 scope . importStatements . push ( ...result ) ;
@@ -376,28 +393,6 @@ export class LuaTransformer {
376393 throw TSTLErrors . UnsupportedImportType ( statement . importClause ) ;
377394 }
378395
379- let shouldResolve = true ;
380- if ( ts . isNamedImports ( imports ) ) {
381- for ( const importSpecifier of imports . elements ) {
382- const parentModule = tsHelper . getImportSpecifierModuleDeclaration ( importSpecifier , this . checker ) ;
383- if ( parentModule ) {
384- const type = this . checker . getTypeAtLocation ( parentModule ) ;
385- const decorators = tsHelper . getCustomDecorators ( type , this . checker ) ;
386- if ( decorators . has ( DecoratorKind . NoResolution ) ) {
387- shouldResolve = false ;
388- break ;
389- }
390- }
391- }
392- } else if ( ts . isNamespaceImport ( imports ) ) {
393- const type = this . checker . getTypeAtLocation ( imports ) ;
394- if ( tsHelper . getCustomDecorators ( type , this . checker ) . has ( DecoratorKind . NoResolution ) ) {
395- shouldResolve = false ;
396- }
397- }
398-
399- const requireCall = this . createModuleRequire ( statement . moduleSpecifier as ts . StringLiteral , shouldResolve ) ;
400-
401396 if ( ts . isNamedImports ( imports ) ) {
402397 const filteredElements = imports . elements . filter ( e => {
403398 const decorators = tsHelper . getCustomDecorators ( this . checker . getTypeAtLocation ( e ) , this . checker ) ;
0 commit comments