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

Display or link nested types/interfaces #440

Open
Christos-Zacharopoulos opened this issue Jan 12, 2022 · 3 comments
Open

Display or link nested types/interfaces #440

Christos-Zacharopoulos opened this issue Jan 12, 2022 · 3 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@Christos-Zacharopoulos
Copy link
Contributor

It would be nice to have some way to display nested types or link them.

Example:

Clicky clicky to Row or ExtendedColumn should display the nested type or redirect to a page for this type or something.
image

After investigating on how to do this, I found these issues:

storybookjs/storybook#13459
storybookjs/storybook#7944
storybookjs/storybook#15008
storybookjs/storybook#13459

If any of these get resolve then Bob's your uncle.

@Christos-Zacharopoulos Christos-Zacharopoulos added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 12, 2022
@mrose-acertus
Copy link

I read in the related issues that the holdup is react-docgen-typescript? May I propose a simpler solution? Extracting the details of interfaces in any given TypeScript source file is pretty straightforward....

const ts = require("typescript");

export const describeInterfaces = (filePath) => {
    const program = ts.createProgram([ filePath ], {
        allowJs: true
    });
    const sourceFile = program.getSourceFile(filePath);
    const typeChecker = program.getTypeChecker();
    ts.forEachChild(sourceFile, node => {
        if (node.kind !== ts.SyntaxKind.InterfaceDeclaration) {
            return;
        }
        const interfaceName = node.name.escapedText;
        console.log(interfaceName);
        node.members.forEach(member => {
            const memberName = member.name.escapedText;
            const memberType = typeChecker.getTypeAtLocation(member.type);
            const memberTypeName = typeChecker.typeToString(memberType);
            console.log("\t" + memberName + " : " + memberTypeName);
        })
    });
};

A DocBlock that provided a capability like this would be awesome....

@dcantu96
Copy link

dcantu96 commented May 3, 2022

This would be amazing and super useful!

@Dina-Lai
Copy link

Dina-Lai commented Sep 5, 2023

I really need this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants