Skip to content

Fix assigned TypeScript namespace aliases#4470

Open
puneetdixit200 wants to merge 1 commit into
evanw:mainfrom
puneetdixit200:fix/4450-ts-namespace-assignment
Open

Fix assigned TypeScript namespace aliases#4470
puneetdixit200 wants to merge 1 commit into
evanw:mainfrom
puneetdixit200:fix/4450-ts-namespace-assignment

Conversation

@puneetdixit200
Copy link
Copy Markdown

This fixes #4450.

TypeScript namespace alias lowering already rewrites reads from exported members in sibling namespace blocks, such as console.log(x) becoming A.x. The assignment target path was skipping the namespace alias rewrite, so x = 0 stayed as a bare identifier.

This change keeps enum/namespace member inlining limited to read-only references, but still lowers assigned namespace aliases to property accesses. I also added a regression test for the sibling namespace assignment case from the issue.

Tests:

  • go test ./internal/js_parser -run TestTSNamespaceExports
  • go test ./internal/js_parser
  • go test ./internal/... ./pkg/...
  • make test-go

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.

TypeScript: an exported variable of sibling namespaces can not be correctly transformed when assigned

1 participant