Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
Argumento de tipo 'Omit<P, "prop1"> & { prop1: string; }' no es asignable al parámetro de tipo 'P'

Estoy tratando de crear una función de orden superior que pueda agregar algunas líneas de código antes y después de la invocación y generar un valor adicional que debe compartirse con la función envuelta.

Mi código se parece a lo siguiente en este momento.

 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 }); }; };

Entonces, en el código anterior, recibo un error de tipo

 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'

No entiendo por qué no puedo Omit<P, "prop1"> & { prop1: string; } ser equivalente de P aquí. ¿Es este algún tipo de problema extraño de TypeScript, o hay algo mal que estoy haciendo aquí? Por supuesto, solo puedo agregar as P para hacer cumplir el tipo, pero quiero entender por qué está fallando en este momento. ¿Alguna idea?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!