-
-
Notifications
You must be signed in to change notification settings - Fork 672
Namespaces for types don't work #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note that if I have a type in separate module and try to do: import * as Outer from "./outer"; I also get compilation problem when I try to use |
@dcodeIO looks like first issue is gone, but issue remains with: import * as Outer from "./outer"; |
What's the complete code there? Asking because the // a.ts
export namespace Outer {
export class Inner {
}
} // b.ts
import * as A from "./a";
A.Outer.Inner; // ?
|
@dcodeIO sorry, here's working example: |
Thanks, I see now. Doesn't seem that there's a super easy fix for this. The elements map only contains the filespace, but there are no (recursive) aliases of its children which could be looked up by a simple string search. What we'd need instead is a multi-level map to be able to resolve symbols at specific points in the tree without having to rely on a global map, hmm... |
@dcodeIO what does happen when I have, say:
and then use |
@dcodeIO BTW, looks like this only fails for variable declaration, but works for usage in function types and params. These seem to compile fine: function cannotReturn(): Outer.Inner {
}
function cannotTakeAargument(arg: Outer.Inner): void {
} but this fails: let cannotDeclareVariable: Outer.Inner = null; EDIT: Looks they actually also fail once you try calling functions. |
Importing and renaming individual classes works apparently, see: So basically for now just gonna do stuff like: import {Inner as Outer_Inner} from "./outer"; However I feel that it's better to just give compiler error on: import * as whatever from "./module"; Then it'll be clearly marked as unsupported feature, cause right now it's not clear what's going on – it only works for some isolated cases. |
Required some hackery cause cannot import module as a whole, see: AssemblyScript#423
Required some hackery cause cannot import module as a whole, see: AssemblyScript#423
Will keep this in mind while switching to symbol tables in #424. Going to implement proper tree-based lookups there. |
Closing in favor of #473, which is our tracking issue for similar related issues now. |
See https://studio.nearprotocol.com/?f=XfZ2mUv for working example.
Basically if you have:
it doesn't look that any references to
Inner
actually work.E.g. none of these compile so far:
Do you have any suggestion on how to fix this?
The text was updated successfully, but these errors were encountered: