-
Notifications
You must be signed in to change notification settings - Fork 4
/
types.ts
47 lines (38 loc) · 1.32 KB
/
types.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
import { Location } from "history"
import * as React from "react"
import { RouteProps, StaticContext } from "react-router"
import { RouteComponentProps } from "react-router-dom"
export type Model = {
id: number
}
export type ErrMsg = React.ReactElement | string
export type CustomRouteProps = RouteProps & {
title: string
}
export type QA = {
"data-qa"?: string
}
export type TimeoutType = number | undefined
// viz https://stackoverflow.com/a/59857898/10045971
export type CustomRouteComponentProps<Params = {}> = RouteComponentProps<
Params,
StaticContext,
LocationState
>
type LocationState = {
from: Location
}
export declare type fEmptyVoid = () => void
export declare type fEmptyReturn = () => any
export declare type fArgVoid = (...args: any[]) => void
export declare type fArgReturn = (...args: any[]) => any
export declare type fFunction = fEmptyVoid | fEmptyReturn | fArgVoid | fArgReturn
/**
* Všechny atributy kromě zadaných K nastaví jako volitelné.
*
* Příklad: AtLeast<{model: string, rel: string, title: string}, "model" | "rel">
* Viz: https://stackoverflow.com/a/57390160/10045971
*/
type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>
/** Připraví Model pro PATCH operace - zafixuje pomocí AtLeast atribut id. */
export type PatchType<T extends Model> = AtLeast<T, "id">