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

302
Views
TS2345: Generic Argument of type is not assignable to parameter of type in Typescript 4.4

Since I've updated from Typescript version 4.0 to 4.4 I get some errors with Generics and I am not able to fix them.


const isFirstData = <TFirst, TSecond>(
    item: { type: ItemType.FIRST; data: TFirst } | { type: ItemType.SECOND; data: TSecond }
): item is { type: ItemType.FIRST; data: TFirst } => item.type === ItemType.FIRST;

const rows: ({
    type: ItemType.SECOND;
    data: TSecond;
} | {
    type: ItemType.FIRST;
    data: TFirst;
})[]; 

const item = rows[0];
const height = isFirstData(item) ? First?.value : Second?.value;

// Argument of type '{ type: ItemType.SECOND; data: TData; } | { type: ItemType.FIRST; data: TFirst; }' is not assignable to parameter of type '{ type: ItemType.FIRST; data: TData; } | { type: ItemType.SECOND; data: TData; }'.

Can somebody explain what has changed in typescript and how to fix my error?

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!