Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
What is the correct way to pass through generics in this instance?

I am building a reusable table component and I have an optional render property that can take "any" type but I want to be specific and not use any

so I have this:

type Column<T> = {
  index: string
  render?: (arg?: T) => JSX.Element | string
}

type Columns = Column<T>[]

but the above line doesn't work as I'm not sure how to pass in the generic here?

then when I pass in the columns later like this:

const cols = [
  {
  index: "Phone Number",
  render: renderFunction('test'),
} as Column<string>

but how do I pass the generic to type Columns = Column<T>[] this line?

I can't pass it form Columns as it might be different for each Column

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use unknown there and use it like this:

type Columns = Column<unknown>[];

const columns: Columns = [{} as Column<string>, {} as Column<number>];
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda