-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Enum export not working across multiple projects #4800
Comments
The problem is Enums are not checked structurally, each any two enum types are not assignable to each other, regardless of their shape; other structural checks would work, e.g. passing an interface with he same shape as the expected target type. A class with a private member, however, will behave like an enum, as a private has to originate from the same declaration, and as mentioned above, they are not. Solutions, npm dedupe should solve this issue, assuming the version of the packages is compatible. the other possible solution would be implementing the suggestion in #4665 (comment). The typescript resolver should attempt to dedupe packages in similar setup, so marking it as a bug. |
After discussion this some more, 1. npm v3 and later should flatten by default, so no additional work needed by the compiler, and 2. enums should not be compared nominally, see #5740 |
I don't understand, what is the resolution here? I am seeing the same issue. I simply want to define an I think I understand the semantic challenge here. But in practical terms, it seems like this makes an |
Great. Thanks. 👏 I think I've already picked this up in |
The error relates to enums, and exports using the new typescript node resolution (with the typings property in the package.json). I have tested this on typescript@next.
The bug can be reproduced through the following scenario: (please go to https://github.com/christyharagan/typeScript-enum-export-bug to find this code):
Three projects:
a
,b
,c
.b
depends ona
c
depends onb
a
exports an enum through its index.ts:b
then exports a function that returnsE
through its index.ts:c
then consumesf
through its index.ts:There is now an error for
e
:All three packages have a package.json that looks like this:
And a tsconfig.json that looks like:
Furthermore, this defect occurs if
f
were to export another symbol (e.g. an interface) which references an exported enum somewhere within it's structure or hierarchy.This only seems to affect enums, not other types.
The text was updated successfully, but these errors were encountered: