Skip to content

Commit

Permalink
Fixed typings.
Browse files Browse the repository at this point in the history
  • Loading branch information
radekmie committed Jan 19, 2021
1 parent 8645ac1 commit be843c7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
8 changes: 5 additions & 3 deletions packages/uniforms-antd/__tests__/SelectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,11 @@ test('<SelectField> - disabled items (options) based on predicate', () => {
}),
);

expect(wrapper.find(Select).prop('children')).toHaveLength(2);
expect(wrapper.find(Select).prop('children')[0].props.disabled).toBe(true);
expect(wrapper.find(Select).prop('children')[1].props.disabled).toBe(false);
// FIXME: The `children` prop is not indexable on its own.
const children: any = wrapper.find(Select).prop('children');
expect(children).toHaveLength(2);
expect(children[0].props.disabled).toBe(true);
expect(children[1].props.disabled).toBe(false);
});

test('<SelectField checkboxes> - renders a set of checkboxes', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/uniforms-antd/src/BoolField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export type BoolFieldProps = FieldProps<
{
checkbox?: boolean;
checkedChildren?: ReactNode;
// FIXME: `Switch` is a value and exporting `typeof Switch` type is impossible.
inputRef?: Ref<Checkbox | typeof Switch | any>;
inputRef?: Ref<typeof Checkbox | typeof Switch | any>;
unCheckedChildren?: ReactNode;
}
>;
Expand Down
2 changes: 1 addition & 1 deletion packages/uniforms-antd/src/ListDelField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function ListDel({
disabled,
icon = <DeleteOutlined />,
name,
shape = 'circle-outline',
shape = 'circle',
size = 'small',
type = 'ghost',
...props
Expand Down
4 changes: 2 additions & 2 deletions packages/uniforms-antd/src/LongTextField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TextArea, { TextAreaProps } from 'antd/lib/input/TextArea';
import TextArea, { TextAreaProps, TextAreaRef } from 'antd/lib/input/TextArea';
import React, { Ref } from 'react';
import { FieldProps, connectField, filterDOMProps } from 'uniforms';

Expand All @@ -8,7 +8,7 @@ export type LongTextFieldProps = FieldProps<
string,
// FIXME: Why `onReset` fails with `wrapField`?
Omit<TextAreaProps, 'onReset'>,
{ inputRef?: Ref<TextArea> }
{ inputRef?: Ref<TextAreaRef> }
>;

function LongText({ rows = 5, ...props }: LongTextFieldProps) {
Expand Down
7 changes: 4 additions & 3 deletions packages/uniforms-antd/src/SelectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type CheckboxesProps = FieldProps<
allowedValues?: CheckboxValueType[];
checkboxes: true;
disableItem?(value: CheckboxValueType): boolean;
inputRef?: Ref<CheckboxGroup | typeof RadioGroup>;
inputRef?: Ref<typeof CheckboxGroup | typeof RadioGroup>;
required?: boolean;
transform?(value: CheckboxValueType): string;
}
Expand All @@ -30,7 +30,7 @@ type SelectProps = FieldProps<
allowedValues?: string[];
checkboxes?: false;
disableItem?(value: CheckboxValueType): boolean;
inputRef?: Ref<SelectAntD<string | string[]>>;
inputRef?: Ref<typeof SelectAntD>;
required?: boolean;
transform?(value: string): string;
}
Expand All @@ -43,6 +43,7 @@ function Select(props: SelectFieldProps) {
return wrapField(
props,
props.checkboxes ? (
// @ts-ignore: Incorrect `value` type.
<Group
disabled={props.disabled}
name={props.name}
Expand All @@ -65,10 +66,10 @@ function Select(props: SelectFieldProps) {
allowClear={!props.required}
disabled={props.disabled}
mode={props.fieldType === Array ? 'multiple' : undefined}
// @ts-ignore: There's no `name` property on Select?
name={props.name}
onChange={value => props.onChange(value)}
placeholder={props.placeholder}
// @ts-ignore: Incorrect `inputRef` type.
ref={props.inputRef}
value={
props.fieldType === Array
Expand Down
3 changes: 2 additions & 1 deletion packages/uniforms/__tests__/BaseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ describe('BaseForm', () => {
});

it('sets `submitting` state while submitting', async () => {
let resolveSubmit = () => {};
// FIXME: It should say `() => void`.
let resolveSubmit: (...args: any[]) => void = () => {};
wrapper.setProps({
onSubmit: () => new Promise(resolve => (resolveSubmit = resolve)),
});
Expand Down

0 comments on commit be843c7

Please sign in to comment.