Skip to content
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

0.20.0-beta.4 Default export not picked up in generated library mode docs #1382

Closed
CS-BTurner opened this issue Oct 26, 2020 · 4 comments
Closed
Labels
bug Functionality does not match expectation

Comments

@CS-BTurner
Copy link

Search terms

Default export, Library mode

Expected Behavior

Given

"typedocOptions": {
  "out": "docs",
  "entryPoints": ["./src/index.ts"],
  "hideGenerator": true
}

I would expect default export of ./src/index.ts to be included in doc generation. It seems all other named exports are included (which is great).

Actual Behavior

Default export does not appear in right navigation modules pane. There isn't any generated html file for it either.

Steps to reproduce the bug

#1364 Using 0.20.0-beta.4

index.ts

import ResourceManager from './ResourceManager';
import Resource from './Resource';

export default ResourceManager;
export { Resource };

// Contributions imports / exports
import { MongoResource, AmqpResource } from './contrib';
import type { MongoResourceOptions, AmqpResourceOptions } from './contrib';

export { MongoResource, AmqpResource };
export type { MongoResourceOptions, AmqpResourceOptions };

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "target": "es2019",

    "esModuleInterop": true,
    "alwaysStrict": true,
    "sourceMap": true,
    "outDir": "lib",
    "baseUrl": ".",
    "declaration": true,
    "resolveJsonModule": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules/**"],

  "typedocOptions": {
    "out": "docs",
    "entryPoints": ["./src/index.ts"],
    "hideGenerator": true
  }
}

Expected library usage

import ResourceManager, { MongoResource } from '@cloudsense/cs-resource-manager';

Environment

  • Typedoc version: 0.20.0-beta.4
  • TypeScript version: 4.0.3
  • Node.js version: v14.13.1
  • OS: MacOS Catalina 10.15.7
@CS-BTurner CS-BTurner added the bug Functionality does not match expectation label Oct 26, 2020
@CS-BTurner CS-BTurner changed the title Default export not picked up in generated library mode docs 0.20.0-beta.4 Default export not picked up in generated library mode docs Oct 26, 2020
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 1, 2020

This should be fixed in 0.20.0-beta.5 - default exports are annoying... there are entirely too many options for them.

@CS-BTurner
Copy link
Author

Hi @Gerrit0,

I have taken another look at this today and can confirm that the default export is now being included in the generation.

However, this behaviour still isn't exactly what I was expecting. In the right hand column, the name of the default export is referred to as default (shown below).

image

I would expect the behaviour to use the exported function / class name instead of default. In my use case, I would expect it to be EnvironmentHandler.

image

Environment

  • Typedoc version: 0.20.0-beta.8
  • TypeScript version: 4.0.5
  • Node.js version: v14.13.1
  • OS: MacOS Catalina 10.15.7

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 4, 2020

It is documented as default... because that's what it is exported as! This is one of the reasons default exports are bad. They don't have an associated name. It's misleading at best to say you export EnvironmentHandler when I can't import { EnvironmentHandler } from 'package'

You could do this, which should result in two documentation items, where default is marked as an alias for EnvironmentHandler:

export { EnvironmentHandler }
export default EnvironmentHandler

@CS-BTurner
Copy link
Author

Ah okay, this makes sense. I definitely agree default exports are complicated!

This beta release is looking really good and in general I am really happy with how it is working. Thanks for all the great work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants