-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 use typeof
on an empty module
#3053
Comments
This is the difference between an instantiated module (one that has at least one value, or executable code, in it) and an uninstantiated module (which only has types or other uninstantiated modules in it). It's meaningless to say If you want to make
Can you clarify this? If the compiler can't see those other files, it's meaningless to write |
The use case is to capture the shape of an existing module and to ensure that we get a compilation error if the shape of the original module changes: // Original
module foo {
export module empty {
}
}
// Copy
interface Copy {
foo: {
empty: typeof foo.empty;
}
}
That's a rather strange argument. What if someone were to add a type to the empty module at a later stage? We'd have to go change all the references. I took a look at #420, but wasn't certain that would cover the case. In any case to the naked eye this looks like a bug. |
looks like #420 would address the underlying issue. |
Hi,
TS: 1.4/1.5
In the following, the compiler issues an error on the last line:
This has turned out to be a problem for the case when a module is defined across multiple files. For certain references the module will be empty, as it is initialised in a different context.
Why do we have no error for
bar
but an error forempty
?The text was updated successfully, but these errors were encountered: