Skip to content

Do I need to install @types/react-signature-canvas? #106

@praveenpuglia

Description

@praveenpuglia

Now that it's written in typescript and can export the typings from the tsx files directly, do I still need to install the @types package?

I have checked the published package for react-signature-canvas and that doesn't contain any typings all by itself.

Here's my tsx code where the ref complains of type issues.

const SignatureCanvas = lazy(() => import('react-signature-canvas'));

export const DrawSignature = () => {
	const canvasRef = useRef<typeof SignatureCanvas>(null);
	
	return (
      <Suspense>
        <SignatureCanvas
          ref={canvasRef}
          canvasProps={{
            className: styles['canvas'],
          }}
          backgroundColor={backgroundBlue}
        />
	  </Suspense>
    )
}

Here, the ref on the component complains.

Type 'RefObject<LazyExoticComponent<typeof ReactSignatureCanvas>>' is not assignable to type 'Ref<ReactSignatureCanvas> | undefined'.
  Type 'RefObject<LazyExoticComponent<typeof ReactSignatureCanvas>>' is not assignable to type 'RefObject<ReactSignatureCanvas>'.
    Type 'LazyExoticComponent<typeof ReactSignatureCanvas>' is not assignable to type 'ReactSignatureCanvas'.ts(2322)
index.d.ts(119, 9): The expected type comes from property 'ref' which is declared here on type 'IntrinsicAttributes & ReactSignatureCanvasProps & RefAttributes<ReactSignatureCanvas>'

I have looked at other issues like #61 but those examples don't work.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions