react-native-element-dropdown
react-native-element-dropdown copied to clipboard
Unused '@ts-expect-error' directive
We get the following tsc
errors.
node_modules/react-native-element-dropdown/src/useDeviceOrientation.ts:27:7 - error TS2578: Unused '@ts-expect-error' directive.
27 // @ts-expect-error - React Native >= 0.65
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/react-native-element-dropdown/src/useDeviceOrientation.ts:29:9 - error TS2578: Unused '@ts-expect-error' directive.
29 // @ts-expect-error - need update @types/[email protected]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
https://github.com/hoaphantn7604/react-native-element-dropdown/blob/7949771f92088fea60495bd0dac7af55950ea49c/src/useDeviceOrientation.ts#L27-L35
Any ideas what is causing that?
hi @SmartArray ,
Try upgrading devDependencies.
"devDependencies": {
"@types/react-native": "*",
},
Thanks for your response.
My devDependencies are up to date.
Looking at line 27, why would my project throw an error when it's using React Native 0.67 for instance?
In that case, the typescript compiler expects an error, but it won't receive one and exits with error code
Hey there, also facing this issue. RN 0.66.3 typesript 4.7.2 when i run tsc --project tsconfig.json "@types/react-native": "^0.66.3",
Also get a bunch of errors for items like 'height' is declared but its value is never read. 'item' is declared but its value is never read. ...I can silence them with "noUnusedLocals": false, "noUnusedParameters": false, in my tsconfig but rather not.
Do you think we need "// @ts-expect-error" on these lines mentioned above in useDeviceOrientation.ts ?
An alternative way around this is to change just that file and track the change via git. Then, when you yarn install
the package, you can use a post install
script to update the file to fix it.
Here's what I did:
- Add the file in question to
git
via:git add node_modules/react-native-element-dropdown/src/useDeviceOrientation.ts -f
- Remove the comments and push up the change
- Pin my version of
react-native-element-dropdown
in mypackage.json
(in my case, to1.8.12
) - Add
postinstall
toscripts
inpackage.json
, having it rungit checkout node_modules/react-native-element-dropdown/src/useDeviceOrientation.ts
.
The postinstall runs after every install kicked off by yarn. So effectively, I version controlled that file, updated it so yarn tsc
works, then pulled down that update automatically whenever yarn
is called and the package goes in.
Hi, @ts-expect-err has been removed in version 2.0.
@hoaphantn7604 awesome! Do you have an idea on timeline for that release?
Hi @jcerone-boom , Version 2.0.0 has been release.