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 in markdown plugin: TypeError: Cannot read properties of undefined (reading 'comment') #368

Closed
chrstnbwnkl opened this issue Dec 1, 2022 · 1 comment

Comments

@chrstnbwnkl
Copy link

Hello there, thanks for this great plugin :)

When building the docs for my package using the Docusaurus TypeDoc plugin, I am getting the following error:

[ERROR] TypeError: Cannot read properties of undefined (reading 'comment')
    at getComments (/home/chris/dev/maintained_libs/routing-js/node_modules/typedoc-plugin-markdown/dist/resources/helpers/property-table.js:103:39)
    at /home/chris/dev/maintained_libs/routing-js/node_modules/typedoc-plugin-markdown/dist/resources/helpers/property-table.js:45:34
    at Array.map (<anonymous>)
    at Array.<anonymous> (/home/chris/dev/maintained_libs/routing-js/node_modules/typedoc-plugin-markdown/dist/resources/helpers/property-table.js:32:33)
    at Array.wrapper (/home/chris/dev/maintained_libs/routing-js/node_modules/handlebars/dist/cjs/handlebars/internal/wrapHelper.js:15:19)
    at eval (eval at createFunctionContext (/home/chris/dev/maintained_libs/routing-js/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:262:23), <anonymous>:11:239)
    at prog (/home/chris/dev/maintained_libs/routing-js/node_modules/handlebars/dist/cjs/handlebars/runtime.js:268:12)
    at DeclarationReflection.<anonymous> (/home/chris/dev/maintained_libs/routing-js/node_modules/handlebars/dist/cjs/handlebars/helpers/with.js:32:14)
    at DeclarationReflection.wrapper (/home/chris/dev/maintained_libs/routing-js/node_modules/handlebars/dist/cjs/handlebars/internal/wrapHelper.js:15:19)
    at eval (eval at createFunctionContext (/home/chris/dev/maintained_libs/routing-js/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:262:23), <anonymous>:13:49)

It turns out that the following interface seems to be causin the trouble:

/** A route path object that includes the points along the route as well as additional route attributes. */
export interface GraphHopperRoutePath {
    /**
     * The total distance, in meters.
     *
     * @see {@link https://www.graphhopper.com/blog/2019/11/28/routing-api-using-path-details/} for more details.
     *
     */
    distance: number
    /**
     * The total travel time, in milliseconds.
     *
     * @see {@link https://www.graphhopper.com/blog/2019/11/28/routing-api-using-path-details/} for more details.
     */
    time: number
    /** The total ascent, in meters. */
    ascend: number
    /** The total descent, in meters.  */
    descend: number
    /** The geometry of the route. The format depends on the value of points_encoded. */
    points?: LineString | string // not returned if `calc_points=false`
    /** The snapped input points. The format depends on the value of points_encoded. */
    snapped_waypoints: LineString | string
    /**
     * Whether the points and snapped_waypoints fields are polyline-encoded strings rather than
     * JSON arrays of coordinates. See the field description for more information on the two formats.
     */
    points_encoded: boolean
    /** The bounding box of the route geometry. */
    bbox: [number, number, number, number]
    /**
     * The instructions for this route. This feature is under active development, and our
     * instructions can sometimes be misleading, so be mindful when using them for navigation.
     */
    instructions: GraphHopperInstruction[]
    /**
     * Details, as requested with the details parameter.
     * Consider the value `{"street_name": [[0,2,"Frankfurter Straße"],[2,6,"Zollweg"]]}`.
     * In this example, the route uses two streets: The first, Frankfurter Straße, is used
     * between points[0] and points[2], and the second, Zollweg, between points[2] and points[6].
     */
    details: { [Property in keyof GraphHopperDetail]: JSONValue }
    /**
     * An array of indices (zero-based), specifiying the order in which the input points are visited.
     * Only present if the optimize parameter was used.
     */
    points_order: number[]
}

I have not been able to reproduce this in a minimal example, but looking at the following piece of code:

https://github.com/tgreyuk/typedoc-plugin-markdown/blob/61f6c3e1916d374055c9df12e0d7a709dad4730a/packages/typedoc-plugin-markdown/src/resources/helpers/property-table.ts#L131-L132

it seems that the array check should be something like

    if (property.signatures?.length) {
        return property.signatures[0].comment;
    }

At least that fixes the issue for me :-)

@tgreyuk
Copy link
Member

tgreyuk commented Dec 2, 2022

Fix in typedoc-plugin-markdown@3.14.0

@tgreyuk tgreyuk closed this as completed Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants