Typedoc: 0.20.0-beta.4 Default export not picked up in generated library mode docs

Created on 26 Oct 2020  路  4Comments  路  Source: TypeStrong/typedoc

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
bug

Most helpful comment

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.

All 4 comments

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

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

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

woppa684 picture woppa684  路  3Comments

topherfangio picture topherfangio  路  3Comments

Rycochet picture Rycochet  路  4Comments

nidsharm picture nidsharm  路  3Comments

euberdeveloper picture euberdeveloper  路  3Comments