forked from refined-github/refined-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobals.d.ts
83 lines (70 loc) · 2.74 KB
/
globals.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
/* eslint-disable @typescript-eslint/consistent-type-definitions -- Declaration merging necessary */
/* eslint-disable @typescript-eslint/consistent-indexed-object-style */
type AnyObject = Record<string, any>;
type DeinitHandle = {disconnect: VoidFunction} | {clear: VoidFunction} | {destroy: VoidFunction} | {abort: VoidFunction} | VoidFunction;
type Deinit = DeinitHandle | DeinitHandle[];
type FeatureID = string & {feature: true};
interface FeatureMeta {
id: FeatureID;
description: string;
screenshot?: string;
}
interface Window {
content: GlobalFetch;
}
declare module 'markdown-wasm/dist/markdown.node.js';
declare module 'filter-altered-clicks' {
export default function filterAlteredClicks<Listener>(handler: Listener): Listener;
}
declare module 'size-plugin';
declare module '*.md' { // It should be just for readme.md, but 🤷♂️
export const importedFeatures: FeatureID[];
export const featuresMeta: FeatureMeta[];
}
// Custom UI events specific to RGH
interface GlobalEventHandlersEventMap {
'details:toggled': CustomEvent;
'pjax:error': CustomEvent;
'page:loaded': CustomEvent;
'turbo:visit': CustomEvent;
'session:resume': CustomEvent;
}
declare namespace JSX {
/* eslint-disable @typescript-eslint/no-redundant-type-constituents -- https://github.com/refined-github/refined-github/pull/5654#discussion_r878891540 */
interface IntrinsicElements {
'clipboard-copy': IntrinsicElements.button & {for?: string};
'details-dialog': IntrinsicElements.div & {tabindex: string};
'details-menu': IntrinsicElements.div & {src?: string; preload?: boolean};
'has-rgh': IntrinsicElements.div;
'has-rgh-inner': IntrinsicElements.div;
'include-fragment': IntrinsicElements.div & {src?: string};
'label': IntrinsicElements.label & {for?: string};
'relative-time': IntrinsicElements.div & {datetime: string};
'tab-container': IntrinsicElements.div;
'batch-deferred-content': IntrinsicElements.div;
'time-ago': IntrinsicElements.div & {datetime: string; format?: string};
}
/* eslint-enable @typescript-eslint/no-redundant-type-constituents */
type BaseElement = IntrinsicElements['div'];
interface IntrinsicAttributes extends BaseElement {
width?: number;
height?: number;
}
}
// Drop after https://github.com/Microsoft/TypeScript/issues/30928
interface NamedNodeMap {
[key: string]: Attr;
}
// Drop after https://github.com/Microsoft/TypeScript/issues/30928
interface HTMLFormControlsCollection {
[key: string]: HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement;
}
declare module 'react' {
const FC = (): JSX.Element => JSX.Element;
const React = {FC};
export default React;
}
// Make `element.cloneNode()` preserve its type instead of returning Node
interface Node extends EventTarget {
cloneNode(deep?: boolean): this;
}