TS error: "Cannot find name 'T' how to pass the generic?

4.6k Views Asked by At

I am using https://www.npmjs.com/package/recompose in my project

I need to pass a generic "T" to Table, how to change the type signature so compose<Props<T>, CompProps<T>> will be satisfied?

I have tried with no success:

export const Table<T> = ...

export const Table = compose<Props<T>, CompProps<T>>(
  setDisplayName('Grid'),
  injectSheet(styles)
)(TableComp);

Error I am receving is:

"Cannot find name 'T'
1

There are 1 best solutions below

1
jcroll On

Since you have no type use any:

export const Table = compose<Props<any>, CompProps<any>>(
  setDisplayName('Grid'),
  injectSheet(styles)
)(TableComp);

Edit: Ok with keeping type safety

export const Table<T> = compose<Props<T>, CompProps<T>>(
  setDisplayName('Grid'),
  injectSheet(styles)
)(TableComp);