diff --git a/src/admin/components/elements/Banner/index.tsx b/src/admin/components/elements/Banner/index.tsx index 3bea04b684..6e16058e4d 100644 --- a/src/admin/components/elements/Banner/index.tsx +++ b/src/admin/components/elements/Banner/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { Link } from 'react-router-dom'; -import { Props } from './types'; +import { Props, RenderedTypeProps } from './types'; import './index.scss'; @@ -25,7 +25,7 @@ const Banner: React.FC = ({ icon && `${baseClass}--align-icon-${alignIcon}`, ].filter(Boolean).join(' '); - let RenderedType = 'div'; + let RenderedType: string | React.ComponentType = 'div'; if (onClick && !to) RenderedType = 'button'; if (to) RenderedType = Link; @@ -34,7 +34,6 @@ const Banner: React.FC = ({ {(icon && alignIcon === 'left') && ( diff --git a/src/admin/components/elements/Banner/types.ts b/src/admin/components/elements/Banner/types.ts index a7e366b31e..9cd1d45e7e 100644 --- a/src/admin/components/elements/Banner/types.ts +++ b/src/admin/components/elements/Banner/types.ts @@ -1,11 +1,19 @@ import { MouseEvent } from 'react'; +type onClick = (event: MouseEvent) => void + export type Props = { children?: React.ReactNode, className?: string, icon?: React.ReactNode, alignIcon?: 'left' | 'right', - onClick?: (event: MouseEvent) => void, + onClick?: onClick to?: string, type?: 'error' | 'success' | 'info' | 'default', } + +export type RenderedTypeProps = { + className?: string + onClick?: onClick + to: string +} diff --git a/src/admin/components/elements/ColumnSelector/getInitialState.tsx b/src/admin/components/elements/ColumnSelector/getInitialState.ts similarity index 70% rename from src/admin/components/elements/ColumnSelector/getInitialState.tsx rename to src/admin/components/elements/ColumnSelector/getInitialState.ts index 041985d494..e2fb7d8a0a 100644 --- a/src/admin/components/elements/ColumnSelector/getInitialState.tsx +++ b/src/admin/components/elements/ColumnSelector/getInitialState.ts @@ -1,4 +1,6 @@ -const getInitialColumnState = (fields, useAsTitle, defaultColumns) => { +import { Field, fieldHasSubFields } from '../../../../fields/config/types'; + +const getInitialColumnState = (fields: Field[], useAsTitle: string, defaultColumns: string[]): { columns: string[] } => { let initialColumns = []; if (Array.isArray(defaultColumns) && defaultColumns.length >= 1) { @@ -17,7 +19,7 @@ const getInitialColumnState = (fields, useAsTitle, defaultColumns) => { return remaining; } - if (!field.name && Array.isArray(field.fields)) { + if (!field.name && fieldHasSubFields(field)) { return [ ...remaining, ...field.fields.map((subField) => subField.name), @@ -39,4 +41,4 @@ const getInitialColumnState = (fields, useAsTitle, defaultColumns) => { }; -module.exports = getInitialColumnState; +export default getInitialColumnState; diff --git a/src/admin/components/elements/ColumnSelector/types.ts b/src/admin/components/elements/ColumnSelector/types.ts index e44d71d2dd..a27578745b 100644 --- a/src/admin/components/elements/ColumnSelector/types.ts +++ b/src/admin/components/elements/ColumnSelector/types.ts @@ -1,6 +1,6 @@ -import { Collection } from '../../../../collections/config/types'; +import { CollectionConfig } from '../../../../collections/config/types'; export type Props = { - collection: Collection, + collection: CollectionConfig, handleChange: (columns) => void, } diff --git a/src/admin/components/elements/DatePicker/index.tsx b/src/admin/components/elements/DatePicker/index.tsx index e1297bc820..1143563725 100644 --- a/src/admin/components/elements/DatePicker/index.tsx +++ b/src/admin/components/elements/DatePicker/index.tsx @@ -3,7 +3,7 @@ import Loading from '../Loading'; const DatePicker = lazy(() => import('./DatePicker')); -export default (props) => ( +export default (props: unknown): React.ReactNode => ( }> diff --git a/src/admin/components/elements/DeleteDocument/index.tsx b/src/admin/components/elements/DeleteDocument/index.tsx index 8eef3fb4ec..6b96dd5105 100644 --- a/src/admin/components/elements/DeleteDocument/index.tsx +++ b/src/admin/components/elements/DeleteDocument/index.tsx @@ -83,7 +83,6 @@ const DeleteDocument: React.FC = (props) => {