File tree Expand file tree Collapse file tree 2 files changed +27
-15
lines changed Expand file tree Collapse file tree 2 files changed +27
-15
lines changed Original file line number Diff line number Diff line change @@ -141,17 +141,22 @@ declare namespace JSX {
141
141
For HTML tag autocompletion and good-enough attr validation, add this:
142
142
143
143
``` ts
144
- type jsxify <T extends HTMLElement > = {
145
- [A in keyof T as A extends string ? Lowercase <Exclude <A , ' children' >> : never ]? :
146
- string | boolean |
147
- (T [A ] extends (string | boolean | null | number )
148
- ? T [A ]
149
- : never )
144
+ declare namespace JSX {
145
+
146
+ // ...
150
147
148
+ type jsxify <T extends HTMLElement > = {
149
+ [A in keyof T as A extends string ? Lowercase <Exclude <A , ' children' >> : never ]? : (
150
+ | string
151
+ | boolean
152
+ | (T [A ] extends (string | boolean | null | number )
153
+ ? T [A ]
154
+ : never ))
151
155
} & { children? : any , class? : string }
152
156
153
157
type IntrinsicElements =
154
158
& { [K in keyof HTMLElementTagNameMap ]: jsxify <HTMLElementTagNameMap [K ]> }
155
- // add special cases here as necessary like this:
156
159
& { meta: jsxify <HTMLMetaElement > & { charset? : ' utf-8' } }
160
+
161
+ }
157
162
```
Original file line number Diff line number Diff line change 1
1
declare namespace JSX {
2
2
3
3
type jsxify < T extends HTMLElement > = {
4
- [ A in keyof T as A extends string ? Lowercase < Exclude < A , 'children' > > : never ] ?:
5
- string | boolean |
6
- ( T [ A ] extends ( string | boolean | null | number )
7
- ? T [ A ]
8
- : never )
9
-
4
+ [ A in keyof T as A extends string ? Lowercase < Exclude < A , 'children' > > : never ] ?: (
5
+ | string
6
+ | boolean
7
+ | ( T [ A ] extends ( string | boolean | null | number )
8
+ ? T [ A ]
9
+ : never ) )
10
10
} & { children ?: any , class ?: string }
11
11
12
12
type IntrinsicElements =
13
13
& { [ K in keyof HTMLElementTagNameMap ] : jsxify < HTMLElementTagNameMap [ K ] > }
14
14
// add special cases here as necessary like this:
15
15
& { meta : jsxify < HTMLMetaElement > & { charset ?: 'utf-8' } }
16
16
17
- type ElementChildrenAttribute = { children : any }
17
+ type jsxChildren =
18
+ | string
19
+ | false
20
+ | null
21
+ | undefined
22
+ | jsxChildren [ ]
23
+
24
+ type ElementChildrenAttribute = { children : jsxChildren }
18
25
19
26
type Element = string
20
27
21
28
type ElementType =
22
29
| string
23
- | ( ( data : any ) => JSX . Element )
30
+ | ( ( data : any ) => jsxChildren )
24
31
25
32
}
26
33
You can’t perform that action at this time.
0 commit comments