souporserious / mdxts

The Content and Documentation SDK for React
https://mdxts.dev
MIT License
357 stars 6 forks source link

Types from external dependencies #134

Open flugg opened 1 month ago

flugg commented 1 month ago

Hi! First of all, really great project!

I got things running using the ExportedTypes component like this:

<ExportedTypes source="./src/button.tsx" workingDirectory="../../packages/components/button" />

However, the output only includes local types defined in the button.tsx file and not any types that's extended. The button file looks like this:

import type { ReactNode, RefObject } from 'react';
import type { ButtonProps as ReactAriaButtonProps } from 'react-aria-components';

export interface ButtonProps extends ReactAriaButtonProps {
  children?: ReactNode;
  isLoading?: boolean;
  ref?: RefObject<HTMLButtonElement>;
}

And I would like to get access to all props including those from within the React Aria Components library. How would I do it?

Thanks!

souporserious commented 1 month ago

Hey, thank you!

Hm, I think this is an issue with node_modules specifically since currently any types outside of the project are skipped over. There could be an additional option to process them though so something like <ExportTypes includeNodeModules /> or maybe a filterType prop might be better.

flugg commented 1 month ago

An option to delicately pick which props to include sounds very reasonable to me, and is similar to how react-docgen-typescript does it with the propFilter prop. I've previously utilized this prop in my Storybook configuration to include metadata for props from node_modules for my controls.