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

[0.8] Advanced TS types #74

Merged
merged 3 commits into from
Jul 21, 2017
Merged

[0.8] Advanced TS types #74

merged 3 commits into from
Jul 21, 2017

Conversation

jaredpalmer
Copy link
Owner

Adds more expressive type signatures to FormikError and FormikTouched. TypeScript will now get angry if you try to set a field on errors or touched that does not exist on values.

Old

interface FormikValues {	
 [field: string]: any;		
}

interface FormikErrors {	
 [field: string]: string;		
}

interface FormikTouched {	
 [field: string]: boolean;		
}

New

export interface FormikValues {
  [field: string]: any;
}

export type FormikErrors<Values extends FormikValues> = {
  [Key in keyof Values]?: string
};

export type FormikTouched<Values extends FormikValues> = {
  [Key in keyof Values]?: boolean
};

@jaredpalmer jaredpalmer merged commit e3c2b01 into setters Jul 21, 2017
@jaredpalmer jaredpalmer deleted the advanced-ts-typesa branch July 21, 2017 20:46
jaredpalmer added a commit that referenced this pull request Jul 21, 2017
* Close #49  Add setFieldX methods, deprecation warnings, move validation to handleBlur

* Add validateOnChange flag to configuration options

* Fix dep warning and typo

* Add setStatus, deprecate setError (add warnings)

* Clean up tests

* Improve internal TS types (no changes to external)

* Fix typos in setX in README

* Fix typo in README

* Document new API in README, link all api methods in prose

* Import formik from source in example (useful for TS checking in dev)

* Update links in warning and error messages

* Add error message when trying to use handleBlur in RN

* Fix links in readme

* Use react-native's Button in example in readme

* Fix typo

* Close #55. Add validate, validateAsync, make yup optional

* [0.8] Add singular validate method (#63)

* Attempt to add singular validate method

* Fix validate and tests, add submitForm

* Fix typo

* Simplify tests

* Add readonly dirty prop

* Rename hoc -> tree in tests

* Use proper JSDoc-style comments in interface defs

* #62 Add validateOnBlur option, fix dirty edge case

* [0.8] Advanced TS types (#74)

* Add more expressive TS types for touched, errors

* Fix typo

* Allow validate to return void

* Deprecate mapValuesToPayload (#75)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant