Compare commits

..

4 Commits

Author SHA1 Message Date
叶枫
db7d4bf896 Apply suggestion from @gemini-code-assist[bot]
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: 叶枫 <7971419+crazyair@users.noreply.github.com>
2026-02-14 18:37:36 +08:00
crazyair
7c7abd885d feat: test 2026-02-14 18:32:30 +08:00
crazyair
6ba9b9b72b feat: test 2026-02-14 18:31:16 +08:00
crazyair
e990f58cc8 feat: test 2026-02-14 18:21:59 +08:00
2 changed files with 13 additions and 1 deletions

View File

@@ -99,5 +99,12 @@ describe('type', () => {
const bamboo: BambooType = 123;
expect(bamboo).toBeTruthy();
});
it('Type is return', () => {
interface Props {
classNames?: { root?: string } | ((props: any) => { root?: string });
}
const result: GetProp<Props, 'classNames', 'Return'> = { root: '123' };
expect(result).toBeTruthy();
});
});
});

View File

@@ -55,7 +55,12 @@ export type GetProps<T extends React.ComponentType<any> | object> =
export type GetProp<
T extends React.ComponentType<any> | object,
PropName extends keyof GetProps<T>,
> = NonNullable<GetProps<T>[PropName]>;
Type extends 'Default' | 'Return' = 'Default',
> = Type extends 'Default'
? NonNullable<GetProps<T>[PropName]>
: Type extends 'Return'
? ReturnType<Extract<NonNullable<GetProps<T>[PropName]>, (...args: any[]) => unknown>>
: never;
type ReactRefComponent<Props extends { ref?: React.Ref<any> | string }> = (
props: Props,