@@ -7,6 +7,7 @@ import * as t from "io-ts"
7
7
8
8
import Component , { ComponentConstructor } from "./component"
9
9
import {
10
+ NestedArray ,
10
11
tryParseJSON ,
11
12
mapNested ,
12
13
isEventAttr ,
@@ -43,6 +44,7 @@ import {
43
44
generateRule ,
44
45
getAtomicProperties ,
45
46
} from "./css"
47
+ import { JSX } from "./types/jsx"
46
48
import { EVENT_HANDLER_GRACE_PERIOD_MS } from "./constants"
47
49
48
50
export interface RenderOptions {
@@ -173,9 +175,9 @@ const RENDER_CSS_NOT_CALLED_ERROR =
173
175
export function createElem (
174
176
nodeName : string | ComponentConstructor < any , any > ,
175
177
attributes :
176
- | ( JSX . InputHTMLAttributes < any > &
177
- JSX . TextareaHTMLAttributes < any > &
178
- JSX . OptionHTMLAttributes < any > )
178
+ | ( JSX . InputHTMLAttributes &
179
+ JSX . TextareaHTMLAttributes &
180
+ JSX . OptionHTMLAttributes )
179
181
| null ,
180
182
...children : NestedArray < JSX . Child >
181
183
) : JSX . Element {
@@ -850,12 +852,10 @@ async function makeRegularElem(
850
852
}
851
853
852
854
if ( nodeName === "input" ) {
853
- const type = ( attributes as JSX . InputHTMLAttributes < any > )
854
- . type as string
855
+ const type = ( attributes as JSX . InputHTMLAttributes ) . type as string
855
856
validator = makeValidator ( INPUT_TYPE_VALIDATOR [ type ] || t . string )
856
857
} else if ( nodeName === "select" ) {
857
- const multiple = ( attributes as JSX . SelectHTMLAttributes < any > )
858
- . multiple
858
+ const multiple = ( attributes as JSX . SelectHTMLAttributes ) . multiple
859
859
validator = makeValidator ( multiple ? t . array ( t . string ) : t . string )
860
860
} else if ( nodeName === "textarea" ) {
861
861
validator = makeValidator ( t . string )
@@ -1266,16 +1266,11 @@ export const scriptPath = pathLib.resolve(
1266
1266
"browser.js" ,
1267
1267
)
1268
1268
1269
- // Export all values above on the default object as well.
1270
- export default {
1271
- createElem,
1272
- handleWebSocket,
1273
- render,
1274
- renderCSS,
1275
- Component,
1276
- scriptPath,
1277
- reloadOptions,
1278
- }
1269
+ // Export all values above on the default object as well. Do this through
1270
+ // a namespace so we can use a locally scoped JSX namespace:
1271
+ // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#locally-scoped-jsx-namespaces
1272
+ import { Purview } from "./namespace"
1273
+ export default Purview
1279
1274
1280
1275
// Export relevant types.
1281
1276
export {
@@ -1286,4 +1281,4 @@ export {
1286
1281
PurviewEvent ,
1287
1282
} from "./types/ws"
1288
1283
export { css , styledTag , CSS } from "./css"
1289
- export * from "./types/jsx"
1284
+ export { JSX , NestedArray }
0 commit comments