Skip to content

Commit

Permalink
Fix broken ts builds with leaked scheduler types
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpalmer committed Nov 11, 2020
1 parent b32c452 commit 0dfa23b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-deers-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'formik': patch
---

Fixed botched typescript builds including scheduler types
5 changes: 4 additions & 1 deletion packages/formik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"umd:main": "dist/formik.umd.production.js",
"module": "dist/formik.esm.js",
"typings": "dist/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"peerDependencies": {
"react": ">=16.8.0"
},
Expand Down Expand Up @@ -48,6 +50,7 @@
"@types/lodash": "^4.14.119",
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.9",
"@types/scheduler": "^0.16.1",
"@types/warning": "^3.0.0",
"@types/yup": "^0.24.9",
"just-debounce-it": "^1.1.0",
Expand Down
13 changes: 10 additions & 3 deletions packages/formik/src/Formik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,10 @@ export function useFormik<Values extends FormikValues = FormikValues>({
// is actually high-priority since we absolutely need to guarantee the
// form is valid before executing props.onSubmit.
const validateFormWithLowPriority = useEventCallback(
(values: Values = state.values) => {
return runWithLowPriority(() => {
(
values: Values = state.values
): Promise<FormikErrors<Values>> | Promise<void> => {
return (runWithLowPriority(() => {
return runAllValidations(values)
.then(combinedErrors => {
if (!!isMounted.current) {
Expand All @@ -373,7 +375,12 @@ export function useFormik<Values extends FormikValues = FormikValues>({
);
}
});
});
// The scheduler package is a transitive dependency installed with React
// If we leave this type as is, scheduler types leak and be exported in the build
// which would require folks to install @types/scheduler if they had
// skipLibCheck: false. Or we'd have to add @types/scheduler as a dep.
// Both are unecessary.
}) as unknown) as Promise<FormikErrors<Values>> | Promise<void>;
}
);

Expand Down

0 comments on commit 0dfa23b

Please sign in to comment.