Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stricter types #1205

Merged
merged 7 commits into from
Jan 14, 2023
Merged

Stricter types #1205

merged 7 commits into from
Jan 14, 2023

Conversation

radekmie
Copy link
Contributor

In this pull request, I narrowed and improved quite a few of core uniforms types. Most notably:

  • All models (in the *Form components' props, Context, modelTransform, etc.) are no longer wrapped with DeepPartial. The idea is that the form always operates on a "valid" data structure. It covers 3rd issue of Explicit form types introduced on v3.6.0 #1083.
  • Every Model has to extend Record<string, unknown>. On the one hand it helps with object manipulation here and there, on the other that's potentially safer than object. (I'm open for a different base here.)
  • Narrowed a lot of anys to unknowns. The only "severe" ones left are the ones in the bridges, but they deserve a separate PR (and one of them is already started in Improve JSONSchemaBridge validator types #1172).

(Side note: we should switch to Zod or some other schema for our internal tests, as Simple Schema is not really TypeScript friendly.)

@radekmie radekmie added this to the v4.0 milestone Dec 27, 2022
@radekmie radekmie requested a review from wadamek65 as a code owner December 27, 2022 20:53
@github-actions github-actions bot added Area: Bridge Affects some of the bridge packages Area: Core Affects the uniforms package Area: Docs Affects the documentation or reproductions seed Area: Theme Affects some of the theme packages Bridge: GraphQL Affects the uniforms-bridge-graphql package Bridge: JSON Schema Affects the uniforms-bridge-json-schema package Bridge: SimpleSchema Affects the uniforms-bridge-simple-schema package Bridge: SimpleSchema (v2) Affects the uniforms-bridge-simple-schema-2 package Bridge: Zod Affects the uniforms-bridge-zod package Theme: AntD Affects the uniforms-antd package Theme: Bootstrap 3 Affects the uniforms-bootstrap3 package Theme: Bootstrap 4 Affects the uniforms-bootstrap4 package Theme: Bootstrap 5 Affects the uniforms-bootstrap5 package Theme: Material-UI Affects the uniforms-material package Theme: MUI Affects the uniforms-mui package Theme: Semantic UI Affects the uniforms-semantic package Theme: Unstyled Affects the uniforms-unstyled package labels Dec 27, 2022
@codecov
Copy link

codecov bot commented Dec 27, 2022

Codecov Report

Merging #1205 (5a0a795) into master (8bb920f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1205   +/-   ##
=======================================
  Coverage   98.39%   98.39%           
=======================================
  Files         231      231           
  Lines        3795     3796    +1     
  Branches      994      994           
=======================================
+ Hits         3734     3735    +1     
  Misses          6        6           
  Partials       55       55           
Impacted Files Coverage Δ
packages/uniforms-antd/src/HiddenField.tsx 100.00% <ø> (ø)
packages/uniforms-material/src/HiddenField.tsx 100.00% <ø> (ø)
packages/uniforms-mui/src/HiddenField.tsx 100.00% <ø> (ø)
packages/uniforms-unstyled/src/HiddenField.tsx 100.00% <ø> (ø)
packages/uniforms/src/AutoForm.tsx 100.00% <ø> (ø)
packages/uniforms/src/Bridge.ts 100.00% <ø> (ø)
packages/uniforms/src/QuickForm.tsx 100.00% <ø> (ø)
packages/uniforms/src/ValidatedForm.tsx 100.00% <ø> (ø)
packages/uniforms/src/ValidatedQuickForm.ts 100.00% <ø> (ø)
packages/uniforms/src/changedKeys.ts 100.00% <ø> (ø)
... and 32 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

packages/uniforms/src/useForm.ts Show resolved Hide resolved
packages/uniforms-unstyled/__tests__/_createContext.ts Outdated Show resolved Hide resolved
packages/uniforms-bootstrap5/src/AutoField.tsx Outdated Show resolved Hide resolved
wadamek65
wadamek65 previously approved these changes Jan 9, 2023
@radekmie radekmie merged commit 6353c83 into master Jan 14, 2023
@radekmie radekmie deleted the stricter-types branch January 14, 2023 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Bridge Affects some of the bridge packages Area: Core Affects the uniforms package Area: Docs Affects the documentation or reproductions seed Area: Theme Affects some of the theme packages Bridge: GraphQL Affects the uniforms-bridge-graphql package Bridge: JSON Schema Affects the uniforms-bridge-json-schema package Bridge: SimpleSchema (v2) Affects the uniforms-bridge-simple-schema-2 package Bridge: SimpleSchema Affects the uniforms-bridge-simple-schema package Bridge: Zod Affects the uniforms-bridge-zod package Theme: AntD Affects the uniforms-antd package Theme: Bootstrap 3 Affects the uniforms-bootstrap3 package Theme: Bootstrap 4 Affects the uniforms-bootstrap4 package Theme: Bootstrap 5 Affects the uniforms-bootstrap5 package Theme: Material-UI Affects the uniforms-material package Theme: MUI Affects the uniforms-mui package Theme: Semantic UI Affects the uniforms-semantic package Theme: Unstyled Affects the uniforms-unstyled package
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants