Skip to content

Don't emit redundant and invalid extra renamed keyword exports in JS files #62104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

@Copilot Copilot AI review requested due to automatic review settings July 22, 2025 08:31
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jul 22, 2025
@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug labels Jul 22, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the issue where TypeScript was emitting redundant and invalid extra renamed keyword exports in JavaScript declaration files. The change addresses a bug where exports using JavaScript keywords as export names (like export { _null as null }) were generating unnecessary additional export declarations.

  • Removes logic that created redundant export declarations for keyword exports
  • Simplifies the private symbol handling logic by using logical OR assignment
  • Cleans up unnecessary variable tracking for export declarations

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
jsDeclarationsKeywordExport1.ts Test case demonstrating exports with keyword names (null, void)
jsDeclarationsKeywordExport1.types Expected type output for the test case
jsDeclarationsKeywordExport1.symbols Expected symbol resolution for the test case
jsDeclarationsKeywordExport1.js Expected compiled output including declaration file
checker.ts Core fix removing redundant export declaration generation logic
Comments suppressed due to low confidence (1)

@@ -9737,18 +9731,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
context.approximateLength += 16 + internalSymbolName.length; // `export default internalName;`
addResult(factory.createExportAssignment(/*modifiers*/ undefined, /*isExportEquals*/ false, factory.createIdentifier(internalSymbolName)), ModifierFlags.None);
}
else if (needsExportDeclaration) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was originally added by @weswigham in #38982

I tried to think of a potential missing test case, but I couldn't find one. Perhaps this just became handled by other code paths since this was introduced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

export { _void as void } leads to exporting duplicate identifiers
2 participants