File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import { SnapshotResult } from "../constants/default-snapshot";
2525import { queryClient } from "../queries" ;
2626import { baseKey } from "../queries/utils/keys" ;
2727import { getSnapshot } from "../states/snapshot" ;
28+ import { ExactlyOneTrue } from "../utils/types" ;
2829
2930export type ResultsQueryState = {
3031 difficulty : SnapshotResult < Mode > [ "difficulty" ] [ ] ;
@@ -385,16 +386,10 @@ export async function getUserAverage<M extends Mode>(
385386 language : string ;
386387 difficulty : Difficulty ;
387388 lazyMode : boolean ;
388- } & (
389- | {
390- last10Only : boolean ;
391- lastDayOnly ?: never ;
392- }
393- | {
394- lastDayOnly : boolean ;
395- last10Only ?: never ;
396- }
397- ) ,
389+ } & ExactlyOneTrue < {
390+ last10Only : boolean ;
391+ lastDayOnly : boolean ;
392+ } > ,
398393) : Promise < [ number , number ] > {
399394 const activeTagIds = getSnapshot ( )
400395 ?. tags . filter ( ( it ) => it . active === true )
Original file line number Diff line number Diff line change 1+ export type OneOf < T > = {
2+ [ K in keyof T ] : {
3+ [ P in K ] : T [ P ] ;
4+ } & {
5+ [ P in Exclude < keyof T , K > ] ?: never ;
6+ } ;
7+ } [ keyof T ] ;
8+
9+ export type ExactlyOneTrue < T extends Record < string , boolean > > = {
10+ [ K in keyof T ] : {
11+ [ P in K ] : true ;
12+ } & {
13+ [ P in Exclude < keyof T , K > ] ?: false | never ;
14+ } ;
15+ } [ keyof T ] ;
You can’t perform that action at this time.
0 commit comments