Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
Typescript in storybook with props type using parameter

I have a component:

type RowItem<T> = Record<keyof T, any>;
type TableRowsCells<T> = Array<RowItem<T>>;
type TableHeadCells<T> = HeadCell<T>[];

type TableProps<T> = {
  ariaLabel: string;
  ariaLabelledBy: string;
  TableHeadCells: TableHeadCells<T>;
  TableRowsCells: TableRowsCells<T>;
  defaultOrderBy?: keyof T;
};

function Table<T>(props: TableProps){
  // ---------------.
  // code stuff.
  // ---------------.
}

I am writing the corresponding storybook

import { Story } from '@storybook/react';


export default {
  title: 'Table',
  component: Table,
};

const Template: Story<TableProps> = (args) => <Table {...args} />;

export const Basic = Template.bind({});
Basic.args = {};

I get error from storybook:

The generic type 'TableProps' requires 1 type argument(s).

How can I specify? write? declare? the argument in storybook with this way?

Thx

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

TableProps is a generic type itself so you need to pass its generic type

for example, the code below specifies any as TableProps's generic type

   const Template: Story<TableProps<any>> = (args) => <Table {...args} />;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!