Skip to content

Fix JS bind expando declaration emit#4069

Open
cjc0013 wants to merge 1 commit into
microsoft:mainfrom
cjc0013:fix-expando-bind-declaration-emit
Open

Fix JS bind expando declaration emit#4069
cjc0013 wants to merge 1 commit into
microsoft:mainfrom
cjc0013:fix-expando-bind-declaration-emit

Conversation

@cjc0013
Copy link
Copy Markdown

@cjc0013 cjc0013 commented May 28, 2026

Fixes #4045

This updates declaration emit for JS variables initialized from fn.bind({}) so the exported alias is emitted as a function declaration based on the bound target signature instead of const alias: typeof fn. That avoids leaking non-exported implementation functions into the generated .d.ts.

It also carries expando properties from the bound source function onto the public alias, while letting alias-owned expando assignments provide their own property declarations.

Tests:

  • go build -tags=noembed -o .\built\local\tsgo.exe .\cmd\tsgo
  • go test ./internal/testrunner/ -run 'TestLocal/(declarationEmitExpandoFunction|declarationEmitExpandoArrowFunctionParameter|functionExpandoPropertyDeclaration|jsExpandoAssignmentElementAccess|declarationEmitJsBindExpandoFunction)' -v
  • go test ./internal/transformers/declarations
  • git diff --check

AI disclosure: I used Codex to help investigate and draft this change; I reviewed the diff and test output and will respond to feedback myself.

Copilot AI review requested due to automatic review settings May 28, 2026 04:15
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.

Behavior difference: Notable gap regarding expando declaration on a function between tsc & tsgo

1 participant