Help with using Expo Camera in TypeScript


#1

Hello all, sorry for my first post being a request, but I am having a really hard time currently using the expo camera documentation in my typescript based app. I am unaware how to properly set the Camera component ref prop, in order to use the function takePictureAsync. Any guidance would be very appreciated.

Currently, I have public camera!: CameraObject; set at the top of my screen component, and set up my Camera component like so:

<Camera style={{ flex: 1 }} type={this.state.type}
      // tslint:disable-next-line:no-any
      ref={(ref: any) => {
            this.camera = ref;
            // tslint:disable-next-line:no-console
            console.log(this.camera);
          }}
>

This seems to work OK (as long as i use .bind(this) on my take picture button onPress function), but I would prefer to not have to specify :any for ref. What should ref be typed as? Pretty much anything else I put seems to trigger a type error in TSLint, and using the ref type as it is directly in the props did not work (as it seems to expect a void function, and not a CameraObject).