Dynamsoft / capture-vision-react-native-samples

Dynamsoft Capture Vision React-Native SDK Samples
https://www.dynamsoft.com/capture-vision/docs/introduction/
Other
15 stars 7 forks source link

dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx typescript definition incompatible with RN 0.70.6 #32

Closed chernandez-bunnings closed 2 months ago

chernandez-bunnings commented 1 year ago

Hello,

Most recent version of dynamsoft-capture-vision-react-native@1.1.8 currently experiences typescript conflicts that have been raised during our tsc step.

Is it possible to request the team to have a look in to the typing definitions to solve these conflicts? For now, I'm patching the package and skipping ts compiler from checking this file dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx by adding // @ts-nocheck at the top of the problematic file. This way our CI won't raise the exception. Ideally I should drop this patch as soon as the issue is resolved in the package directly.

Details of the typings errors:

$ tsc
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx(46,7): error TS2322: Type 'ComponentType<any>' is not assignable to type 'HostComponent<any>'.
  Type 'ComponentClass<any, any>' is not assignable to type 'HostComponent<any>'.
    Type 'Component<any, any, any>' is not assignable to type 'Component<any, {}, any> & Readonly<NativeMethods>'.
      Type 'Component<any, any, any>' is missing the following properties from type 'Readonly<NativeMethods>': measure, measureInWindow, measureLayout, setNativeProps, and 2 more.
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx(51,[9](...)): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx([10](...): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ torchState: any; }'.
  No index signature with a parameter of type 'string' was found on type '{ torchState: any; }'.
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx(102,20): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ torchState: any; }'.
  No index signature with a parameter of type 'string' was found on type '{ torchState: any; }'.
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx([14](...): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'UIManagerStatic'.
  No index signature with a parameter of type 'string' was found on type 'UIManagerStatic'.
error Command failed with exit code 2.

Note: forgot to mentioned that some of those typing conflicts present on react-native@0.70.6

Dynamsoft-Henry commented 1 year ago

Hello @chernandez-bunnings

Thanks for reporting this issue. We are looking at it. I'll let you know if we can resolve the conflicts.

Dynamsoft-Henry commented 1 year ago

Hello @chernandez-bunnings

We have released a new version v1.1.9 to fix the conflicts. You can try the new version now.

chernandez-bunnings commented 1 year ago

Confirming that in version 1.1.9 those ts errors are not raised. Ideally enforcing the types would be great, as I can see this new version defines those types as any in those instances where there were errors. This fix works for now, for me to drop the patch. Thank you for looking into it.

If in the future a more strict type definition is supported that would be very much appreciated.

chernandez-bunnings commented 1 year ago

Apologies for providing a false positive confirmation. During my initial test, I didn't experience the issue. However doing a clean install, we still experience one typing error: image

$ tsc
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx(46,7): error TS2322: Type 'ComponentType<any>' is not assignable to type 'HostComponent<any>'.
  Type 'ComponentClass<any, any>' is not assignable to type 'HostComponent<any>'.
    Type 'Component<any, any, any>' is not assignable to type 'Component<any, {}, any> & Readonly<NativeMethods>'.
      Type 'Component<any, any, any>' is missing the following properties from type 'Readonly<NativeMethods>': measure, measureInWindow, measureLayout, setNativeProps, and 2 more.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
chernandez-bunnings commented 1 year ago

Hello @Dynamsoft-Henry, just wondering if there are any updates on this? We are finalising development work for the barcode scanner. It would be great if we did not have to use a patch to ensure the tsc passes correctly in our ci. I had a quick look into v1.1.12 and the issues still occurs.

Dynamsoft-Henry commented 1 year ago

@chernandez-bunnings Apologize for the late reply. We will fix it as soon as possible.

Dynamsoft-Henry commented 1 year ago

Hi @chernandez-bunnings Would you like to share your tsconfig.json file with us. So that we can confirm whether the issue is solved on you end.