File tree Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -182,17 +182,16 @@ export declare const If: FC<PropsWithChildren<IfProps>>;
182182## ` <Switch /> ` ` <Case /> ` ` <Default /> ` Props
183183
184184``` tsx
185- import { type FC , type PropsWithChildren } from ' react' ;
186- export declare const Switch: FC <PropsWithChildren <{}>>;
187-
185+ import type { FC , PropsWithChildren } from ' react' ;
186+ export const Switch: FC <PropsWithChildren <{}>>;
188187type TagType = React .ElementType | keyof JSX .IntrinsicElements ;
189188interface CaseElementProps <T extends TagType > {
190189 as? : T ;
191190 readonly condition? : boolean ;
192191}
193192export type CaseProps <T extends TagType > = CaseElementProps <T > & React .ComponentPropsWithoutRef <T >;
194- export declare const Case: <T extends TagType >(props : CaseProps <T >) => null ;
195- export declare const Default: <T extends TagType >(props : CaseProps <T >) => null ;
193+ export const Case: <T extends TagType >(props : CaseProps <T >) => any ;
194+ export const Default: <T extends TagType >(props : Omit < CaseProps <T >, ' condition ' > ) => import ( " react/jsx-runtime " ). JSX . Element ;
196195```
197196
198197## Development
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export const Switch: FC<PropsWithChildren<{}>> = ({ children }) => {
2020 }
2121 return false ;
2222 } ) ;
23- return < > { matchChild ?? defaultCase ?? null } </ > ;
23+ return matchChild ?? defaultCase ?? null ;
2424} ;
2525
2626type TagType = React . ElementType | keyof JSX . IntrinsicElements ;
@@ -37,4 +37,6 @@ export const Case = <T extends TagType>(props: CaseProps<T>) => {
3737 return Elm ? < Elm { ...reset } > { children } </ Elm > : children ;
3838} ;
3939
40- export const Default = < T extends TagType > ( props : CaseProps < T > ) => < Case { ...props } /> ;
40+ export const Default = < T extends TagType > ( props : Omit < CaseProps < T > , 'condition' > ) => (
41+ < Case { ...( { ...props } as CaseProps < T > ) } />
42+ ) ;
Original file line number Diff line number Diff line change 11declare module '@uiw/react-only-when/switch' {
2- import { FC , PropsWithChildren } from 'react' ;
3- export declare const Switch : < T extends TagType > ( { children } : PropsWithChildren ) => null ;
2+ import type { FC , PropsWithChildren } from 'react' ;
3+ export const Switch : FC < PropsWithChildren < { } > > ;
44 type TagType = React . ElementType | keyof JSX . IntrinsicElements ;
55 interface CaseElementProps < T extends TagType > {
66 as ?: T ;
77 readonly condition ?: boolean ;
88 }
99 export type CaseProps < T extends TagType > = CaseElementProps < T > & React . ComponentPropsWithoutRef < T > ;
10- export declare const Case : < T extends TagType > ( props : CaseProps < T > ) => any ;
11- export declare const Default : < T extends TagType > ( props : CaseProps < T > ) => any ;
10+ export const Case : < T extends TagType > ( props : CaseProps < T > ) => any ;
11+ export const Default : < T extends TagType > (
12+ props : Omit < CaseProps < T > , 'condition' > ,
13+ ) => import ( 'react/jsx-runtime' ) . JSX . Element ;
1214}
You can’t perform that action at this time.
0 commit comments