formik@2.4.9 ships .d.ts files that import from react:
import * as React from 'react';
TypeScript resolves these types through @types/react, but formik only declares react as a peer dependency — not @types/react. This works in flat node_modules layouts (npm, yarn) because @types/react is hoisted from the consuming project. When pnpm hoisting is disabled (hoist: false), TypeScript cannot find the React types and fails with:
error TS2307: Cannot find module 'react' or its corresponding type declarations.
Workaround:
packageExtensions:
"formik@2":
peerDependencies:
"@types/react": "*"
Suggested fix: Add @types/react to peerDependencies in formik's package.json.
formik@2.4.9ships.d.tsfiles that import fromreact:TypeScript resolves these types through
@types/react, butformikonly declaresreactas a peer dependency — not@types/react. This works in flatnode_moduleslayouts (npm, yarn) because@types/reactis hoisted from the consuming project. When pnpm hoisting is disabled (hoist: false), TypeScript cannot find the React types and fails with:Workaround:
Suggested fix: Add
@types/reacttopeerDependenciesinformik'spackage.json.