-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
77 lines (63 loc) · 1.79 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
declare module "https://unpkg.com/preact@latest?module" {
export function h(
name: string,
props?: any,
children?: VNode[]
): VNode;
export function h<Props>(
component: Component<Props>,
props?: Exclude<Props, "children">,
children?: VNode[],
): VNode;
export type Component<Props> = (props: Props) => VNode;
type VNode = string | null | any;
export function render(node: VNode, element: HTMLElement): any;
export let Fragment: any;
}
declare module "https://unpkg.com/preact@latest/hooks/dist/hooks.module.js?module" {
export type Reducer<State, Action> =
(state: State, action: Action) => State;
export type Dispatcher<Action> =
(action: Action) => void;
export function useReducer<State, Action>(
reducer: Reducer<State, Action>,
initialState: State,
): [State, Dispatcher<Action>];
type EffectCallback = () => void | (() => void);
export function useEffect(
callback: EffectCallback,
dependencies: any[]
): void;
}
declare namespace Tally {
export type Player = {
id: string,
name: string,
score: number,
}
export type Log = {
player: string,
score: number,
}
export type State = {
status: "waiting" | "playing" | "paused",
newPlayerName: string,
selectedPlayerId: string | null,
players: Player[],
history: Log[],
temporaryScore: number,
increments: number[],
paused: boolean,
}
export type Action =
| { type: "reset-scores" }
| { type: "start-game" }
| { type: "load-game", state: State }
| { type: "pause-game" }
| { type: "reset-game" }
| { type: "change-score", amount: number }
| { type: "select-next-player" }
| { type: "select-player", id: string }
| { type: "add-player" }
| { type: "set-new-player-name", name: string }
}