Home > database >  How to extend union type in extending interface
How to extend union type in extending interface

Time:10-06

My situation

interface ElectionRaw {
  status: 'before' | 'in_progress' | 'counting_in_progress' | 'done',
}

interface Election extends ElectionRaw {
  transformed: true,
  status: 'long_before' | ElectionRaw['status'],
}

throws:

Interface 'Election' incorrectly extends interface 'ElectionRaw'.
  Types of property 'status' are incompatible.
    Type '"before" | "in_progress" | "counting_in_progress" | "done" | "long_before"' is not assignable to type '"before" | "in_progress" | "counting_in_progress" | "done"'.
      Type '"long_before"' is not assignable to type '"before" | "in_progress" | "counting_in_progress" | "done"'.(2430)

link to playground

Many thanks for advices

  • Related