You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Baz}from'./b.js'letx: Baz.Foo.Bar// should compile without error
Actual behavior:
import{Baz}from'./b.js'letx: Baz.Foo.Bar// Error: Namespace '".../b".Baz' has no exported member 'Foo'.lety=newBaz.Foo.Bar// Ok
Playground Link:
I am unsure how to use TypeScript Playground to import custom modules.
Related Issues:
Merging constants with namespaces seems to be a fundamentally different issue, as there is a symbol conflict. Here that shouldn't be the case.
Embedding types in namespace declarations also appears to be a different issue, as in this case it is the namespace itself not being recognised as a valid token in the type.
Stack overflow question I raised in trying to determine if this is a bug or expected behaviour.
The text was updated successfully, but these errors were encountered:
This is not surprising, since namespaces aren't types themselves, so can't be exported as types and therefore the nested types are lost.
import{FooasFooImpl}from'./a.js'exportnamespaceBaz{exportconstFoo=FooImpl//export type Foo = FooImpl <-- can't do this, since namespaces aren't types//export namespace Foo = FooImpl <-- can't do this, since namespaces can't be assigned}
However, since the members can be accessed as values, they should also be accessible as types.
You can use export import Foo = a.FooImpl with a qualified name (so use a top-level module import to a instead of destructring) if this is what you want to happen
I note I was not able to find the export import syntax anywhere in the TypeScript documentation. Now I know what to look for, this appears to be a duplicate of issue 10058. I will close this and also update my Stack Overflow question with the answer.
TypeScript Version: 3.8.0-dev.20191116
Search Terms:
Code
a.ts:
b.ts:
Expected behavior:
Actual behavior:
Playground Link:
I am unsure how to use TypeScript Playground to import custom modules.
Related Issues:
The text was updated successfully, but these errors were encountered: