Skip to content

commonjs named exports are merged into export= when not function/class #1508

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

Closed
hugomrdias opened this issue Feb 15, 2021 · 3 comments
Closed

Comments

@hugomrdias
Copy link

hugomrdias commented Feb 15, 2021

Search terms

commonjs
named exports
module.exports

Expected Behavior

all named exports should show in the navigation

Actual Behavior

all named exports are merged into export= when at least one of the named exports isn't a function/class

Steps to reproduce the bug

https://codesandbox.io/s/typedoc-test-w69ry?file=/src/index.js

Environment

  • Typedoc version: 0.20
  • TypeScript version: 4.1.3
  • Node.js version: all
  • OS: all
@hugomrdias hugomrdias added the bug label Feb 15, 2021
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 16, 2021

I am so close to saying I don't care about the horrible thing that is module.exports.

I removed o1 from your demo, and see the same behavior, with a single export= member having two function properties... which indicates this might be a dupe of #1422.

@hugomrdias
Copy link
Author

i can't reproduce that maybe it was some cache in codesandbox
Screenshot 2021-02-16 at 11 49 48

i spotted this error with the following

const obj1 = { key :value }

module.exports = {
  fn1,
  fn2,
  obj1: Object.freeze(obj1)
}

changing this code to

const obj1 = { key :value }
Object.freeze(obj1)
module.exports = {
  fn1,
  fn2,
  obj1
}

solves the issue, so seems to be when you define the name export directly in the module.export ={} block.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jun 15, 2021

Having spent more time looking into this, I've decided that there's no good way to fix this with the existing implementation of converters. TypeDoc relies on TypeScript's symbol organization to figure out how to document code, and TypeScript's symbol flags are set in such a way here that documenting module.exports as an object is the way to go. Trying to detect this edge case is proving too hacky.

@Gerrit0 Gerrit0 closed this as completed Jun 15, 2021
@Gerrit0 Gerrit0 removed the bug label Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants