50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import type {
|
|
CompetitionFormat,
|
|
CompetitionId,
|
|
CompletedSeriesProjection,
|
|
InProgressSeriesProjection,
|
|
RoundRobinCompetitionFormat,
|
|
SeriesOutcome,
|
|
TeamId,
|
|
} from "../src/index.js";
|
|
|
|
type Expect<T extends true> = T;
|
|
type IsAssignable<From, To> = [From] extends [To] ? true : false;
|
|
type Not<T extends boolean> = T extends true ? false : true;
|
|
|
|
export type TeamIdCannotBeUsedAsCompetitionId = Expect<
|
|
Not<IsAssignable<TeamId, CompetitionId>>
|
|
>;
|
|
|
|
export type CompletedSeriesRequiresOutcome = Expect<
|
|
IsAssignable<CompletedSeriesProjection, { outcome: SeriesOutcome }>
|
|
>;
|
|
|
|
export type InProgressSeriesCannotExposeOutcome = Expect<
|
|
IsAssignable<InProgressSeriesProjection, { outcome?: never }>
|
|
>;
|
|
|
|
export type LegacyBracketModeIsNotACompetitionFormat = Expect<
|
|
Not<IsAssignable<{ type: "bracket" }, CompetitionFormat>>
|
|
>;
|
|
|
|
type ExplicitRoundRobinPairing = NonNullable<
|
|
RoundRobinCompetitionFormat["pairings"]
|
|
>[number];
|
|
|
|
export type ExplicitRoundRobinPairingsAreOptional = Expect<
|
|
IsAssignable<{}, Pick<RoundRobinCompetitionFormat, "pairings">>
|
|
>;
|
|
|
|
export type ExplicitRoundRobinPairingsAreTeamIdBased = Expect<
|
|
IsAssignable<
|
|
ExplicitRoundRobinPairing,
|
|
{
|
|
roundNumber: number;
|
|
matchNumber: number;
|
|
teamAId: TeamId;
|
|
teamBId: TeamId;
|
|
}
|
|
>
|
|
>;
|