-
Notifications
You must be signed in to change notification settings - Fork 0
/
zero.ts
59 lines (50 loc) · 1.71 KB
/
zero.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
// https://dev.to/ferdaber/typescript-and-jsx-part-ii---what-can-create-jsx-22h6
// https://github.com/ferdaber --> Der weiss evtl ne Menge
declare global {
namespace Zero {
type WithClass<Type> = {
[Property in keyof Type]?: Type[Property];
} & {
class?: string;
charset?: string
};
// interface ThisTypeMightBeUseful extends HTMLElementTagNameMap { }
interface HtmlElement extends Omit<HTMLElement, "style"> {
style?: string;
}
// Maybe we can construct a joined type with these stuff
// This example excludes style from the HTMLElementTagNameMap
// type NoCart = Omit<HTMLElementTagNameMap, "style">;
interface HtmlElementTagNameMap
extends Omit<HTMLElementTagNameMap, "style"> {
style?: string;
}
interface SvgElementTagNameMap extends Omit<SVGElementTagNameMap, "style"> {
style?: string;
}
}
namespace JSX {
interface Element extends Zero.HtmlElement {
new (props: any, context?: any): Zero.WithClass<Zero.HtmlElement>;
}
type ElementClass = never;
type ElementAttributesProperty = never;
type ElementChildrenAttribute = never;
// custom prop types for example <div myProp={} />
type IntrinsicAttributes = {
[Property in keyof Zero.HtmlElement]?: Zero.HtmlElement[Property];
};
type IntrinsicClassAttributes = {
[Property in keyof Zero.HtmlElement]?: Zero.HtmlElement[Property];
};
type SvgAny = {
[Property in keyof Zero.SvgElementTagNameMap]?: any;
};
type IntrinsicElements = {
// SVG does not exist in
[Property in keyof Zero.HtmlElementTagNameMap]?: Zero.WithClass<
Zero.HtmlElementTagNameMap[Property]
>;
} & SvgAny;
}
}