react-native-element-dropdown icon indicating copy to clipboard operation
react-native-element-dropdown copied to clipboard

Unused '@ts-expect-error' directive

Open SmartArray opened this issue 2 years ago • 8 comments

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?

SmartArray avatar Apr 24 '22 08:04 SmartArray

hi @SmartArray ,

Try upgrading devDependencies.

"devDependencies": {
    "@types/react-native": "*",
  },

hoaphantn7604 avatar Apr 24 '22 09:04 hoaphantn7604

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

SmartArray avatar May 04 '22 11:05 SmartArray

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.

devpascoe avatar May 31 '22 10:05 devpascoe

Do you think we need "// @ts-expect-error" on these lines mentioned above in useDeviceOrientation.ts ?

devpascoe avatar May 31 '22 11:05 devpascoe

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:

  1. Add the file in question to git via: git add node_modules/react-native-element-dropdown/src/useDeviceOrientation.ts -f
  2. Remove the comments and push up the change
  3. Pin my version of react-native-element-dropdown in my package.json (in my case, to 1.8.12)
  4. Add postinstall to scripts in package.json, having it run git 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.

jcerone-boom avatar Jun 10 '22 19:06 jcerone-boom

Hi, @ts-expect-err has been removed in version 2.0.

hoaphantn7604 avatar Jun 13 '22 01:06 hoaphantn7604

@hoaphantn7604 awesome! Do you have an idea on timeline for that release?

jcerone-boom avatar Jun 13 '22 16:06 jcerone-boom

Hi @jcerone-boom , Version 2.0.0 has been release.

hoaphantn7604 avatar Jun 14 '22 02:06 hoaphantn7604