Skip to content

Type error compiling with typescript  #3837

Closed
@rcocks-hl

Description

@rcocks-hl

Bug report

Current Behavior

Typescript compilation fails with type errors in Formik library

<project>/node_modules/formik/dist/ErrorMessage.d.ts(1,23): error TS2688: Cannot find type definition file for 'hoist-non-react-statics'.
<project>/node_modules/formik/dist/FastField.d.ts(1,23): error TS2688: Cannot find type definition file for 'hoist-non-react-statics'.
<project>/node_modules/formik/dist/FieldArray.d.ts(1,23): error TS2688: Cannot find type definition file for 'hoist-non-react-statics'.       

The npm package hoist-non-react-statics hasn't been updated in years, so seems unlikely to be an upstream issue.

Typescript version 4.9.5.

Expected behavior

Compilation should suceed without type errors.

Reproducible example

I don't have an easily shared reproduction, but this is my package-lock info:

"node_modules/formik": {
			"version": "2.4.2",
			"resolved": "https://registry.npmjs.org/formik/-/formik-2.4.2.tgz",
			"integrity": "sha512-C6nx0hifW2uENP3M6HpPmnAE6HFWCcd8/sqBZEOHZY6lpHJ5qehsfAy43ktpFLEmkBmhiZDei726utcUB9leqg==",
			"funding": [
				{
					"type": "individual",
					"url": "https://opencollective.com/formik"
				}
			],
			"dependencies": {
				"deepmerge": "^2.1.1",
				"hoist-non-react-statics": "^3.3.0",
				"lodash": "^4.17.21",
				"lodash-es": "^4.17.21",
				"react-fast-compare": "^2.0.1",
				"tiny-warning": "^1.0.2",
				"tslib": "^2.0.0"
			},
			"peerDependencies": {
				"react": ">=16.8.0"
			}
		},

react-hoist-non-statics is satisifed with 3.3.2, as it has been for a while:

		"hoist-non-react-statics": {
			"version": "3.3.2",
			"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz",
			"integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==",
			"requires": {
				"react-is": "^16.7.0"
			}
		},

Suggested solution(s)

Not sure if this requires manual typing or setting a typescript version dependency.

Additional context

This happened after upgrading from Formik 2.4.1 to 2.4.2.

Your environment

Software Version(s)
Formik 2.4.2
React 16.14.0
TypeScript 4.9.5
Browser N/A
npm/Yarn 8.5.5
Operating System windows 11 21H2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions