Skip to content

Commit

Permalink
refactor: cleanup generic type
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Apr 15, 2022
1 parent eba5e71 commit c8b566b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/If.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, FC, ReactElement } from 'react';
import React, { FC, Fragment, ReactElement } from 'react';
import { Else } from './Else';
import { Fallback } from './Fallback';
import { getConditionResult } from './getConditionResults';
Expand All @@ -16,7 +16,7 @@ import type { ComponentWithConditionPropsAsyncSupport, ExtendablePromise } from
* but only the first block of the right type (either Then or Else, depending on the condition) will be rendered.
* @param __namedParameters The props to pass down to the `<IF />` component, see {@link ComponentWithConditionProps}
*/
export const If: FC<ComponentWithConditionPropsAsyncSupport<'without-function-children'>> = ({ condition, keepAlive = false, children }) => {
export const If: FC<ComponentWithConditionPropsAsyncSupport> = ({ condition, keepAlive = false, children }) => {
if (!children) {
return null;
}
Expand Down
5 changes: 1 addition & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ export interface AsyncSupportProps {
* Extend ComponentWithConditionProps
* to also support async
*/
export type ComponentWithConditionPropsAsyncSupport<C extends 'with-function-children' | 'without-function-children'> =
C extends 'with-function-children'
? ComponentWithConditionPropsWithFunctionChildren<AsyncSupportProps>
: ComponentWithConditionProps<AsyncSupportProps>;
export type ComponentWithConditionPropsAsyncSupport = ComponentWithConditionProps<AsyncSupportProps>;

export type FCWithImplicitChildren<P = NonNullObject> = FunctionComponentWithImplicitChildren<P>;

Expand Down

0 comments on commit c8b566b

Please sign in to comment.