Skip to content

TypeScript example for onSelect #110

Description

@MichalBryxi

Given:

  table = headlessTable<Row>(this, {
    columns: () => this.args.columns, // this.args.columns: ColumnConfig<Row>[]
    data: () => this.args.data, // this.args.data: Row[]
    plugins: [
      RowSelection.with(() => {
        return {
          selection: [],
          onSelect: (data) => { // Parameter 'data' implicitly has an 'any' type.
            ...
          },
          onDeselect: () => {},
        };
      }),
    ],
  });

I would hope that the first data argument of onSelect hook would give me correct type on the first argument (data) and not any. Or what would be the correct TS usage?

I can obviously just do:

onSelect: (data: T) => { ... }

but that feels ... unnecessary?

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions