vite-plugin-react-pages
vite-plugin-react-pages copied to clipboard
TsInfo improvements
Consider the following case:
type Variant = "primary" | "secondary";
type Size = "sm" | "md" | "lg";
type Dimension = {
w?: number;
h?: number;
}
interface AsProp {
as?: any;
}
interface BaseProps {
size?: Size;
wh?: Dimension;
}
interface ButtonProps extends BaseProps, AsProp {
variant?: Variant | "link";
}
The TsInfo
should show following output:
Name | Description | Type | Default Value |
---|---|---|---|
variant | "primary" | "secondary" | "link" |
||
size | "sm" | "md" | "lg" |
||
wh | { w: number, h: number } |
||
as | any |
What I am getting:
Name | Description | Type | Default Value |
---|---|---|---|
variant | Variant | "link" |
Suggested improvements:
- expand type references
- expand heritage clauses
- allow to skip certain heritage types
Examples:
-
<TsInfo src="./Button.tsx" name="ButtonProps"/>
should expandButtonProps
only no heritage types - `<TsInfo src="./Button.tsx" name="ButtonProps" heritage="true"/> should expand inherited props too
-
<TsInfo src="./Button.tsx" name="ButtonProps" heritage="AsProp"/>
should expand inherited props fromAsProp
and not all (can be comma separated names).
And the jsx api should be like:
import _TsInfo0 from './types.ts?tsInfo=ButtonProps'
import _TsInfo0 from './types.ts?tsInfo=ButtonProps&heritage=true'
import _TsInfo0 from './types.ts?tsInfo=ButtonProps&heritage=AsProp'
Alternative syntax can be:
// only local props
<TsInfo src="./Button.tsx" name="ButtonProps"/>
// with all inherited props
<TsInfo src="./Button.tsx" name="ButtonProps:*"/>
// only local props & props from AsProp
<TsInfo src="./Button.tsx" name="ButtonProps:AsProp"/>