Open csantos1113 opened 10 months ago
@valentinpalkovic it would be great if we could support tsconfig paths in the react-docgen
resolver for both webpack & vite. WDYT?
Relates to https://github.com/reactjs/react-docgen/issues/456.
@shilman we could indeed try to provide a custom importer, which handles path aliases, or someone/we contribute directly to react-docgen.
At least https://github.com/reactjs/react-docgen/issues/456 was fixed in Storybook by adjusting react-docgen's default resolver.
It will be part of the next 8.0.0-rc.2 prerelease!
react-docgen also does not seem to work in my setup:
"use client";
import {
Button as ButtonBase,
ButtonText,
ButtonIcon,
ButtonSpinner,
} from "theme";
import type { ComponentProps } from "react";
export type ButtonProps = { title: string } & Pick<
ComponentProps<typeof ButtonBase>,
"onPress" | "variant" | "action" | "size"
> & {
Icon?: ComponentProps<typeof ButtonIcon>["as"];
processing?: boolean;
};
export const Button = ({ title, Icon, processing, ...rest }: ButtonProps) => {
return (
<ButtonBase {...rest}>
<ButtonText>{title}</ButtonText>
{Icon ? <ButtonIcon as={Icon} /> : null}
{processing ? <ButtonSpinner /> : null}
</ButtonBase>
);
};
import type { Meta, StoryObj } from "@storybook/react";
import { Button } from "./Button";
export default {
title: "primitives/Button",
component: Button,
parameters: {
layout
layout: "centered",
},
docs/autodocs
tags: ["autodocs"],
};
type Story = StoryObj<typeof Button>;
export const Default: Story = {
args: {
title: "Button",
},
};
i am unsure whether it is a problem similar to https://github.com/reactjs/react-docgen/issues/456 or something else
Describe the bug
react-docgen
generates different (and incomplete) documentation thanreact-docgen-typescript
; and once #24165 lands the default documentation generated by Storybook will be significantly "bad" for typescript users using typescript path aliases and enums.EDIT (@valentinpalkovic):
react-docgen
Originally posted by @csantos1113 in https://github.com/storybookjs/storybook/issues/24165#issuecomment-1832420070
To Reproduce
vite-tsconfig-paths
for those paths to resolve in vitereact-docgen
(which will be the default in 8.0 once #24165 is merged)react-docgen
(which will be the default in 8.0 once #24165 is merged)vite-tsconfig-paths
react-docgen-typescript
insteadSystem
Additional context
I understand there are foundational differences between the two libraries, and react-docgen has a bunch of open TypeScript related issues: https://github.com/reactjs/react-docgen/issues?q=is%3Aissue+is%3Aopen+typescript and the decision behind Storybook swapping the default docsgen library, and that keeping these 2 libraries working "the same" is not responsibility of the Storybook team ❤️
This is not really an issue with storybook per se, but the Storybook team might help push this forward in the right direction 🙏
I'm opening this issue per @shilman request: https://github.com/storybookjs/storybook/pull/24165#issuecomment-1833012165
Related issues