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

131
Views
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
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!