Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint: Remove ts-ignore #10961

Merged
merged 2 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import React, { SyntheticEvent, MutableRefObject } from 'react';
import React, { SyntheticEvent, MutableRefObject, ComponentType } from 'react';
import { merge } from 'lodash';
import BasicSelect, {
OptionTypeBase,
Expand All @@ -39,6 +39,7 @@ import {
SortableContainerProps,
} from 'react-sortable-hoc';
import arrayMove from 'array-move';
import { Props as SelectProps } from 'react-select/src/Select';
import {
WindowedSelectComponentType,
WindowedSelectProps,
Expand Down Expand Up @@ -93,9 +94,11 @@ export type SupersetStyledSelectProps<

function styled<
OptionType extends OptionTypeBase,
SelectComponentType extends WindowedSelectComponentType<
SelectComponentType extends
| WindowedSelectComponentType<OptionType>
| ComponentType<SelectProps<OptionType>> = WindowedSelectComponentType<
OptionType
> = WindowedSelectComponentType<OptionType>
>
>(SelectComponent: SelectComponentType) {
type SelectProps = SupersetStyledSelectProps<OptionType>;
type Components = SelectComponents<OptionType>;
Expand Down Expand Up @@ -287,7 +290,5 @@ export const Select = styled(WindowedSelect);
export const AsyncSelect = styled(WindowedAsyncSelect);
export const CreatableSelect = styled(WindowedCreatableSelect);
export const AsyncCreatableSelect = styled(WindowedAsyncCreatableSelect);
// Wrap with async pagination (infinite scroll). Cannot use windowed since options are appended dynamically which causes focus jumping
// @ts-ignore
export const PaginatedSelect = withAsyncPaginate(styled(BasicSelect));
export default Select;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import React, {
Component,
FunctionComponent,
RefObject,
ReactElement,
} from 'react';
import {
ListChildComponentProps,
Expand Down Expand Up @@ -53,10 +54,15 @@ export type WindowedMenuListProps = {
* If may also be `Component<GroupProps<OptionType>>[]` but we are not supporting
* grouped options just yet.
*/

type MenuListPropsChildren<OptionType> =
| Component<OptionProps<OptionType>>[]
| ReactElement[];

export type MenuListProps<
OptionType extends OptionTypeBase
> = MenuListComponentProps<OptionType> & {
children: Component<OptionProps<OptionType>>[];
children: MenuListPropsChildren<OptionType>;
// theme is not present with built-in @types/react-select, but is actually
// available via CommonProps.
theme?: ThemeConfig;
Expand All @@ -68,7 +74,7 @@ const DEFAULT_OPTION_HEIGHT = 30;
/**
* Get the index of the last selected option.
*/
function getLastSelected(children: Component<any>[]) {
function getLastSelected(children: MenuListPropsChildren<any>) {
return Array.isArray(children)
? children.findIndex(
({ props: { isFocused = false } = {} }) => isFocused,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import React, { ComponentType, FunctionComponent } from 'react';
import React, { ComponentType, FunctionComponent, ReactElement } from 'react';
import Select, {
Props as SelectProps,
OptionTypeBase,
Expand Down Expand Up @@ -47,8 +47,11 @@ export function MenuList<OptionType extends OptionTypeBase>({
}) {
const { windowThreshold = DEFAULT_WINDOW_THRESHOLD } = props.selectProps;
if (Array.isArray(children) && children.length > windowThreshold) {
// @ts-ignore
return <WindowedMenuList {...props}>{children}</WindowedMenuList>;
return (
<WindowedMenuList {...props}>
{children as ReactElement[]}
</WindowedMenuList>
);
}
return <DefaultMenuList {...props}>{children}</DefaultMenuList>;
}
Expand Down