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

125
Vistas
Argument of type 'Omit<P, "prop1"> & { prop1: string; }' is not assignable to parameter of type 'P'

I am trying to create a higher order function which can add some lines of code before and after the invocation and generate an extra value which needs to be shared with the wrapped function.

My code looks like the following right now.

interface Interface1 {
  prop1: string;
}

const func1 = <P extends Interface1>(func2: (param: P) => any) => {
  const str = 'something';
  return (param: Omit<P, 'prop1'>) => { // Getting type error on this line
    return func2({ ...param, prop1: str });
  };
};

So in the above code I am receiving a type error

Argument of type 'Omit<P, "prop1"> & { prop1: string; }' is not assignable to parameter of type 'P'.
  'Omit<P, "prop1"> & { prop1: string; }' is assignable to the constraint of type 'P', but 'P' could be instantiated with a different subtype of constraint 'Interface1'

I don't understand why can't Omit<P, "prop1"> & { prop1: string; } be equivalent of P here. Is this some sort of weird TypeScript issue, or is there something wrong that I am doing here. Of course I can just add as P to enforce the type, but I wanna understand why it's failing right now. Any idea?

about 4 years ago · Santiago Trujillo
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