TypeScript `extend` produces ESLint error when extending a generic

Viewed 1351

I have a load of models that have some meta data appended, so I created a generic type to append them to the models when they're present:

type WithMeta<T> = T extends Meta;

Although this produces the following error: Parsing error: '?' expected.

ESLint isn't telling me which rule is triggering this, so hoping someone here knows the answer? Thanks

1 Answers

I was able to fix my issue with &:

interface Meta {
  createdAt: string;
  updatedAt: string;
}

type WithMeta<T> = T & Meta;
Related