flaschengeist-types/types/PEP440.d.ts

15 lines
625 B
TypeScript

/* This is some sort of PEP440 subset */
type Join<T extends unknown[], D extends string> = T extends []
? ''
: T extends [string | number | boolean | bigint]
? `${T[0]}`
: T extends [string | number | boolean | bigint, ...infer U]
? `${T[0]}${D}${Join<U, D>}`
: string;
type BaseVersion = Join<[number, number], '.'> | Join<[number, number, number], '.'>;
type PreRelease = Join<[['a' | 'b' | 'rc'], number], '.'>;
type PRVersion = BaseVersion | `${BaseVersion}${PreRelease}`;
/** A PEP440 subset used to describe backend module versions */
declare type PEP440Version = PRVersion | `${PRVersion}.dev${number}`;