Skip to content

Typescript errors on attempting to pass alt prop down to img  #16

@lotust

Description

@lotust

getting typescript error on attempting to add non-explicitly defined props in to component despite docs indicating that it is possible

Any other props will be passed down to the element. This way, you can e.g. add an alt attribute to the image.

Type '{ src: string; alt: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Magnifier> & Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "src"> & Partial<...> & Partial<...>'.
  Property 'alt' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Magnifier> & Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "src"> & Partial<...> & Partial<...>'.

looking at interface Props defined in /src/Magnifier.tsx is it possible that adding a [key: string]?: HTMLAttributes<T> would address the issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions