JobDerived.ts 535 B

12345678910111213141516
  1. import Job from "@/Job";
  2. type JobConstructorParameters = ConstructorParameters<typeof Job>;
  3. // Borrowed from https://dev.to/futuresight/how-2-typescript-get-the-last-item-type-from-a-tuple-of-types-3fh3#comment-gb5d
  4. type DropFirstInTuple<T extends any[]> = ((...args: T) => any) extends (
  5. arg: any,
  6. ...rest: infer U
  7. ) => any
  8. ? U
  9. : T;
  10. type DerivedJobConstructorParameters =
  11. DropFirstInTuple<JobConstructorParameters>;
  12. export interface JobDerived extends Job {
  13. new (...args: DerivedJobConstructorParameters): Job & typeof Job;
  14. }