-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
TypeScript Version: 3.8.0-dev.20191125 (@next), but was present in 3.4 already
Search Terms:
- typescript ts4023
- Exported variable has or is using name from external module but cannot be named
- typescript enum declaration
Code
Selectors.ts
import {State} from './Store';
export const pageUiSelector = (state: State) => state.ui;
Store.ts
export enum Pages {
dashboard = 'dashboard',
}
export interface State {
ui: {
[Pages.dashboard]: {
selectedRow: number | null;
};
};
}
tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"module": "commonjs",
"rootDir": ".",
"strict": true,
"target": "es2017"
}
}
Expected behavior:
No error.
Actual behavior:
This error is thrown:
Selectors.ts:2:14 - error TS4023: Exported variable 'pageUiSelector' has or is using name 'Pages' from external module "xxx/Store" but cannot be named.
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.