react-native-community/react-native-template-typescript

The template lack deps `@types/react`

hua03 opened this issue · 4 comments

hua03 commented

Expected results

When use other package manager eg: npm, pnpm, no eslint errors are reported.

Observed results

when use pnpm install new package, there report import error:

TS7016: Could not find a declaration file for module 'react'. '/Users/huahao/WorkSpace/Project/Demo/ReactNativeTSApp/node_modules/.pnpm/react@18.1.0/node_modules/react/index.js' implicitly has an 'any' type.   If the 'react' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react'

Logs

no logs, this is a eslint error.

Steps to reproduce

  1. init react native project with typescript template, pnpx react-native init ReactNativeTSApp --template react-native-template-typescript
  2. install new package with pnpm, pnpm install @react-navigation/native

I'm not so familiar with pnpm, do you have any potential solutions for this?

Solution in userland is to install @types/react after initting the project.

The template ought to include them though instead of relying on them being pulled in by @types/react-native

hua03 commented

I agree with @tom-sherman that @types/react should be included in the template rather than being installed by users themselves.

Fixed in 6.12.6, thanks for the contribution @EkaanshArora 👍