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

258
Vistas
typescript is there a way to remove the array from an property?

I have this model:

export interface SizeAndColors {
   size: string;
   color: string;
}[];

and then I have another model and I need the sizeAndColor but without a array.

export interface Cart {
  options: SizeAndColors
}

How can I say at options that I want to have this interface without the array? is that possible ?

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

0

Assuming that SizeAndColors really is declared as an array type where the elements are objects with size and color properties (what's in the question [doesn't seem to be that][1]), I'd suggest splitting the original interface:

interface SizeAndColorsElement {
    size: string;
    colors: string;
}
export type SizeAndColors = SizeAndColorsElement[];

But if you can't, you can use SizeAndColors[number] to access just the object part of that:

export interface Cart {
    options: SizeAndColors[number];
}

Again: That's assuming it's really defined as an array type, which it doesn't seem to be in the question's code.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Define you interface like this

export interface SizeAndColors {
 size: string;
 color: string;
}

and use array only when you need it

export interface Cart {
 options: SizeAndColors[]
}
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