Skip to content

Default exports documented as Class default #111

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
aciccarello opened this issue Jul 7, 2015 · 8 comments
Closed

Default exports documented as Class default #111

aciccarello opened this issue Jul 7, 2015 · 8 comments
Labels
question Question about functionality

Comments

@aciccarello
Copy link
Collaborator

I am using ES6 classes with default exports such as

export default 'testApp';
// or
export default class DataService {
  ... 
}

But when the documentation is generated, all of the objects, functions, classes, ect. that were exported as the default export from a file are all showing up as a class called default

@sebastian-lenz sebastian-lenz added the question Question about functionality label Jul 8, 2015
@sebastian-lenz
Copy link
Member

Right, I've also noted this behaviour. Actually this is not done by TypeDoc but the TypeScript compiler renames the symbols to default. I'm not sure how we should handle this within the documentation, if you consume the generated module the class will be actually named "default" so the documentation is correct.

@aciccarello
Copy link
Collaborator Author

Okay, this is a pretty significant issue as it makes the documentation unhelpful to have all the methods of all exported classes listed on one page.

If there is no way to retrieve the class name, I was thinking that using the file name might be an option but it's not perfect. At least it would line up with the name used when importing. Maybe this could be a separate mode option where all types are documented under their respective file name.

@sebastian-lenz
Copy link
Member

You have all the methods of all exported classes listed on one page? For me the members and methods are rendered correctly although multiple classes are named default. Is your source code available on GitHub or could you send me the definitions where this is happening?

I've just checked the compiler symbols, they contain a localSymbol storing the original name of the symbol. So it should be relative easy to lookup the original name.

@aciccarello
Copy link
Collaborator Author

Sorry for the confusion and no I don't have my code up online. All the classes that aren't the default export show up correctly. However, the properties and methods of default exports show up under one "default" class.

Hopefully that localSymbol should work well.

@aciccarello
Copy link
Collaborator Author

Any update on this?

@aciccarello
Copy link
Collaborator Author

I switched to using module mode so my docs don't look as bad as they did. But it would be nice to show the exports name.

@mathdoodle
Copy link

I'd like to second another look at this. I've read somewhere that default exports are a best practice, so creating useable docs for this case would seem desirable. Like aciccarello, I'm having to work-around with named exports, which is not a long-term solution (bundling today makes this OK).

My suggestion on the resolution would be to "damn the technical inaccuracy". Try to document as if they were named exports and put a note somewhere. The d.ts files or ts source itself will take care that the compile is safe (we don't compile from the docs - they are for humans!).

Awesome work BTW. Wish I could be more helpful.

@aciccarello
Copy link
Collaborator Author

@mathdoodle I think #398 should fix any other issues you may be having with default eports. Please let someone know if it doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about functionality
Projects
None yet
Development

No branches or pull requests

4 participants