Skip to content

JSDoc tags missing from react-docgen-typescript output #28

@RoystonS

Description

@RoystonS

JSDoc tags in comments on props (such as @ignore) are missed out by react-docgen-typescript.

Repro Case

With this component, styleguidist should be skipping property2 from the styleguide, but it's still shown.

import * as React from 'react';

interface IJsDocTagsDontWorkProps {
    /**
     * First property.
     */
    property1: string;

    /**
     * Second property.
     * @ignore
     */
    property2: string;
}

export class JsDocTagsDontWork extends React.PureComponent<IJsDocTagsDontWorkProps, undefined> {
    render() {
        return <div>Hello</div>;
    }
}

export default JsDocTagsDontWork;

Issue

I've had a very quick poke around... I suspect that the TypeScript compiler is being 'helpful' and is splitting JsDoc comments into two: the plain text part is returned by symbol.getDocumentationComment() but it removes JsDoc tags from the result of that call: they're instead returned by symbol.getJsDocTags().

react-docgen expects to receive a full JsDoc comment containing both the plain text and the tags (which it then parses), but right now, react-docgen-typescript only returns the plain text part because it's only calling getDocumentationComment(), meaning the JsDoc tags are just dropped.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions