summaryrefslogtreecommitdiffhomepage
path: root/services/blog/nuldoc-src/jsx/types.d.ts
blob: 973b8521121b3caaf8cc3b353967885ededd4b24 (plain)
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
import type {
  FunctionComponentResult,
  JSXElement,
  JSXNode,
} from "myjsx/jsx-runtime";

export { JSXNode };

interface IntrinsicElementType {
  children?: JSXNode;
  className?: string;
  id?: string;
  // My JSX runtime does not use key. It is only for linter that complains about missing key.
  key?: string;
}

declare global {
  namespace JSX {
    type Element = JSXElement;
    type ElementType =
      | string
      // deno-lint-ignore no-explicit-any
      | ((props: any) => FunctionComponentResult);

    // TODO: HTML 用の element と XML 用の element を分ける
    interface IntrinsicElements {
      // XML (Atom)
      author: IntrinsicElementType;
      entry: IntrinsicElementType;
      feed: IntrinsicElementType & { xmlns: string };
      id: IntrinsicElementType;
      name: IntrinsicElementType;
      published: IntrinsicElementType;
      summary: IntrinsicElementType;
      updated: IntrinsicElementType;
      // HTML
      a: IntrinsicElementType & {
        href?: string;
        rel?: "noreferrer";
        target?: "_blank";
      };
      article: IntrinsicElementType;
      body: IntrinsicElementType;
      button: IntrinsicElementType & { type: string };
      canvas: { id?: string; "data-slide-link"?: string };
      div: IntrinsicElementType;
      footer: IntrinsicElementType;
      h1: IntrinsicElementType;
      h2: IntrinsicElementType;
      head: unknown;
      header: IntrinsicElementType;
      html: IntrinsicElementType & { lang?: string };
      img: { src: string };
      li: IntrinsicElementType;
      link: { rel: string; href: string; type?: string };
      main: IntrinsicElementType;
      meta: {
        charset?: string;
        name?: string;
        content?: string;
        property?: string;
      };
      nav: IntrinsicElementType;
      noscript: IntrinsicElementType;
      ol: IntrinsicElementType;
      p: IntrinsicElementType;
      script: { src: string; type?: string; defer?: "true" };
      section: IntrinsicElementType;
      span: IntrinsicElementType;
      time: IntrinsicElementType & { datetime?: string };
      title: IntrinsicElementType;
      ul: IntrinsicElementType;
    }

    interface ElementChildrenAttribute {
      children: unknown;
    }

    type LibraryManagedAttributes<_F, P> = P & {
      // My JSX runtime does not use key. It is only for linter that complains about missing key.
      key?: string;
    };
  }
}