Skip to content

Commit 073592d

Browse files
committed
Use collectCustomDecorators and remove isNonNamespaceModuleDeclaration
1 parent 0dd855d commit 073592d

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

src/LuaTransformer.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from "path";
22
import * as ts from "typescript";
33
import { CompilerOptions, LuaTarget } from "./CompilerOptions";
4-
import { DecoratorKind } from "./Decorator";
4+
import { Decorator, DecoratorKind } from "./Decorator";
55
import * as tstl from "./LuaAST";
66
import { LuaLibFeature } from "./LuaLib";
77
import { ContextType, TSHelper as tsHelper } from "./TSHelper";
@@ -360,17 +360,10 @@ export class LuaTransformer {
360360
let shouldResolve = true;
361361
const moduleOwnerSymbol = this.checker.getSymbolAtLocation(statement.moduleSpecifier);
362362
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-
}
363+
const decMap = new Map<DecoratorKind, Decorator>();
364+
tsHelper.collectCustomDecorators(moduleOwnerSymbol, this.checker, decMap);
365+
if (decMap.has(DecoratorKind.NoResolution)) {
366+
shouldResolve = false;
374367
}
375368
}
376369

src/TSHelper.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ export class TSHelper {
131131
return !((ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Ambient) === 0);
132132
}
133133

134-
public static isNonNamespaceModuleDeclaration(node: ts.Node): node is ts.ModuleDeclaration {
135-
return ts.isModuleDeclaration(node) && (node.flags & ts.NodeFlags.Namespace) === 0;
136-
}
137-
138134
public static isStatic(node: ts.Node): boolean {
139135
return node.modifiers !== undefined && node.modifiers.some(m => m.kind === ts.SyntaxKind.StaticKeyword);
140136
}

0 commit comments

Comments
 (0)