Skip to content

ref type mismatch? #110

Description

@smajl

Expected behavior

Typescript will compile without errors.

Current behavior

Ref types mismatch.

TS2322: Type '(instance: ReactInstance) => void' is not assignable to type 'string | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined'.   Type '(instance: ReactInstance) => void' is not assignable to type '(instance: HTMLDivElement | null) => void'.     Types of parameters 'instance' and 'instance' are incompatible.       Type 'HTMLDivElement | null' is not assignable to type 'ReactInstance'.         Type 'null' is not assignable to type 'ReactInstance'.  index.d.ts(143, 9): The expected type comes from property 'ref' which is declared here on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'

Steps to reproduce

function MyComponent() {
  const renderList: React.ComponentProps<typeof List>['itemsRenderer'] = (items, ref) => (
    <div className={classes.root} ref={ref}>
      ...
    </div>
  );

  return (
    <List
      itemsRenderer={renderList}
      ...
    />
  );
}

Context (environment)

  • Version: 3.0.9
  • TypeScript: 3.8.3
  • Platform: Win 10 64bit

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions