|
| 1 | +//// [tests/cases/compiler/jsxNamespaceGlobalReexport.tsx] //// |
| 2 | + |
| 3 | +//// [index.d.ts] |
| 4 | +type Defaultize<Props, Defaults> = |
| 5 | + // Distribute over unions |
| 6 | + Props extends any // Make any properties included in Default optional |
| 7 | + ? Partial<Pick<Props, Extract<keyof Props, keyof Defaults>>> & |
| 8 | + // Include the remaining properties from Props |
| 9 | + Pick<Props, Exclude<keyof Props, keyof Defaults>> |
| 10 | + : never; |
| 11 | +export namespace JSXInternal { |
| 12 | + interface HTMLAttributes<T = {}> { } |
| 13 | + interface SVGAttributes<T = {}> { } |
| 14 | + type LibraryManagedAttributes<Component, Props> = Component extends { |
| 15 | + defaultProps: infer Defaults; |
| 16 | + } |
| 17 | + ? Defaultize<Props, Defaults> |
| 18 | + : Props; |
| 19 | + |
| 20 | + interface IntrinsicAttributes { |
| 21 | + key?: any; |
| 22 | + } |
| 23 | + |
| 24 | + interface Element extends VNode<any> { } |
| 25 | + |
| 26 | + interface ElementClass extends Component<any, any> { } |
| 27 | + |
| 28 | + interface ElementAttributesProperty { |
| 29 | + props: any; |
| 30 | + } |
| 31 | + |
| 32 | + interface ElementChildrenAttribute { |
| 33 | + children: any; |
| 34 | + } |
| 35 | + |
| 36 | + interface IntrinsicElements { |
| 37 | + div: HTMLAttributes; |
| 38 | + } |
| 39 | +} |
| 40 | +export const Fragment: unique symbol; |
| 41 | +export type ComponentType<T = {}> = {}; |
| 42 | +export type ComponentChild = {}; |
| 43 | +export type ComponentChildren = {}; |
| 44 | +export type VNode<T = {}> = {}; |
| 45 | +export type Attributes = {}; |
| 46 | +export type Component<T = {}, U = {}> = {}; |
| 47 | +//// [index.d.ts] |
| 48 | +export { Fragment } from '..'; |
| 49 | +import { |
| 50 | + ComponentType, |
| 51 | + ComponentChild, |
| 52 | + ComponentChildren, |
| 53 | + VNode, |
| 54 | + Attributes |
| 55 | +} from '..'; |
| 56 | +import { JSXInternal } from '..'; |
| 57 | + |
| 58 | +export function jsx( |
| 59 | + type: string, |
| 60 | + props: JSXInternal.HTMLAttributes & |
| 61 | + JSXInternal.SVGAttributes & |
| 62 | + Record<string, any> & { children?: ComponentChild }, |
| 63 | + key?: string |
| 64 | +): VNode<any>; |
| 65 | +export function jsx<P>( |
| 66 | + type: ComponentType<P>, |
| 67 | + props: Attributes & P & { children?: ComponentChild }, |
| 68 | + key?: string |
| 69 | +): VNode<any>; |
| 70 | + |
| 71 | +export function jsxs( |
| 72 | + type: string, |
| 73 | + props: JSXInternal.HTMLAttributes & |
| 74 | + JSXInternal.SVGAttributes & |
| 75 | + Record<string, any> & { children?: ComponentChild[] }, |
| 76 | + key?: string |
| 77 | +): VNode<any>; |
| 78 | +export function jsxs<P>( |
| 79 | + type: ComponentType<P>, |
| 80 | + props: Attributes & P & { children?: ComponentChild[] }, |
| 81 | + key?: string |
| 82 | +): VNode<any>; |
| 83 | + |
| 84 | +export function jsxDEV( |
| 85 | + type: string, |
| 86 | + props: JSXInternal.HTMLAttributes & |
| 87 | + JSXInternal.SVGAttributes & |
| 88 | + Record<string, any> & { children?: ComponentChildren }, |
| 89 | + key?: string |
| 90 | +): VNode<any>; |
| 91 | +export function jsxDEV<P>( |
| 92 | + type: ComponentType<P>, |
| 93 | + props: Attributes & P & { children?: ComponentChildren }, |
| 94 | + key?: string |
| 95 | +): VNode<any>; |
| 96 | +// This shouldn't be preferred over |
| 97 | +//export namespace jsxDEV { |
| 98 | +// export import JSX = JSXInternal; |
| 99 | +//} |
| 100 | +// but it sort-of should work and it shouldn't crash. |
| 101 | +declare global { |
| 102 | + // @ts-ignore |
| 103 | + export import JSX = JSXInternal; |
| 104 | +} |
| 105 | +//// [index.tsx] |
| 106 | +export const Comp = () => <div></div>; |
| 107 | + |
| 108 | +//// [index.js] |
| 109 | +"use strict"; |
| 110 | +exports.__esModule = true; |
| 111 | +exports.Comp = void 0; |
| 112 | +var jsx_runtime_1 = require("preact/jsx-runtime"); |
| 113 | +var Comp = function () { return jsx_runtime_1.jsx("div", {}, void 0); }; |
| 114 | +exports.Comp = Comp; |
0 commit comments