react-hook-form: Typescript build failing because of 'react-native' import

Describe the bug After upgrading to 3.24.0 our Typescript build is failing. This is caused by the typings importing 'react-native', which we’re not using in our project.

ERROR in [at-loader] ./node_modules/react-hook-form/dist/types.d.ts:2:30
    TS2307: Cannot find module 'react-native'.

ERROR in [at-loader] ./node_modules/react-hook-form/dist/useForm.d.ts:2:30
    TS2307: Cannot find module 'react-native'.

To Reproduce I’m assuming this happens for every Typescript based project that doesn’t use 'react-native'.

Expected behavior The package should not have a dependency on 'react-native'.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 30 (25 by maintainers)

Commits related to this issue

Most upvoted comments

@bluebill1049 pls give me a day to investigate this

lovely going to publish it now @bopfer thanks

For what it’s worth. I am seeing the same issue in my web-only project and I have held off on upgrading to 3.24.0 for now:

$ tsc -p tsconfig.json
../../../node_modules/react-hook-form/dist/types.d.ts:2:30 - error TS2307: Cannot find module 'react-native'.

2 import * as ReactNative from 'react-native';
                               ~~~~~~~~~~~~~~

../../../node_modules/react-hook-form/dist/useForm.d.ts:2:30 - error TS2307: Cannot find module 'react-native'.

2 import * as ReactNative from 'react-native';

Tomorrow I will see if I can create a reproducible example.

I agree - @kobber if you can post a reproducible example on GitHub or elsewhere so we can look, that would be helpful

As noted in my comments to the PR, I don’t see react-native being pulled into a project by yarn / npm because of this reference. The react-native reference being used in the react-hook-form project is for internal typings only. (The PR is not to fix this, but as a tangential followup to it)

At this stage, I don’t see the harm in doing this. If there is a harder tie-in we could branch out a project for react-native (I’ve seen the react-spring animation lib do something like this) but I would hope we could avoid that if at all possible.