-
Notifications
You must be signed in to change notification settings - Fork 1
/
global.d.ts
107 lines (89 loc) · 2.35 KB
/
global.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/** @format */
import { ElectronAPI } from '@electron-toolkit/preload';
interface document {
documentMode: number;
}
interface BeforeInstallPromptEvent extends Event {
platforms: string[];
timeStamp: number;
type: 'beforeinstallprompt';
prompt: () => void;
userChoice: Promise<{
outcome: 'dismissed' | 'accepted' | string;
platform: string;
}>;
}
interface WindowEventMap {
beforeinstallprompt: BeforeInstallPromptEvent;
}
interface Event {
detail: any;
}
interface Navigator {
getBattery: () => Promise<any>;
battery: PlainObject;
mozBattery: PlainObject;
webkitBattery: PlainObject;
}
interface window {
webkitAudioContext: AudioContext;
requestIdleCallback: (cb: CommonFunction, options?: { timeout: number }) => void;
electron: ElectronAPI;
}
declare type CommonFunction = (...args: any[]) => any;
declare type PlainObject<T = any> = Record<string, T>;
//让数组也继承纯对象特性
interface Array<T> extends PlainObject<T> {}
declare type Writeable<T> = {
-readonly [K in keyof T]: T[K];
};
declare type FuncParamsType<T extends (...args: any[]) => any> = T extends (
...args: infer P
) => any
? P
: T;
declare type CtorParamsType<T extends abstract new (...args: any[]) => any> =
T extends new (...args: infer P) => any ? P : never;
/**
* UnionToIntersection<{ a: string } | { b: string }> = { a: string } & { b: string }
*/
declare type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (
x: infer U,
) => any
? U
: never;
/**
* LastUnion<'a' | 'b'> = 'b'
*/
declare type LastUnion<T> = UnionToIntersection<
T extends any ? (x: T) => any : never
> extends (x: infer L) => any
? L
: never;
/**
* UnionToTuple<'a' | 'b'> = ['a', 'b']
*/
declare type UnionToTuple<T, Last = LastUnion<T>> = [T] extends [never]
? []
: [...UnionToTuple<Exclude<T, Last>>, Last];
declare module '*.css';
declare module '*.scss';
declare module '*.json';
declare module '*.png';
declare module '*.jpg';
declare module '*.webp';
declare module '*.svg';
// declare module "colorthief" {
// class ColorThief {
// getColor: (
// src: HTMLOrSVGImageElement,
// quality?: number
// ) => [number, number, number];
// getPalette: (
// src: HTMLOrSVGImageElement,
// colorCount?: number,
// quality?: number
// ) => Array<[number, number, number]>;
// }
// export default ColorThief;
// }