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
{{ message }}
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
When I try to import this, I get a TS 2497 error at the import site saying this file "resolves to a non-module entity and cannot be imported using this construct".
Modify the code as follows - introduce an intermediary variable - and then it works:
There is a subtle distinction between export = <identifier> and export = <expression>. Only the earlier exports all meaning of an identifier. In your case, the object literal is treated as an expression, and what you are exporting is only the value side of that expression.
Okay, I understand the difference between an identifier and an expression, but you say "Only the earlier exports all meaning of an identifier", are you talking about the very first example?
Because this doesn't export anything - it doesn't even appear to become a module?
I thought anything with an import or export statement became a module.
So is it the error message that's incorrect in the first case? "resolves to a non-module entity and cannot be imported using this construct" - sounds to me like the file didn't evaluate to a module entity at all?
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Example module:
When I try to import this, I get a
TS 2497
error at the import site saying this file "resolves to a non-module entity and cannot be imported using this construct".Modify the code as follows - introduce an intermediary variable - and then it works:
How come I have to "trick" it into generating a module in this case?
I often have this problem in various other cases with top-level exports, such as when I'm exporting a single top-level function.
Is this normal?
I'm using release 1.8.9.
The text was updated successfully, but these errors were encountered: