-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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 used as object key is not exported in declaration #35329
Comments
The cause is that the type serializer can’t figure out what to write for the return type of I’m not sure if there’s a reason we can’t fall back to using an indexed access type, Anyway, the cleanest workaround is to give export enum Pages {
dashboard = 'dashboard',
}
export interface UIState {
[Pages.dashboard]: {
selectedRow: number | null;
};
}
export interface State {
ui: UIState;
} |
Hurrrr - it's because we allow To fix, on our part, we could either
@hcomnetworkers As a workaround, add an import to |
@weswigham sorry, I think my comment misled you. The screenshot I posted is something I wrote for the purpose of illustrating that import types aren‘t valid property key types. That didn’t come from the declaration emit.
This is what’s happening today. I was unsure if it’s a bug.
This is not a functioning workaround, which I did think is a bug: |
TypeScript Version: 3.8.0-dev.20191125 (@next), but was present in 3.4 already
Search Terms:
Code
Selectors.ts
Store.ts
tsconfig.json
Expected behavior:
No error.
Actual behavior:
This error is thrown:
Details:
This error only occurs when exporting the given selector and when using
--declaration
. The probable cause is that the enum values used as object key is not properly detected and added to the exported files.If the enum is not used as object key, but as object value, the error does not occur.
If the content of Store.ts is moved to Selectors.ts, the error does not occur.
This code works as expected in the ts-loader via webpack, however
tsc
and PhpStorm report this as error.The text was updated successfully, but these errors were encountered: