From f03b63770ffff16da922ae741a17d40d8daff887 Mon Sep 17 00:00:00 2001 From: wadamek65 Date: Tue, 24 Aug 2021 15:23:33 +0200 Subject: [PATCH 1/7] Added explicit form type casting (except BaseForm). --- packages/uniforms-antd/src/AutoForm.tsx | 4 ++-- packages/uniforms-antd/src/QuickForm.tsx | 4 ++-- packages/uniforms-antd/src/ValidatedForm.tsx | 4 ++-- packages/uniforms-antd/src/ValidatedQuickForm.tsx | 6 +++++- packages/uniforms-bootstrap3/src/AutoForm.tsx | 4 ++-- packages/uniforms-bootstrap3/src/QuickForm.tsx | 4 ++-- packages/uniforms-bootstrap3/src/ValidatedForm.tsx | 4 ++-- packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx | 6 +++++- packages/uniforms-bootstrap4/src/AutoForm.tsx | 4 ++-- packages/uniforms-bootstrap4/src/QuickForm.tsx | 4 ++-- packages/uniforms-bootstrap4/src/ValidatedForm.tsx | 4 ++-- packages/uniforms-bootstrap4/src/ValidatedQuickForm.tsx | 6 +++++- packages/uniforms-bootstrap5/src/AutoForm.tsx | 4 ++-- packages/uniforms-bootstrap5/src/QuickForm.tsx | 4 ++-- packages/uniforms-bootstrap5/src/ValidatedForm.tsx | 4 ++-- packages/uniforms-bootstrap5/src/ValidatedQuickForm.tsx | 6 +++++- packages/uniforms-material/src/AutoForm.tsx | 4 ++-- packages/uniforms-material/src/QuickForm.tsx | 4 ++-- packages/uniforms-material/src/ValidatedForm.tsx | 4 ++-- packages/uniforms-material/src/ValidatedQuickForm.tsx | 6 +++++- packages/uniforms-semantic/src/AutoForm.tsx | 4 ++-- packages/uniforms-semantic/src/QuickForm.tsx | 4 ++-- packages/uniforms-semantic/src/ValidatedForm.tsx | 4 ++-- packages/uniforms-semantic/src/ValidatedQuickForm.tsx | 6 +++++- packages/uniforms-unstyled/src/AutoForm.tsx | 4 ++-- packages/uniforms-unstyled/src/QuickForm.tsx | 4 ++-- packages/uniforms-unstyled/src/ValidatedForm.tsx | 4 ++-- packages/uniforms-unstyled/src/ValidatedQuickForm.tsx | 6 +++++- 28 files changed, 77 insertions(+), 49 deletions(-) diff --git a/packages/uniforms-antd/src/AutoForm.tsx b/packages/uniforms-antd/src/AutoForm.tsx index a8f25da9c..dd83b25bb 100644 --- a/packages/uniforms-antd/src/AutoForm.tsx +++ b/packages/uniforms-antd/src/AutoForm.tsx @@ -2,12 +2,12 @@ import { AutoForm } from 'uniforms'; import ValidatedQuickForm from './ValidatedQuickForm'; -function Auto(parent: any): any { +function Auto(parent: any) { class _ extends AutoForm.Auto(parent) { static Auto = Auto; } - return _; + return (_ as unknown) as AutoForm; } export default Auto(ValidatedQuickForm); diff --git a/packages/uniforms-antd/src/QuickForm.tsx b/packages/uniforms-antd/src/QuickForm.tsx index c12584608..99930e213 100644 --- a/packages/uniforms-antd/src/QuickForm.tsx +++ b/packages/uniforms-antd/src/QuickForm.tsx @@ -5,7 +5,7 @@ import BaseForm from './BaseForm'; import ErrorsField from './ErrorsField'; import SubmitField from './SubmitField'; -function Quick(parent: any): any { +function Quick(parent: any) { class _ extends QuickForm.Quick(parent) { static Quick = Quick; @@ -22,7 +22,7 @@ function Quick(parent: any): any { } } - return _; + return (_ as unknown) as QuickForm; } export default Quick(BaseForm); diff --git a/packages/uniforms-antd/src/ValidatedForm.tsx b/packages/uniforms-antd/src/ValidatedForm.tsx index 15aa5dbb1..fa18a2d26 100644 --- a/packages/uniforms-antd/src/ValidatedForm.tsx +++ b/packages/uniforms-antd/src/ValidatedForm.tsx @@ -2,12 +2,12 @@ import { ValidatedForm } from 'uniforms'; import BaseForm from './BaseForm'; -function Validated(parent: any): any { +function Validated(parent: any) { class _ extends ValidatedForm.Validated(parent) { static Validated = Validated; } - return _; + return (_ as unknown) as ValidatedForm; } export default Validated(BaseForm); diff --git a/packages/uniforms-antd/src/ValidatedQuickForm.tsx b/packages/uniforms-antd/src/ValidatedQuickForm.tsx index 554624af2..83d33eb24 100644 --- a/packages/uniforms-antd/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-antd/src/ValidatedQuickForm.tsx @@ -1,5 +1,9 @@ +import { ValidatedQuickForm } from 'uniforms'; + import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); +export default ValidatedForm.Validated( + QuickForm.Quick(BaseForm), +) as ValidatedQuickForm; diff --git a/packages/uniforms-bootstrap3/src/AutoForm.tsx b/packages/uniforms-bootstrap3/src/AutoForm.tsx index a8f25da9c..dd83b25bb 100644 --- a/packages/uniforms-bootstrap3/src/AutoForm.tsx +++ b/packages/uniforms-bootstrap3/src/AutoForm.tsx @@ -2,12 +2,12 @@ import { AutoForm } from 'uniforms'; import ValidatedQuickForm from './ValidatedQuickForm'; -function Auto(parent: any): any { +function Auto(parent: any) { class _ extends AutoForm.Auto(parent) { static Auto = Auto; } - return _; + return (_ as unknown) as AutoForm; } export default Auto(ValidatedQuickForm); diff --git a/packages/uniforms-bootstrap3/src/QuickForm.tsx b/packages/uniforms-bootstrap3/src/QuickForm.tsx index c12584608..99930e213 100644 --- a/packages/uniforms-bootstrap3/src/QuickForm.tsx +++ b/packages/uniforms-bootstrap3/src/QuickForm.tsx @@ -5,7 +5,7 @@ import BaseForm from './BaseForm'; import ErrorsField from './ErrorsField'; import SubmitField from './SubmitField'; -function Quick(parent: any): any { +function Quick(parent: any) { class _ extends QuickForm.Quick(parent) { static Quick = Quick; @@ -22,7 +22,7 @@ function Quick(parent: any): any { } } - return _; + return (_ as unknown) as QuickForm; } export default Quick(BaseForm); diff --git a/packages/uniforms-bootstrap3/src/ValidatedForm.tsx b/packages/uniforms-bootstrap3/src/ValidatedForm.tsx index 15aa5dbb1..fa18a2d26 100644 --- a/packages/uniforms-bootstrap3/src/ValidatedForm.tsx +++ b/packages/uniforms-bootstrap3/src/ValidatedForm.tsx @@ -2,12 +2,12 @@ import { ValidatedForm } from 'uniforms'; import BaseForm from './BaseForm'; -function Validated(parent: any): any { +function Validated(parent: any) { class _ extends ValidatedForm.Validated(parent) { static Validated = Validated; } - return _; + return (_ as unknown) as ValidatedForm; } export default Validated(BaseForm); diff --git a/packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx b/packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx index 554624af2..83d33eb24 100644 --- a/packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx @@ -1,5 +1,9 @@ +import { ValidatedQuickForm } from 'uniforms'; + import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); +export default ValidatedForm.Validated( + QuickForm.Quick(BaseForm), +) as ValidatedQuickForm; diff --git a/packages/uniforms-bootstrap4/src/AutoForm.tsx b/packages/uniforms-bootstrap4/src/AutoForm.tsx index a8f25da9c..dd83b25bb 100644 --- a/packages/uniforms-bootstrap4/src/AutoForm.tsx +++ b/packages/uniforms-bootstrap4/src/AutoForm.tsx @@ -2,12 +2,12 @@ import { AutoForm } from 'uniforms'; import ValidatedQuickForm from './ValidatedQuickForm'; -function Auto(parent: any): any { +function Auto(parent: any) { class _ extends AutoForm.Auto(parent) { static Auto = Auto; } - return _; + return (_ as unknown) as AutoForm; } export default Auto(ValidatedQuickForm); diff --git a/packages/uniforms-bootstrap4/src/QuickForm.tsx b/packages/uniforms-bootstrap4/src/QuickForm.tsx index c12584608..99930e213 100644 --- a/packages/uniforms-bootstrap4/src/QuickForm.tsx +++ b/packages/uniforms-bootstrap4/src/QuickForm.tsx @@ -5,7 +5,7 @@ import BaseForm from './BaseForm'; import ErrorsField from './ErrorsField'; import SubmitField from './SubmitField'; -function Quick(parent: any): any { +function Quick(parent: any) { class _ extends QuickForm.Quick(parent) { static Quick = Quick; @@ -22,7 +22,7 @@ function Quick(parent: any): any { } } - return _; + return (_ as unknown) as QuickForm; } export default Quick(BaseForm); diff --git a/packages/uniforms-bootstrap4/src/ValidatedForm.tsx b/packages/uniforms-bootstrap4/src/ValidatedForm.tsx index 15aa5dbb1..fa18a2d26 100644 --- a/packages/uniforms-bootstrap4/src/ValidatedForm.tsx +++ b/packages/uniforms-bootstrap4/src/ValidatedForm.tsx @@ -2,12 +2,12 @@ import { ValidatedForm } from 'uniforms'; import BaseForm from './BaseForm'; -function Validated(parent: any): any { +function Validated(parent: any) { class _ extends ValidatedForm.Validated(parent) { static Validated = Validated; } - return _; + return (_ as unknown) as ValidatedForm; } export default Validated(BaseForm); diff --git a/packages/uniforms-bootstrap4/src/ValidatedQuickForm.tsx b/packages/uniforms-bootstrap4/src/ValidatedQuickForm.tsx index 554624af2..83d33eb24 100644 --- a/packages/uniforms-bootstrap4/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-bootstrap4/src/ValidatedQuickForm.tsx @@ -1,5 +1,9 @@ +import { ValidatedQuickForm } from 'uniforms'; + import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); +export default ValidatedForm.Validated( + QuickForm.Quick(BaseForm), +) as ValidatedQuickForm; diff --git a/packages/uniforms-bootstrap5/src/AutoForm.tsx b/packages/uniforms-bootstrap5/src/AutoForm.tsx index a8f25da9c..dd83b25bb 100644 --- a/packages/uniforms-bootstrap5/src/AutoForm.tsx +++ b/packages/uniforms-bootstrap5/src/AutoForm.tsx @@ -2,12 +2,12 @@ import { AutoForm } from 'uniforms'; import ValidatedQuickForm from './ValidatedQuickForm'; -function Auto(parent: any): any { +function Auto(parent: any) { class _ extends AutoForm.Auto(parent) { static Auto = Auto; } - return _; + return (_ as unknown) as AutoForm; } export default Auto(ValidatedQuickForm); diff --git a/packages/uniforms-bootstrap5/src/QuickForm.tsx b/packages/uniforms-bootstrap5/src/QuickForm.tsx index c12584608..99930e213 100644 --- a/packages/uniforms-bootstrap5/src/QuickForm.tsx +++ b/packages/uniforms-bootstrap5/src/QuickForm.tsx @@ -5,7 +5,7 @@ import BaseForm from './BaseForm'; import ErrorsField from './ErrorsField'; import SubmitField from './SubmitField'; -function Quick(parent: any): any { +function Quick(parent: any) { class _ extends QuickForm.Quick(parent) { static Quick = Quick; @@ -22,7 +22,7 @@ function Quick(parent: any): any { } } - return _; + return (_ as unknown) as QuickForm; } export default Quick(BaseForm); diff --git a/packages/uniforms-bootstrap5/src/ValidatedForm.tsx b/packages/uniforms-bootstrap5/src/ValidatedForm.tsx index 15aa5dbb1..fa18a2d26 100644 --- a/packages/uniforms-bootstrap5/src/ValidatedForm.tsx +++ b/packages/uniforms-bootstrap5/src/ValidatedForm.tsx @@ -2,12 +2,12 @@ import { ValidatedForm } from 'uniforms'; import BaseForm from './BaseForm'; -function Validated(parent: any): any { +function Validated(parent: any) { class _ extends ValidatedForm.Validated(parent) { static Validated = Validated; } - return _; + return (_ as unknown) as ValidatedForm; } export default Validated(BaseForm); diff --git a/packages/uniforms-bootstrap5/src/ValidatedQuickForm.tsx b/packages/uniforms-bootstrap5/src/ValidatedQuickForm.tsx index 554624af2..83d33eb24 100644 --- a/packages/uniforms-bootstrap5/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-bootstrap5/src/ValidatedQuickForm.tsx @@ -1,5 +1,9 @@ +import { ValidatedQuickForm } from 'uniforms'; + import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); +export default ValidatedForm.Validated( + QuickForm.Quick(BaseForm), +) as ValidatedQuickForm; diff --git a/packages/uniforms-material/src/AutoForm.tsx b/packages/uniforms-material/src/AutoForm.tsx index a8f25da9c..dd83b25bb 100644 --- a/packages/uniforms-material/src/AutoForm.tsx +++ b/packages/uniforms-material/src/AutoForm.tsx @@ -2,12 +2,12 @@ import { AutoForm } from 'uniforms'; import ValidatedQuickForm from './ValidatedQuickForm'; -function Auto(parent: any): any { +function Auto(parent: any) { class _ extends AutoForm.Auto(parent) { static Auto = Auto; } - return _; + return (_ as unknown) as AutoForm; } export default Auto(ValidatedQuickForm); diff --git a/packages/uniforms-material/src/QuickForm.tsx b/packages/uniforms-material/src/QuickForm.tsx index c12584608..99930e213 100644 --- a/packages/uniforms-material/src/QuickForm.tsx +++ b/packages/uniforms-material/src/QuickForm.tsx @@ -5,7 +5,7 @@ import BaseForm from './BaseForm'; import ErrorsField from './ErrorsField'; import SubmitField from './SubmitField'; -function Quick(parent: any): any { +function Quick(parent: any) { class _ extends QuickForm.Quick(parent) { static Quick = Quick; @@ -22,7 +22,7 @@ function Quick(parent: any): any { } } - return _; + return (_ as unknown) as QuickForm; } export default Quick(BaseForm); diff --git a/packages/uniforms-material/src/ValidatedForm.tsx b/packages/uniforms-material/src/ValidatedForm.tsx index 15aa5dbb1..fa18a2d26 100644 --- a/packages/uniforms-material/src/ValidatedForm.tsx +++ b/packages/uniforms-material/src/ValidatedForm.tsx @@ -2,12 +2,12 @@ import { ValidatedForm } from 'uniforms'; import BaseForm from './BaseForm'; -function Validated(parent: any): any { +function Validated(parent: any) { class _ extends ValidatedForm.Validated(parent) { static Validated = Validated; } - return _; + return (_ as unknown) as ValidatedForm; } export default Validated(BaseForm); diff --git a/packages/uniforms-material/src/ValidatedQuickForm.tsx b/packages/uniforms-material/src/ValidatedQuickForm.tsx index 554624af2..fcd7237b5 100644 --- a/packages/uniforms-material/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-material/src/ValidatedQuickForm.tsx @@ -1,5 +1,9 @@ +import { ValidatedQuickForm } from 'uniforms'; + import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); +export default ValidatedForm.Validated( + QuickForm.Quick(BaseForm), +) as typeof ValidatedQuickForm; diff --git a/packages/uniforms-semantic/src/AutoForm.tsx b/packages/uniforms-semantic/src/AutoForm.tsx index a8f25da9c..dd83b25bb 100644 --- a/packages/uniforms-semantic/src/AutoForm.tsx +++ b/packages/uniforms-semantic/src/AutoForm.tsx @@ -2,12 +2,12 @@ import { AutoForm } from 'uniforms'; import ValidatedQuickForm from './ValidatedQuickForm'; -function Auto(parent: any): any { +function Auto(parent: any) { class _ extends AutoForm.Auto(parent) { static Auto = Auto; } - return _; + return (_ as unknown) as AutoForm; } export default Auto(ValidatedQuickForm); diff --git a/packages/uniforms-semantic/src/QuickForm.tsx b/packages/uniforms-semantic/src/QuickForm.tsx index c12584608..99930e213 100644 --- a/packages/uniforms-semantic/src/QuickForm.tsx +++ b/packages/uniforms-semantic/src/QuickForm.tsx @@ -5,7 +5,7 @@ import BaseForm from './BaseForm'; import ErrorsField from './ErrorsField'; import SubmitField from './SubmitField'; -function Quick(parent: any): any { +function Quick(parent: any) { class _ extends QuickForm.Quick(parent) { static Quick = Quick; @@ -22,7 +22,7 @@ function Quick(parent: any): any { } } - return _; + return (_ as unknown) as QuickForm; } export default Quick(BaseForm); diff --git a/packages/uniforms-semantic/src/ValidatedForm.tsx b/packages/uniforms-semantic/src/ValidatedForm.tsx index 15aa5dbb1..fa18a2d26 100644 --- a/packages/uniforms-semantic/src/ValidatedForm.tsx +++ b/packages/uniforms-semantic/src/ValidatedForm.tsx @@ -2,12 +2,12 @@ import { ValidatedForm } from 'uniforms'; import BaseForm from './BaseForm'; -function Validated(parent: any): any { +function Validated(parent: any) { class _ extends ValidatedForm.Validated(parent) { static Validated = Validated; } - return _; + return (_ as unknown) as ValidatedForm; } export default Validated(BaseForm); diff --git a/packages/uniforms-semantic/src/ValidatedQuickForm.tsx b/packages/uniforms-semantic/src/ValidatedQuickForm.tsx index 554624af2..83d33eb24 100644 --- a/packages/uniforms-semantic/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-semantic/src/ValidatedQuickForm.tsx @@ -1,5 +1,9 @@ +import { ValidatedQuickForm } from 'uniforms'; + import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); +export default ValidatedForm.Validated( + QuickForm.Quick(BaseForm), +) as ValidatedQuickForm; diff --git a/packages/uniforms-unstyled/src/AutoForm.tsx b/packages/uniforms-unstyled/src/AutoForm.tsx index a8f25da9c..dd83b25bb 100644 --- a/packages/uniforms-unstyled/src/AutoForm.tsx +++ b/packages/uniforms-unstyled/src/AutoForm.tsx @@ -2,12 +2,12 @@ import { AutoForm } from 'uniforms'; import ValidatedQuickForm from './ValidatedQuickForm'; -function Auto(parent: any): any { +function Auto(parent: any) { class _ extends AutoForm.Auto(parent) { static Auto = Auto; } - return _; + return (_ as unknown) as AutoForm; } export default Auto(ValidatedQuickForm); diff --git a/packages/uniforms-unstyled/src/QuickForm.tsx b/packages/uniforms-unstyled/src/QuickForm.tsx index c12584608..99930e213 100644 --- a/packages/uniforms-unstyled/src/QuickForm.tsx +++ b/packages/uniforms-unstyled/src/QuickForm.tsx @@ -5,7 +5,7 @@ import BaseForm from './BaseForm'; import ErrorsField from './ErrorsField'; import SubmitField from './SubmitField'; -function Quick(parent: any): any { +function Quick(parent: any) { class _ extends QuickForm.Quick(parent) { static Quick = Quick; @@ -22,7 +22,7 @@ function Quick(parent: any): any { } } - return _; + return (_ as unknown) as QuickForm; } export default Quick(BaseForm); diff --git a/packages/uniforms-unstyled/src/ValidatedForm.tsx b/packages/uniforms-unstyled/src/ValidatedForm.tsx index 15aa5dbb1..fa18a2d26 100644 --- a/packages/uniforms-unstyled/src/ValidatedForm.tsx +++ b/packages/uniforms-unstyled/src/ValidatedForm.tsx @@ -2,12 +2,12 @@ import { ValidatedForm } from 'uniforms'; import BaseForm from './BaseForm'; -function Validated(parent: any): any { +function Validated(parent: any) { class _ extends ValidatedForm.Validated(parent) { static Validated = Validated; } - return _; + return (_ as unknown) as ValidatedForm; } export default Validated(BaseForm); diff --git a/packages/uniforms-unstyled/src/ValidatedQuickForm.tsx b/packages/uniforms-unstyled/src/ValidatedQuickForm.tsx index 554624af2..83d33eb24 100644 --- a/packages/uniforms-unstyled/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-unstyled/src/ValidatedQuickForm.tsx @@ -1,5 +1,9 @@ +import { ValidatedQuickForm } from 'uniforms'; + import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); +export default ValidatedForm.Validated( + QuickForm.Quick(BaseForm), +) as ValidatedQuickForm; From 977658d9508bee9966ba7e90e014b71419393184 Mon Sep 17 00:00:00 2001 From: wadamek65 Date: Tue, 24 Aug 2021 15:37:03 +0200 Subject: [PATCH 2/7] Added BaseForm types. --- packages/uniforms-antd/src/BaseForm.tsx | 4 ++-- packages/uniforms-bootstrap3/src/BaseForm.tsx | 4 ++-- packages/uniforms-bootstrap4/src/BaseForm.tsx | 4 ++-- packages/uniforms-bootstrap5/src/BaseForm.tsx | 4 ++-- packages/uniforms-material/src/BaseForm.tsx | 4 ++-- packages/uniforms-semantic/src/BaseForm.tsx | 4 ++-- packages/uniforms-unstyled/src/BaseForm.tsx | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/uniforms-antd/src/BaseForm.tsx b/packages/uniforms-antd/src/BaseForm.tsx index 798ed59a7..6ba42984b 100644 --- a/packages/uniforms-antd/src/BaseForm.tsx +++ b/packages/uniforms-antd/src/BaseForm.tsx @@ -1,7 +1,7 @@ import classnames from 'classnames'; import { BaseForm } from 'uniforms'; -function AntD(parent: any): any { +function AntD(parent: any) { class _ extends parent { static AntD = AntD; @@ -21,7 +21,7 @@ function AntD(parent: any): any { } } - return _; + return (_ as unknown) as typeof BaseForm; } export default AntD(BaseForm); diff --git a/packages/uniforms-bootstrap3/src/BaseForm.tsx b/packages/uniforms-bootstrap3/src/BaseForm.tsx index 18fb80283..626849a46 100644 --- a/packages/uniforms-bootstrap3/src/BaseForm.tsx +++ b/packages/uniforms-bootstrap3/src/BaseForm.tsx @@ -1,7 +1,7 @@ import classnames from 'classnames'; import { BaseForm } from 'uniforms'; -function Bootstrap3(parent: any): any { +function Bootstrap3(parent: any) { class _ extends parent { static Bootstrap3 = Bootstrap3; @@ -34,7 +34,7 @@ function Bootstrap3(parent: any): any { } } - return _; + return (_ as unknown) as typeof BaseForm; } export default Bootstrap3(BaseForm); diff --git a/packages/uniforms-bootstrap4/src/BaseForm.tsx b/packages/uniforms-bootstrap4/src/BaseForm.tsx index 711059c0d..372bf8b28 100644 --- a/packages/uniforms-bootstrap4/src/BaseForm.tsx +++ b/packages/uniforms-bootstrap4/src/BaseForm.tsx @@ -2,7 +2,7 @@ import classnames from 'classnames'; import omit from 'lodash/omit'; import { BaseForm } from 'uniforms'; -function Bootstrap4(parent: any): any { +function Bootstrap4(parent: any) { class _ extends parent { static Bootstrap4 = Bootstrap4; @@ -23,7 +23,7 @@ function Bootstrap4(parent: any): any { } } - return _; + return (_ as unknown) as typeof BaseForm; } export default Bootstrap4(BaseForm); diff --git a/packages/uniforms-bootstrap5/src/BaseForm.tsx b/packages/uniforms-bootstrap5/src/BaseForm.tsx index 2b99b731a..7a93c475a 100644 --- a/packages/uniforms-bootstrap5/src/BaseForm.tsx +++ b/packages/uniforms-bootstrap5/src/BaseForm.tsx @@ -2,7 +2,7 @@ import classnames from 'classnames'; import omit from 'lodash/omit'; import { BaseForm } from 'uniforms'; -function Bootstrap5(parent: any): any { +function Bootstrap5(parent: any) { class _ extends parent { static Bootstrap5 = Bootstrap5; @@ -23,7 +23,7 @@ function Bootstrap5(parent: any): any { } } - return _; + return (_ as unknown) as typeof BaseForm; } export default Bootstrap5(BaseForm); diff --git a/packages/uniforms-material/src/BaseForm.tsx b/packages/uniforms-material/src/BaseForm.tsx index 8ee86a432..18901966f 100644 --- a/packages/uniforms-material/src/BaseForm.tsx +++ b/packages/uniforms-material/src/BaseForm.tsx @@ -1,13 +1,13 @@ import { BaseForm } from 'uniforms'; -function Material(parent: any): any { +function Material(parent: any) { class _ extends parent { static Material = Material; static displayName = `Material${parent.displayName}`; } - return _; + return (_ as unknown) as typeof BaseForm; } export default Material(BaseForm); diff --git a/packages/uniforms-semantic/src/BaseForm.tsx b/packages/uniforms-semantic/src/BaseForm.tsx index c850a34aa..d6a1ad99a 100644 --- a/packages/uniforms-semantic/src/BaseForm.tsx +++ b/packages/uniforms-semantic/src/BaseForm.tsx @@ -1,7 +1,7 @@ import classnames from 'classnames'; import { BaseForm } from 'uniforms'; -function Semantic(parent: any): any { +function Semantic(parent: any) { class _ extends parent { static Semantic = Semantic; @@ -18,7 +18,7 @@ function Semantic(parent: any): any { } } - return _; + return (_ as unknown) as typeof BaseForm; } export default Semantic(BaseForm); diff --git a/packages/uniforms-unstyled/src/BaseForm.tsx b/packages/uniforms-unstyled/src/BaseForm.tsx index b1a6bb8af..2dd419472 100644 --- a/packages/uniforms-unstyled/src/BaseForm.tsx +++ b/packages/uniforms-unstyled/src/BaseForm.tsx @@ -1,13 +1,13 @@ import { BaseForm } from 'uniforms'; -function Unstyled(parent: any): any { +function Unstyled(parent: any) { class _ extends parent { static Unstyled = Unstyled; static displayName = `Unstyled${parent.displayName}`; } - return _; + return (_ as unknown) as typeof BaseForm; } export default Unstyled(BaseForm); From 6b302d147a79bc47cbba9acd3738c0494ef58497 Mon Sep 17 00:00:00 2001 From: wadamek65 Date: Tue, 24 Aug 2021 15:47:31 +0200 Subject: [PATCH 3/7] Casted Component in website to any. --- website/lib/universal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/lib/universal.tsx b/website/lib/universal.tsx index e91509d35..1ae7deb3d 100644 --- a/website/lib/universal.tsx +++ b/website/lib/universal.tsx @@ -46,7 +46,7 @@ export const themeContext = createContext('unstyled'); function _createThemedComponent(component: keyof typeof unstyled) { return function ThemedComponent(props: Record) { const theme = useContext(themeContext); - const Component = themes[theme][component]; + const Component: any = themes[theme][component]; return ; }; } From 0ea1bc127528a611cae68b45d09fc999456d8f16 Mon Sep 17 00:00:00 2001 From: wadamek65 Date: Tue, 24 Aug 2021 15:48:49 +0200 Subject: [PATCH 4/7] Added comment to explicit any typing. --- website/lib/universal.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/website/lib/universal.tsx b/website/lib/universal.tsx index 1ae7deb3d..01fb7e5f2 100644 --- a/website/lib/universal.tsx +++ b/website/lib/universal.tsx @@ -46,6 +46,7 @@ export const themeContext = createContext('unstyled'); function _createThemedComponent(component: keyof typeof unstyled) { return function ThemedComponent(props: Record) { const theme = useContext(themeContext); + // Form prop errors due to `props` having no strict type here const Component: any = themes[theme][component]; return ; }; From 0901598c731533ce1c3bd2e639f013dd1fb8bb90 Mon Sep 17 00:00:00 2001 From: wadamek65 Date: Tue, 24 Aug 2021 16:09:23 +0200 Subject: [PATCH 5/7] Removed redundant casts. --- packages/uniforms-antd/src/ValidatedQuickForm.tsx | 6 +----- packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx | 6 +----- packages/uniforms-bootstrap4/src/ValidatedQuickForm.tsx | 6 +----- packages/uniforms-bootstrap5/src/ValidatedQuickForm.tsx | 6 +----- packages/uniforms-material/src/ValidatedQuickForm.tsx | 6 +----- packages/uniforms-semantic/src/ValidatedQuickForm.tsx | 6 +----- packages/uniforms-unstyled/src/ValidatedQuickForm.tsx | 6 +----- 7 files changed, 7 insertions(+), 35 deletions(-) diff --git a/packages/uniforms-antd/src/ValidatedQuickForm.tsx b/packages/uniforms-antd/src/ValidatedQuickForm.tsx index 83d33eb24..554624af2 100644 --- a/packages/uniforms-antd/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-antd/src/ValidatedQuickForm.tsx @@ -1,9 +1,5 @@ -import { ValidatedQuickForm } from 'uniforms'; - import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated( - QuickForm.Quick(BaseForm), -) as ValidatedQuickForm; +export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); diff --git a/packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx b/packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx index 83d33eb24..554624af2 100644 --- a/packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx @@ -1,9 +1,5 @@ -import { ValidatedQuickForm } from 'uniforms'; - import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated( - QuickForm.Quick(BaseForm), -) as ValidatedQuickForm; +export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); diff --git a/packages/uniforms-bootstrap4/src/ValidatedQuickForm.tsx b/packages/uniforms-bootstrap4/src/ValidatedQuickForm.tsx index 83d33eb24..554624af2 100644 --- a/packages/uniforms-bootstrap4/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-bootstrap4/src/ValidatedQuickForm.tsx @@ -1,9 +1,5 @@ -import { ValidatedQuickForm } from 'uniforms'; - import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated( - QuickForm.Quick(BaseForm), -) as ValidatedQuickForm; +export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); diff --git a/packages/uniforms-bootstrap5/src/ValidatedQuickForm.tsx b/packages/uniforms-bootstrap5/src/ValidatedQuickForm.tsx index 83d33eb24..554624af2 100644 --- a/packages/uniforms-bootstrap5/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-bootstrap5/src/ValidatedQuickForm.tsx @@ -1,9 +1,5 @@ -import { ValidatedQuickForm } from 'uniforms'; - import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated( - QuickForm.Quick(BaseForm), -) as ValidatedQuickForm; +export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); diff --git a/packages/uniforms-material/src/ValidatedQuickForm.tsx b/packages/uniforms-material/src/ValidatedQuickForm.tsx index fcd7237b5..554624af2 100644 --- a/packages/uniforms-material/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-material/src/ValidatedQuickForm.tsx @@ -1,9 +1,5 @@ -import { ValidatedQuickForm } from 'uniforms'; - import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated( - QuickForm.Quick(BaseForm), -) as typeof ValidatedQuickForm; +export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); diff --git a/packages/uniforms-semantic/src/ValidatedQuickForm.tsx b/packages/uniforms-semantic/src/ValidatedQuickForm.tsx index 83d33eb24..554624af2 100644 --- a/packages/uniforms-semantic/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-semantic/src/ValidatedQuickForm.tsx @@ -1,9 +1,5 @@ -import { ValidatedQuickForm } from 'uniforms'; - import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated( - QuickForm.Quick(BaseForm), -) as ValidatedQuickForm; +export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); diff --git a/packages/uniforms-unstyled/src/ValidatedQuickForm.tsx b/packages/uniforms-unstyled/src/ValidatedQuickForm.tsx index 83d33eb24..554624af2 100644 --- a/packages/uniforms-unstyled/src/ValidatedQuickForm.tsx +++ b/packages/uniforms-unstyled/src/ValidatedQuickForm.tsx @@ -1,9 +1,5 @@ -import { ValidatedQuickForm } from 'uniforms'; - import BaseForm from './BaseForm'; import QuickForm from './QuickForm'; import ValidatedForm from './ValidatedForm'; -export default ValidatedForm.Validated( - QuickForm.Quick(BaseForm), -) as ValidatedQuickForm; +export default ValidatedForm.Validated(QuickForm.Quick(BaseForm)); From a0916f7d7b2d656e337573105765e95616abf5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Miernik?= Date: Wed, 25 Aug 2021 13:55:12 +0200 Subject: [PATCH 6/7] Improved universal typing. --- website/lib/universal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/lib/universal.tsx b/website/lib/universal.tsx index 01fb7e5f2..edda486a2 100644 --- a/website/lib/universal.tsx +++ b/website/lib/universal.tsx @@ -44,9 +44,9 @@ export const themes = { export const themeContext = createContext('unstyled'); function _createThemedComponent(component: keyof typeof unstyled) { - return function ThemedComponent(props: Record) { + return function ThemedComponent(props: Record) { const theme = useContext(themeContext); - // Form prop errors due to `props` having no strict type here + // FIXME: Form prop errors due to `props` having no strict type here. const Component: any = themes[theme][component]; return ; }; From fe496d5eab3873edd3eda812a1b447bde43a20e9 Mon Sep 17 00:00:00 2001 From: wadamek65 Date: Tue, 31 Aug 2021 13:46:01 +0200 Subject: [PATCH 7/7] Added section about form types to FAQ. --- docs/faq.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index 9a9f71e62..688540f43 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -245,3 +245,21 @@ const ChangedForm = ({ model }) => ( ); ``` + +### Why am I suddenly getting type errors in my form components? + +After introduction of TypeScript in `uniforms@3.0.0`, in the initial versions all form components in theme packages were typed as `any`. +Natural strict typing is not possible due to TypeScript constraints. In one of the versions we have decided to change this approach and explicitly cast all of the form types. +If you experience any errors regarding form types, please [file us a bug report](https://github.com/vazco/uniforms/issues/new?assignees=&labels=&template=bug-report.md) and use one of the following workarounds for the time being in your project. + +```tsx +const AnyAutoForm: any = AutoForm; +; + +// or + +const anyProps: any = { + untypedProp: 1 +} + +```