Lets suppose that I have a d.ts file that it imports types from other d.ts files which import types from other d.ts and it goes on.
Is there any tool that will allow me to create a single d.ts file from this tree that does not include all its dependencies and avoids name duplication?
The file index.d.ts is simply a collection of all the necessary declarations, and within them (for example, in data-grid.d.ts), there are also imports of external declarations.
index.d.ts
export * from './common.d.ts';
export * from './data-grid.d.ts';
export * from './tree-list.d.ts';
export * from './data/custom_store.d.ts';
I want to get a single declaration file with all the collected types and declarations.
I try to use rollup + rollup-plugin-dts
here is config
rollup.config.js
const { dts } = require('rollup-plugin-dts');
exports.default = {
input: './index.d.ts',
output: {
file: 'dist/types.all.d.ts',
format: 'es'
},
plugins: [dts()]
};
Everything builds without errors, but in the file types.all.d.ts, I get some types with unnecessary suffixes.
For example:
declare class NestedOption<P> extends React$1.PureComponent<P, any> {
render(): React$1.ReactNode;
}
declare class AsyncRule$1 extends NestedOption<IAsyncRuleProps> {
static OptionName: string;
static IsCollectionItem: boolean;
static PredefinedProps: {
type: string;
};
}
How can I get rid of these suffixes in the type names?
How would you suggest combining the tree of declarations into a single file?
P.S.: I understand that the problem might be due to the attempt to resolve duplicated names, but I cannot control or change the external declarations as they are the result of builds. Thank you in advance.