Skip to content

Commit

Permalink
type(Checkbox): Enhanced type derivation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 30, 2020
1 parent 22ea08e commit fd8009d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
15 changes: 7 additions & 8 deletions packages/react-breadcrumb/src/Breadcrumb.tsx
Expand Up @@ -31,14 +31,13 @@ function InternalBreadcrumb(props: BreadcrumbProps = {}) {
);
}

interface CompoundedComponent
extends React.ForwardRefExoticComponent<BreadcrumbProps> {
Item: typeof Item;
}

const Breadcrumb = React.forwardRef<unknown, BreadcrumbProps>(
InternalBreadcrumb,
) as CompoundedComponent;
Breadcrumb.Item = Item;
);
type Breadcrumb = typeof Breadcrumb & {
Item: typeof Item;
};

(Breadcrumb as Breadcrumb).Item = Item;

export default Breadcrumb;
export default Breadcrumb as Breadcrumb;
14 changes: 6 additions & 8 deletions packages/react-checkbox/src/Checkbox.tsx
Expand Up @@ -40,15 +40,13 @@ function InternalCheckbox(
);
}

interface CompoundedComponent
extends React.ForwardRefExoticComponent<CheckboxProps> {
Group: typeof CheckboxGroup;
}

const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
InternalCheckbox,
) as CompoundedComponent;
);
type Checkbox = typeof Checkbox & {
Group: typeof CheckboxGroup;
};

Checkbox.Group = CheckboxGroup;
(Checkbox as Checkbox).Group = CheckboxGroup;

export default Checkbox;
export default Checkbox as Checkbox;
3 changes: 0 additions & 3 deletions packages/react-checkbox/src/index.ts
@@ -1,7 +1,4 @@
import Checkbox from './Checkbox';
import { CheckboxGroup } from './Group';

Checkbox.Group = CheckboxGroup;

export * from './Checkbox';
export * from './Group';
Expand Down

0 comments on commit fd8009d

Please sign in to comment.