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

Type error compiling with typescript #3837

Closed
rcocks-hl opened this issue Jun 27, 2023 · 3 comments · Fixed by #3860, #3879, DTS-STN/passport-status#667, LetsSmash/namethesongs#10 or FelixAshong/signin-sigu-ppage#8

Comments

@rcocks-hl
Copy link

rcocks-hl commented Jun 27, 2023

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
@Grmiade
Copy link

Grmiade commented Jul 31, 2023

Yeah, @types/hoist-non-react-statics should be declared in the dependencies 👍

@john-jay
Copy link

This worked for me:
npm i @types/hoist-non-react-statics --save-dev

@rcocks-hl
Copy link
Author

Hi, what's the status of this please?

The suggested workaround of npm i-D @types/hoist-non-react-statics does not work for our use case.

@kodiakhq kodiakhq bot closed this as completed in #3860 Sep 17, 2023
kodiakhq bot pushed a commit that referenced this issue Sep 17, 2023
…3860)

This package is needed by Formik but it was not included in the dependency list.

Fixes #3837
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment