Skip to content

Conversation

@ahejlsberg
Copy link
Member

This PR fixes our odd behavior when hovering on module.exports in a JS file. Previously we'd display { "exports=": { ... } }, now we display module "xxx" when hovering on module and exports: { ... } when hovering on exports. In addition, find-all-references on module finds all locations where the module is imported.

The PR also fixes the following panic:

module.exports = {}
exports.foo = 42 // Click on `exports` causes panic

@ahejlsberg
Copy link
Member Author

The many baseline changes are all because module.exports now resolves to the symbol for the module source file instead of a synthetic module.exports symbol with no associated declaration.

Comment on lines 7 to +10
->module.exports : Symbol(module.exports, Decl(something.js, 0, 0))
->module : Symbol(export=, Decl(something.js, 0, 0))
+>module.exports : Symbol(export=, Decl(something.js, 0, 0))
+>module : Symbol(module.exports)
+>module : Symbol("something", Decl(something.js, 0, 0))
Copy link
Member

Choose a reason for hiding this comment

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

Kind of funky that before, module.exports was module.exports and module was export=, but now module.exports is export= and module is module name...

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the new behavior is defensible. The old one--not so much.

Copy link
Contributor

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 hover display behavior for module.exports in JavaScript files and resolves a panic that occurred when clicking on exports after a module.exports = {} assignment. The fix changes how the module identifier is symbolized - previously showing Symbol(module.exports), it now displays Symbol("moduleName", Decl(...)) with the actual module name, making hover information clearer and enabling find-all-references functionality.

Key changes:

  • Updated symbol representation for module in module.exports expressions across all CommonJS patterns
  • Changed from generic Symbol(module.exports) to specific Symbol("moduleName", Decl(...)) format

@jakebailey
Copy link
Member

Seems like you fixed a test and just need to run npm run updatefailing.

@ahejlsberg
Copy link
Member Author

Seems like you fixed a test and just need to run npm run updatefailing.

Tried, but didn't seem to do anything.

@ahejlsberg
Copy link
Member Author

ahejlsberg commented Nov 15, 2025

Hmm, I'm not understanding what to do here! No changes are generated when I run npm run updatefailing.

@jakebailey
Copy link
Member

jakebailey commented Nov 15, 2025

I think this is a bad interaction of the script and baselines (since generating new baselines also fails the test, and the CI check is smarter)

We can fix this manually for now; remove the test from the failing list, then also remove the t.Skip() call from the generated test itself, then if you run the test you can accept the baselines. Then you can rerun updatefailing again.

I'll look into fixing this properly later.

@ahejlsberg ahejlsberg added this pull request to the merge queue Nov 15, 2025
Merged via the queue into main with commit 05f4d69 Nov 15, 2025
22 checks passed
@ahejlsberg ahejlsberg deleted the hover-on-module-exports branch November 15, 2025 02:27
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.

3 participants