How to force to use @types/react-native
instead of built-in STALED dts
files
#37670
Labels
Resolution: Answered
When the issue is resolved with a simple answer
Description
TL;DR: Is there a way to force
TypeScript
to use@types/react-native
instead of built-in stalednode_modules/react-native/types
files?Built-in types do NOT align with the current react-native version, e.g. #36441, it doesn't make sense to use staled types. I know it will be fixed in the near future, but still it's not good, so I'd like to use up-to-date
@types/react-native
instead.Refer to #36441, I'm trying to work around this one. I found out that in the
DefinitelyTyped
package, this has been updated by DefinitelyTyped/DefinitelyTyped#65144, which means, if I deletenode_modules/react-native/types
in my local, everything just worked, there's no more error complaining about the invalidautoComplete
prop value (I'm usingnew-password
in this case).That's definitely not the ideal solution, since in another environment, like the auto-building process, this won't be performed and
tsc
will complain about ti again.I do want to use the built-in version, but somehow it's not even aligned with the latest version of the app.
Any solution I can use? Adding
"types": ["react-native"]
intsconfig.json
doesn't help.React Native Version
~0.71.8
Output of
npx react-native info
System:
OS: Windows 10 10.0.19045
CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11900K @ 3.50GHz
Memory: 25.28 GB / 63.84 GB
Binaries:
Node: 18.16.0 - C:\NodeJS\node.EXE
Yarn: 1.22.19 - C:\NodeJS\yarn.CMD
npm: 9.6.7 - C:\NodeJS\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowAllTrustedApps: Disabled
IDEs:
Android Studio: AI-222.4459.24.2221.9971841
Visual Studio: Not Found
Languages:
Java: 17.0.1 - C:\Program Files\Common Files\Oracle\Java\javapath\javac.EXE
npmPackages:
@react-native-community/cli: Not Found
react: ~18.2.0 => 18.2.0
react-native: ~0.71.8 => 0.71.8
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
essential
package.json
:By default it will error (see code snippet below)
Deleting
node_modules/react-native/types
folder, it works, because types in@types/react-native
is correctSnack, code example, screenshot, or link to a repository
The text was updated successfully, but these errors were encountered: