-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Import type information only #5556
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
So you're not going for eliding modules, right? You're specifically trying to make it so that users don't accidentally use values withing a module? |
I tend to use import _atomUtils = require('../main/atom/atomUtils');
var atomUtils: typeof _atomUtils; Use case lazy loading Or I might have misunderstood the question 🌹 |
@basarat Absolutely correct, that's the same use-case I have with @DanielRosenwasser Yes, eliding modules works. But I need to be explicitly sure that I haven't accidentally used the value before it's been defined (E.g. guarantee that Edit: Also, yes, |
see #2812 for more details. |
Just realised Flow actually handles this and the syntax is identical: http://flowtype.org/blog/2015/02/18/Import-Types.html. |
There's a few other issues that touch on something similar (#5098, #278), but is there a way to explicitly import only type information from an external module? I imagine something like below, where there's a reserved word used to modify an existing import:
This construct would import type information only, and any runtime usage of the namespace in the current module could be considered an error. This is useful in a few place (E.g.
ts-node
andtsconfig
) where I need the type information from TypeScript, but I also need to guarantee that I don't accidentally import it as a dependency in the compiled output. Not sure if others have a similar use-case, but the reverse at least seems to be an issue (importing for side-effects only, which is optimized out by the compiler currently).The text was updated successfully, but these errors were encountered: