Skip to content

fix: don't treat destructured parameter names as dependencies - #325

Merged
sxzz merged 1 commit into
sxzz:mainfrom
abrahamguo:fix/destructured-param-deps
Oct 22, 2026
Merged

sxzz merged 1 commit into
sxzz:mainfrom
abrahamguo:fix/destructured-param-deps

Conversation

@abrahamguo

@abrahamguo abrahamguo commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

AI usage

  • No AI was used in this PR.
  • AI was used: Claude Code + Opus 5.5
    • I have carefully reviewed the AI-generated content myself.

Description

collectDependencies adds the value of every Property node as a dependency, including properties of an ObjectPattern. In a destructured parameter, that value is a binding, not a reference:

// mod.d.ts
export declare function f({ value }: { value?: string }): void;

// index.d.ts
export { f } from "./mod";
export declare const value: string;

This bundles to declare const value$1: string and export { value$1 as value }, because the value in mod.d.ts is treated as a global reference. When the parameter's name matches a declaration in the same module, that declaration is never tree-shaken, even if nothing uses it.

This PR skips value when the parent is an ObjectPattern. Computed keys are still collected.

Linked Issues

Additional context

For this reason, posthog-js 1.438.13 publishes declare const posthog$1: PostHog and posthog$1 as default (dist/module.d.ts), so editors auto-import its default export as posthog$1. The source declares export const posthog. Other modules destructure a parameter with the same name, e.g. useHideSurveyOnURLChange({ …, posthog }).

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/sxzz/rolldown-plugin-dts@325

commit: abeaa36

@sxzz
sxzz merged commit f5d8075 into sxzz:main Oct 22, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants