Skip to content
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

Cannot re-export type definitions #8

Closed
FrozenKiwi opened this issue Mar 23, 2019 · 4 comments
Closed

Cannot re-export type definitions #8

FrozenKiwi opened this issue Mar 23, 2019 · 4 comments

Comments

@FrozenKiwi
Copy link

I'm sure this is user-error, as I would think this is the most common use-case for this library.

I generate TS from spec, with output

 namespace MyLib {
    export interface ...
 }

Then compile & publish this as my own internal types definition to be included in other projects. However, I can't re-import - when importing the file I see "file is not a module"

To fix I manually add in an "export " at the start of the file:

export namespace MyLib { ... }

And this works.

Is this appropriate? Is there a better way to resolve this?

@drwpow
Copy link
Owner

drwpow commented Mar 25, 2019

@FrozenKiwi out of curiosity, what version of TypeScript are you using? In my projects on 3.3.3333 I’m able to use MyLib.interface without any importing/exporting.

@drwpow
Copy link
Owner

drwpow commented Mar 25, 2019

I should add that I typically place my specs inside the include path in tsconfig.json. I wonder if that makes a difference, too.

Either way, there seems to be a helpful step missing in the README for sure.

@drwpow
Copy link
Owner

drwpow commented Apr 19, 2019

@FrozenKiwi thanks to another contributor with this problem, you can now export the namespace by passing --export to the CLI (refer to the README). Update to the new npm version v1.1.3 to use this option. And let me know if this solves your problem!

@drwpow drwpow closed this as completed Apr 19, 2019
@FrozenKiwi
Copy link
Author

Oops - apologies for not replying: I had a bad filter on github for a while so missed all my notifications

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants