Skip to content

Commit

Permalink
Merge pull request #519 from Yoctol/fix/select-generic-type
Browse files Browse the repository at this point in the history
fix(select): generic types
  • Loading branch information
jigsawye authored Mar 16, 2021
2 parents 82ff65a + ca9831e commit 239e13a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/lab/Select/MultipleSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {
PropsWithoutRef,
ReactElement,
ReactNode,
Ref,
forwardRef,
Expand Down Expand Up @@ -28,7 +29,7 @@ import {
useSelectOptions,
} from './utils';

interface MultipleSelectProps<T extends SelectOption = SelectOption> {
interface MultipleSelectProps<T extends SelectOption> {
id?: string;
loading?: boolean;
searchable?: boolean;
Expand Down Expand Up @@ -241,6 +242,8 @@ const MultipleSelect = forwardRef(function MultipleSelect<
/>
</div>
);
});
}) as <T extends SelectOption>(
p: PropsWithoutRef<MultipleSelectProps<T>> & { ref?: Ref<HTMLDivElement> }
) => ReactElement;

export { MultipleSelect };
7 changes: 5 additions & 2 deletions src/lab/Select/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {
PropsWithoutRef,
ReactElement,
ReactNode,
Ref,
forwardRef,
Expand All @@ -23,7 +24,7 @@ import {
import { SelectOption, SelectValue } from './types';
import { StyledSelect } from './styles';

interface SelectProps<T extends SelectOption = SelectOption, V = T | null> {
interface SelectProps<T extends SelectOption, V = T | null> {
id?: string;
loading?: boolean;
searchable?: boolean;
Expand Down Expand Up @@ -197,6 +198,8 @@ const Select = forwardRef(function Select<T extends SelectOption>(
/>
</div>
);
});
}) as <T extends SelectOption>(
p: PropsWithoutRef<SelectProps<T>> & { ref?: Ref<HTMLDivElement> }
) => ReactElement;

export { Select };

0 comments on commit 239e13a

Please sign in to comment.