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

310
Views
Typescript - generics infer and define can not work together

Here is generics infer(not infer keyword) demo:

function foo<A>(a: A): A {}

const result = foo({ a: 1 });
//  const result: {
//    a: number;
//  }

But it seems i can't add some "extra" types to function foo, otherwise infer will not working:

function foo<Extra, A>(a: A): A & Extra {}

const result = foo<{ b: number }>({ a: 1 });
//  const result: {
//    b: number;
//  }

So, what i want is the function foo can both has type a and b in the above example, can anyone help?

about 4 years ago · Juan Pablo Isaza
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!