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

Error documenting reexported enum declared via JSDoc #1464

Closed
kryops opened this issue Jan 12, 2021 · 1 comment
Closed

Error documenting reexported enum declared via JSDoc #1464

kryops opened this issue Jan 12, 2021 · 1 comment
Labels
bug Functionality does not match expectation

Comments

@kryops
Copy link

kryops commented Jan 12, 2021

Search terms

enum, JavaScript, JSDoc

Actual Behavior

After upgrading from 0.17.0-3 to 0.20.14, typedoc throws the following error:

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  assert(declaration)

    at Object.convertTypeAlias (/Users/strobel/git/_repos/crossmip/node_modules/typedoc/dist/lib/converter/symbols.js:111:7)
    at convertSymbol (/Users/strobel/git/_repos/crossmip/node_modules/typedoc/dist/lib/converter/symbols.js:81:79)
    at Object.convertAlias (/Users/strobel/git/_repos/crossmip/node_modules/typedoc/dist/lib/converter/symbols.js:375:9)
    at Object.convertSymbol (/Users/strobel/git/_repos/crossmip/node_modules/typedoc/dist/lib/converter/symbols.js:81:79)
    at Converter.convertReExports (/Users/strobel/git/_repos/crossmip/node_modules/typedoc/dist/lib/converter/converter.js:186:23)
    at Converter.compile (/Users/strobel/git/_repos/crossmip/node_modules/typedoc/dist/lib/converter/converter.js:161:18)
    at Converter.convert (/Users/strobel/git/_repos/crossmip/node_modules/typedoc/dist/lib/converter/converter.js:42:14)
    at Application.convert (/Users/strobel/git/_repos/crossmip/node_modules/typedoc/dist/lib/application.js:151:31)
    at run (/Users/strobel/git/_repos/crossmip/node_modules/typedoc/bin/typedoc:61:25)
    at Object.<anonymous> (/Users/strobel/git/_repos/crossmip/node_modules/typedoc/bin/typedoc:27:1) {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: undefined,
  expected: true,
  operator: '=='
}

Steps to reproduce the bug

We have a project that is somewhere in the middle of the TypeScript migration, with some JS code that is typed via JSDoc. We are using typedoc to generate API documentation from mixed TypeScript and JavaScript sources.

It seems that the problem is the JSDoc @enum, which creates a type alias.

column-type.js

/** @enum {string} */
export const ColumnType = {
  STRING: 'string',
  NUMBER: 'number',
  BOOLEAN: 'boolean',
  DATE_TIME: 'datetime',
  DATE: 'date',
  TIME: 'time',
  ICON: 'icon',
};

index.ts

export { ColumnType } from './column-type';

tsconfig.json

{
  "compilerOptions": {
    "noEmit": true,
    "allowJs": true,
    "target": "esnext",
    "lib": ["es6", "dom", "esnext"],
    "module": "esnext",
    "moduleResolution": "node",
    "strict": true,
    "pretty": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "jsx": "react",
    "noUnusedLocals": true,
    "resolveJsonModule": true,
    "baseUrl": "./node_modules"
}

typedoc.json

{
  "readme": "none",
  "exclude": ["**/test/**", "**/public/**"],
  "excludePrivate": true,
  "excludeExternals": true
}

typedoc command

typedoc --options typedoc.json --tsconfig tsconfig.json --out public/api/package packages/package/src/index.ts

When hovering over the re-export line in VS Code, the type is resolved as the following:

(alias) type ColumnType = string
(alias) const ColumnType: {
    STRING: string;
    NUMBER: string;
    BOOLEAN: string;
    DATE_TIME: string;
    DATE: string;
    TIME: string;
    ICON: string;
}

After migrating the affected files to a Typescript enum, the error disappears.

Environment

  • Typedoc version: 0.20.14
  • TypeScript version: 3.9.7
  • Node.js version: 12.16.3
  • OS: MacOS 11.1
@kryops kryops added the bug Functionality does not match expectation label Jan 12, 2021
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jan 12, 2021

Thanks! This should be a pretty easy fix... will be done on Saturday if not sooner.

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