orfium-ictinus
orfium-ictinus copied to clipboard
Display or link nested types/interfaces
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.
After investigating on how to do this, I found these issues:
https://github.com/storybookjs/storybook/issues/13459 https://github.com/storybookjs/storybook/issues/7944 https://github.com/storybookjs/storybook/issues/15008 https://github.com/storybookjs/storybook/issues/13459
If any of these get resolve then Bob's your uncle.
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....
This would be amazing and super useful!
I really need this!