Skip to content

Problem when using Record + optional types #152

@dlmr

Description

@dlmr

There is an error when using Record along with different types. Or maybe this is not something that is supported by choice?

Example

/**
 * @param {{bar: (string|string[])}} options - this is object param.
 */
export function foo(options = {}) {}

The following errors is thrown when bulding the docs.

esdoc/out/src/Publisher/Builder/DocBuilder.js:469
            throw _iteratorError2;
            ^

SyntaxError: Invalid regular expression: /[~]\{bar: (string$/: Unterminated group
    at RegExp (native)

Looked a bit more into this and the issue above is because of the parenthesis, however removing them results in a lint error about invalid JSDoc (might not be relevant for ESDoc).

/**
 * @param {{bar: string|string[]}} options - this is object param.
 */
export function foo(options = {}) {}

The output becomes.

Name Type Attribute Description
options {bar: string string[]}

And not the expected.

Name Type Attribute Description
options {bar: string string[]}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions