-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Tree-shaking of parameter defaults too aggressive #4514
Copy link
Copy link
Closed
Labels
Description
Rollup Version
2.75
Operating System (or Browser)
any
Node Version (if applicable)
No response
Link To Reproduction
Expected Behaviour
In rollup-plugin-dts, I synthesize a fake AST for typescript definitions.
As an example, I turn the following TS code:
interface A {}
declare const a: A;
export declare function typeQuery(): typeof a;Into a synthetic AST representing something like:
function A() {}
function a(_1 = A) {return [_1]}
function typeQuery(_2 = typeQuery, _3 = a) {return [_2,_3]}
export {typeQuery}For various reasons, I use parameters and defaults to link between items and make sure that referenced things are being retained.
In particular, looking at the synthetic AST, I would expect that A is retained because I could "in theory" get a reference to it by doing a typeQuery()[1]()[0].
Actual Behaviour
As reported in Swatinem/rollup-plugin-dts#208, the recent changes in #4510 broke this use-case.
As the REPL shows, the synthetic example is being reduced to:
function a(_1) {return [_1]}
function typeQuery(_2 = typeQuery, _3 = a) {return [_2,_3]}
export { typeQuery };
That seems to be wrong, as I can no longer get to A by doing typeQuery()[1]()[0].
Reactions are currently unavailable