fix: make name required on field types (#337)

* fix: make name required on field types

* fix: improve typescript types
This commit is contained in:
Dan Ribbens
2021-10-11 15:52:18 -04:00
committed by GitHub
parent d0259ceecd
commit b257e01c8d
8 changed files with 20 additions and 10 deletions

View File

@@ -1,9 +1,10 @@
import React, { Suspense, lazy } from 'react';
import Loading from '../../../elements/Loading';
import { Props } from './types';
const Code = lazy(() => import('./Code'));
const CodeField: React.FC = (props) => (
const CodeField: React.FC<Props> = (props) => (
<Suspense fallback={<Loading />}>
<Code {...props} />
</Suspense>

View File

@@ -8,7 +8,7 @@ const withCondition = <P extends Record<string, unknown>>(Field: React.Component
admin: {
condition,
} = {},
} = props as FieldBase;
} = props as Partial<FieldBase>;
if (condition) {
return <WithCondition {...props} />;
@@ -24,7 +24,7 @@ const withCondition = <P extends Record<string, unknown>>(Field: React.Component
admin: {
condition,
} = {},
} = props as FieldBase & {
} = props as Partial<FieldBase> & {
path?: string
};

View File

@@ -119,6 +119,7 @@ describe('Cell Types', () => {
describe('Select', () => {
const fieldWithOptionsObject: SelectField = {
type: 'select',
name: 'selectObject',
options: [{
value: 'one',
label: 'One',
@@ -129,6 +130,7 @@ describe('Cell Types', () => {
};
const fieldWithStringsOptions: SelectField = {
type: 'select',
name: 'selectString',
options: ['blue', 'green', 'yellow'],
};
it('renders options objects', () => {