Skip to content

Commit

Permalink
Replaced ts-ignore with ts-expect-error.
Browse files Browse the repository at this point in the history
  • Loading branch information
radekmie committed Feb 26, 2021
1 parent 12e88a1 commit 94d48fc
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 70 deletions.
6 changes: 3 additions & 3 deletions packages/uniforms-antd/__tests__/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test('<DateField> - renders an input with correct readOnly state', () => {
);

expect(wrapper.find(DatePicker)).toHaveLength(1);
// @ts-ignore
// @ts-expect-error
expect(wrapper.find(DatePicker).prop('onChange')(now)).toBeFalsy();
expect(onChange).not.toHaveBeenCalled();
});
Expand Down Expand Up @@ -119,7 +119,7 @@ test('<DateField> - renders a input which correctly reacts on change', () => {
);

expect(wrapper.find(DatePicker)).toHaveLength(1);
// @ts-ignore
// @ts-expect-error
expect(wrapper.find(DatePicker).prop('onChange')(now)).toBeFalsy();
expect(onChange).toHaveBeenLastCalledWith('x', now.toDate());
});
Expand All @@ -134,7 +134,7 @@ test('<DateField> - renders a input which correctly reacts on change (empty)', (
);

expect(wrapper.find(DatePicker)).toHaveLength(1);
// @ts-ignore
// @ts-expect-error
expect(wrapper.find(DatePicker).prop('onChange')(undefined)).toBeFalsy();
expect(onChange).toHaveBeenLastCalledWith('x', undefined);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/uniforms-antd/__tests__/RadioField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test('<RadioField> - renders a set of checkboxes with correct readOnly state', (

expect(wrapper.find(Radio.Group)).toHaveLength(1);
expect(
// @ts-ignore
// @ts-expect-error
wrapper.find(Radio.Group).prop('onChange')({ target: { value: 'b' } }),
).toBeFalsy();
expect(onChange).not.toHaveBeenCalled();
Expand Down Expand Up @@ -153,7 +153,7 @@ test('<RadioField> - renders a set of checkboxes which correctly reacts on chang

expect(wrapper.find(Radio.Group)).toHaveLength(1);
expect(
// @ts-ignore
// @ts-expect-error
wrapper.find(Radio.Group).prop('onChange')({ target: { value: 'b' } }),
).toBeFalsy();
expect(onChange).toHaveBeenLastCalledWith('x', 'b');
Expand All @@ -173,7 +173,7 @@ test('<RadioField> - renders a set of checkboxes which correctly reacts on chang

expect(wrapper.find(Radio.Group)).toHaveLength(1);
expect(
// @ts-ignore
// @ts-expect-error
wrapper.find(Radio.Group).prop('onChange')({ target: { value: 'a' } }),
).toBeFalsy();
expect(onChange).toHaveBeenLastCalledWith('x', 'a');
Expand Down
20 changes: 10 additions & 10 deletions packages/uniforms-antd/__tests__/SelectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ test('<SelectField> - renders a select with correct name', () => {
});

test('<SelectField> - renders a select with correct options', () => {
// @ts-ignore Is open a valid prop?
// @ts-expect-error Is open a valid prop?
const element = <SelectField name="x" open />;
const wrapper = mount(
element,
Expand All @@ -88,19 +88,19 @@ test('<SelectField> - renders a select with correct options', () => {

expect(wrapper.find(Select)).toHaveLength(1);
expect(wrapper.find(Select).prop('children')).toHaveLength(2);
// @ts-ignore Check children type.
// @ts-expect-error Check children type.
expect(wrapper.find(Select).prop('children')[0].props.value).toBe('a');
// @ts-ignore Check children type.
// @ts-expect-error Check children type.
expect(wrapper.find(Select).prop('children')[0].props.children).toBe('a');
// @ts-ignore Check children type.
// @ts-expect-error Check children type.
expect(wrapper.find(Select).prop('children')[1].props.value).toBe('b');
// @ts-ignore Check children type.
// @ts-expect-error Check children type.
expect(wrapper.find(Select).prop('children')[1].props.children).toBe('b');
});

test('<SelectField> - renders a select with correct options (transform)', () => {
const element = (
// @ts-ignore Is open a valid prop?
// @ts-expect-error Is open a valid prop?
<SelectField name="x" open transform={x => x.toUpperCase()} />
);
const wrapper = mount(
Expand All @@ -110,13 +110,13 @@ test('<SelectField> - renders a select with correct options (transform)', () =>

expect(wrapper.find(Select)).toHaveLength(1);
expect(wrapper.find(Select).prop('children')).toHaveLength(2);
// @ts-ignore Check children type.
// @ts-expect-error Check children type.
expect(wrapper.find(Select).prop('children')[0].props.value).toBe('a');
// @ts-ignore Check children type.
// @ts-expect-error Check children type.
expect(wrapper.find(Select).prop('children')[0].props.children).toBe('A');
// @ts-ignore Check children type.
// @ts-expect-error Check children type.
expect(wrapper.find(Select).prop('children')[1].props.value).toBe('b');
// @ts-ignore Check children type.
// @ts-expect-error Check children type.
expect(wrapper.find(Select).prop('children')[1].props.children).toBe('B');
});

Expand Down
2 changes: 1 addition & 1 deletion packages/uniforms-antd/__tests__/wrapField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('<wrapField> - renders wrapper with label', () => {
const element = wrapField({ label: 'Label' }, <div />);
const wrapper = mount(element);

// @ts-ignore Correct label type.
// @ts-expect-error Correct label type.
expect(wrapper.find(Form.Item).prop('label').props.children[0]).toBe('Label');
});

Expand Down
2 changes: 1 addition & 1 deletion packages/uniforms-antd/src/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Date({
}
}}
placeholder={props.placeholder}
// @ts-ignore: `DatePicker` is an intersection.
// @ts-expect-error: `DatePicker` is an intersection.
ref={props.inputRef}
showTime={showTime}
style={style}
Expand Down
4 changes: 2 additions & 2 deletions packages/uniforms-antd/src/SelectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function Select(props: SelectFieldProps) {
return wrapField(
props,
props.checkboxes ? (
// @ts-ignore: Incorrect `value` type.
// @ts-expect-error: Incorrect `value` type.
<Group
disabled={props.disabled}
name={props.name}
Expand Down Expand Up @@ -81,7 +81,7 @@ function Select(props: SelectFieldProps) {
}
}}
placeholder={props.placeholder}
// @ts-ignore: Incorrect `inputRef` type.
// @ts-expect-error: Incorrect `inputRef` type.
ref={props.inputRef}
value={
props.fieldType === Array
Expand Down
2 changes: 1 addition & 1 deletion packages/uniforms-bootstrap4/src/gridClassName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function gridClassName(
return (
(Object.keys(grid) as GridSize[])
.sort(compareSizeClass)
// @ts-ignore Weird type refinement problem.
// @ts-expect-error Weird type refinement problem.
.map(size => gridClassNamePart(size, grid[size], side))
.join(' ')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class SimpleSchema2Bridge extends Bridge {

getErrorMessage(name: string, error: any) {
const scopedError = this.getError(name, error);
// @ts-ignore: `messageForError` has incorrect typing.
// @ts-expect-error: `messageForError` has incorrect typing.
return !scopedError ? '' : this.schema.messageForError(scopedError);
}

Expand All @@ -30,7 +30,7 @@ export default class SimpleSchema2Bridge extends Bridge {
if (Array.isArray(error.details)) {
// FIXME: Correct type for `error`.
return (error.details as any[]).map(error =>
// @ts-ignore: `messageForError` has incorrect typing.
// @ts-expect-error: `messageForError` has incorrect typing.
this.schema.messageForError(error),
);
}
Expand Down Expand Up @@ -146,7 +146,7 @@ export default class SimpleSchema2Bridge extends Bridge {
}

getSubfields(name?: string) {
// @ts-ignore: Typing for `_makeGeneric` is missing.
// @ts-expect-error: Typing for `_makeGeneric` is missing.
return this.schema.objectKeys(SimpleSchema._makeGeneric(name));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('SimpleSchemaBridge', () => {
// Simulate SimpleSchema.
name = name.replace(/\d+/g, '$');

// @ts-ignore: Dynamic `name`.
// @ts-expect-error: Dynamic `name`.
const field = {
a: { type: Object, label: name },
'a.b': { type: Object, label: name },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import invariant from 'invariant';
import cloneDeep from 'lodash/cloneDeep';
import memoize from 'lodash/memoize';
// @ts-ignore
// @ts-expect-error
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { Bridge, joinName } from 'uniforms';

Expand Down
4 changes: 2 additions & 2 deletions packages/uniforms-bridge-simple-schema/src/register.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-ignore
// @ts-expect-error
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
// @ts-ignore
// @ts-expect-error
import { Match } from 'meteor/check';
import { filterDOMProps } from 'uniforms';

Expand Down
6 changes: 3 additions & 3 deletions packages/uniforms-material/__tests__/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ test('<DateField> - renders a Input which correctly reacts on change', () => {
createContext({ x: { type: Date } }, { onChange }),
);

// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(Input).props().onChange!({ target: { valueAsNumber: now } });
expect(onChange).toHaveBeenLastCalledWith('x', now);
});
Expand All @@ -112,7 +112,7 @@ test('<DateField> - renders a Input which correctly reacts on change (empty)', (
);

wrapper.find(Input).props().onChange!({
// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
target: { valueAsNumber: undefined },
});
expect(onChange).toHaveBeenLastCalledWith('x', undefined);
Expand All @@ -128,7 +128,7 @@ test('<DateField> - renders a Input which correctly reacts on change (overflow)'
createContext({ x: { type: Date } }, { onChange }),
);

// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(Input).props().onChange!({ target: { valueAsNumber: now } });
expect(onChange).not.toHaveBeenCalled();
});
Expand Down
6 changes: 3 additions & 3 deletions packages/uniforms-material/__tests__/LongTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ test('<LongTextField> - renders a TextField which correctly reacts on change', (
);

expect(wrapper.find(TextField)).toHaveLength(1);
// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(TextField).props().onChange!({ target: { value: 'y' } });
expect(onChange).toHaveBeenLastCalledWith('x', 'y');
});
Expand All @@ -112,7 +112,7 @@ test('<LongTextField> - renders a TextField which correctly reacts on change (em
);

expect(wrapper.find(TextField)).toHaveLength(1);
// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(TextField).props().onChange!({ target: { value: '' } });
expect(onChange).toHaveBeenLastCalledWith('x', '');
});
Expand All @@ -127,7 +127,7 @@ test('<LongTextField> - renders a TextField which correctly reacts on change (sa
);

expect(wrapper.find(TextField)).toHaveLength(1);
// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(TextField).props().onChange!({ target: { value: 'y' } });
expect(onChange).toHaveBeenLastCalledWith('x', 'y');
});
Expand Down
12 changes: 6 additions & 6 deletions packages/uniforms-material/__tests__/NumField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ test('<NumField> - renders a TextField which correctly reacts on change', () =>
);

expect(wrapper.find(TextField)).toHaveLength(1);
// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(TextField).props().onChange!({ target: { value: '1' } });
expect(onChange).toHaveBeenLastCalledWith('x', 1);
});
Expand All @@ -191,7 +191,7 @@ test('<NumField> - renders a TextField which correctly reacts on change (decimal
);

expect(wrapper.find(TextField)).toHaveLength(1);
// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(TextField).props().onChange!({ target: { value: '2.5' } });
expect(onChange).toHaveBeenLastCalledWith('x', 2.5);
});
Expand All @@ -206,7 +206,7 @@ test('<NumField> - renders a TextField which correctly reacts on change (decimal
);

expect(wrapper.find(TextField)).toHaveLength(1);
// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(TextField).props().onChange!({ target: { value: '2.5' } });
expect(onChange).toHaveBeenLastCalledWith('x', 2);
});
Expand All @@ -221,7 +221,7 @@ test('<NumField> - renders a TextField which correctly reacts on change (empty)'
);

expect(wrapper.find(TextField)).toHaveLength(1);
// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(TextField).props().onChange!({ target: { value: '' } });
expect(onChange).toHaveBeenLastCalledWith('x', undefined);
});
Expand All @@ -236,7 +236,7 @@ test('<NumField> - renders a TextField which correctly reacts on change (same va
);

expect(wrapper.find(TextField)).toHaveLength(1);
// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(TextField).props().onChange!({ target: { value: '1' } });
expect(onChange).toHaveBeenLastCalledWith('x', 1);
});
Expand All @@ -251,7 +251,7 @@ test('<NumField> - renders a TextField which correctly reacts on change (zero)',
);

expect(wrapper.find(TextField)).toHaveLength(1);
// @ts-ignore Provide a valid EventTarget.
// @ts-expect-error Provide a valid EventTarget.
wrapper.find(TextField).props().onChange!({ target: { value: '0' } });
expect(onChange).toHaveBeenLastCalledWith('x', 0);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/uniforms-material/__tests__/RadioField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ test('<RadioField> - renders a RadioGroup which correctly reacts on change', ()
);

expect(wrapper.find(RadioGroup)).toHaveLength(1);
// @ts-ignore Provide a valid value.
// @ts-expect-error Provide a valid value.
wrapper.find(RadioGroup).props().onChange!({ target: { value: 'b' } });
expect(onChange).toHaveBeenLastCalledWith('x', 'b');
});
Expand All @@ -165,7 +165,7 @@ test('<RadioField> - renders a RadioGroup which correctly reacts on change (same
);

expect(wrapper.find(RadioGroup)).toHaveLength(1);
// @ts-ignore Provide a valid value.
// @ts-expect-error Provide a valid value.
wrapper.find(RadioGroup).props().onChange!({ target: { value: 'a' } });
expect(onChange).toHaveBeenLastCalledWith('x', 'a');
});
Expand Down
Loading

0 comments on commit 94d48fc

Please sign in to comment.