Fix noResolution for named imports#636
Conversation
src/LuaTransformer.ts
Outdated
| const shouldResolve = !tsHelper.getCustomDecorators(type, this.checker).has(DecoratorKind.NoResolution); | ||
| let shouldResolve = true; | ||
| if (ts.isNamedImports(imports)) { | ||
| for (const importSpecifier of imports.elements) { |
There was a problem hiding this comment.
I don't think we can rely on elements there. First, what about import {} from "fake"? Second, I'm not sure if that would work with re-exporting.
We also have to consider a case when we have no elements to check: import "fake".
I think we should check out the actual type of module, not types of imported elements. I'm not really sure how to do it, but editors that use TSLS seem to have resolved module path on hover, so type checker should have it
There was a problem hiding this comment.
Thanks for the hand! I can't think of a way to test import {} from "fake" but I've got import "fake" validated by two new tests.
Also using this.checker.getSymbolAtLocation(statement.moduleSpecifier) looks much more reliable
|
Looks like we can use |
|
I've removed the This directive can technically be used on a |
src/LuaTransformer.ts
Outdated
| let shouldResolve = true; | ||
| const moduleOwnerSymbol = this.checker.getSymbolAtLocation(statement.moduleSpecifier); | ||
| if (moduleOwnerSymbol) { | ||
| const decMap = new Map<DecoratorKind, Decorator>(); |
There was a problem hiding this comment.
Don't abbreviate variable names please.
2231cc3 to
37a6fbe
Compare
Closes #635
@noResolutionshould still only be applicable to ambient modules.If a module is merged with another and one has a
@noResolution, no path resolution will be performed.