Description
openedon Nov 21, 2022
Bug Report
π Search Terms
declaration emit
dts
inline
inlining
duplication
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
Playground link with relevant code
π» Code
export const I = {
/**
* Docs
*/
prop: true
};
export const Inlined = I;
export const Aliased: typeof I = I;
π Actual behavior
Declaration emit contains a duplicated type.
export declare const I: {
/**
* Docs
*/
prop: boolean;
};
export declare const Inlined: {
/**
* Docs
*/
prop: boolean;
};
export declare const Aliased: typeof I;
π Expected behavior
Declaration emit should reference the original via an alias.
export declare const I: {
/**
* Docs
*/
prop: boolean;
};
export declare const Inlined: typeof I;
export declare const Aliased: typeof I;
Notes
I know this is working-as-expected so feel free to close immediately if there is no quick win in sight.
We've got a bunch of documentation that has bloated declarations because of this specific trivial intra-file variant of the more generalized duplication/inlining issue. It happens when we do renames or migrations of types from one name to another and they need to be exported under separate names. The workaround is to explicitly add the typeof X
annotation but folk forget this.
The general solution long-term will be to go with --isolatedDeclarations
and a completely different form of declaration emit, but in the short-term, and for folks that enjoy inference, maybe there's also a possibility to quickly fix up existing declaration emit for this specific case?