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

143
Vistas
Check if value is a CustomType

My interfaces.ts looks as follows:

export const types = ["foo", "bar"] as const;

export type CustomType = typeof types[number];

And I want to check whether a string is a CustomType. When I use includes it gives me an error telling me:

Argument of type 'string' is not assignable to parameter of type '"foo" | "bar"'.

I could use findIndex but is there no other way so I can use includes?

const a = types.includes(value);                       // error
const b = types.findIndex(type => type === value) < 0  // boolean
about 4 years ago · Juan Pablo Isaza
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