|
| 1 | +//// [tests/cases/compiler/jsxFactoryAndReactNamespace.ts] //// |
| 2 | + |
| 3 | +//// [Element.ts] |
| 4 | + |
| 5 | +declare namespace JSX { |
| 6 | + interface Element { |
| 7 | + name: string; |
| 8 | + isIntrinsic: boolean; |
| 9 | + isCustomElement: boolean; |
| 10 | + toString(renderId?: number): string; |
| 11 | + bindDOM(renderId?: number): number; |
| 12 | + resetComponent(): void; |
| 13 | + instantiateComponents(renderId?: number): number; |
| 14 | + props: any; |
| 15 | + } |
| 16 | +} |
| 17 | +export namespace Element { |
| 18 | + export function isElement(el: any): el is JSX.Element { |
| 19 | + return el.markAsChildOfRootElement !== undefined; |
| 20 | + } |
| 21 | + |
| 22 | + export function createElement(args: any[]) { |
| 23 | + |
| 24 | + return { |
| 25 | + } |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +export let createElement = Element.createElement; |
| 30 | + |
| 31 | +function toCamelCase(text: string): string { |
| 32 | + return text[0].toLowerCase() + text.substring(1); |
| 33 | +} |
| 34 | + |
| 35 | +//// [test.tsx] |
| 36 | +import { Element} from './Element'; |
| 37 | + |
| 38 | +let c: { |
| 39 | + a?: { |
| 40 | + b: string |
| 41 | + } |
| 42 | +}; |
| 43 | + |
| 44 | +class A { |
| 45 | + view() { |
| 46 | + return [ |
| 47 | + <meta content="helloworld"></meta>, |
| 48 | + <meta content={c.a!.b}></meta> |
| 49 | + ]; |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +//// [Element.js] |
| 54 | +"use strict"; |
| 55 | +var Element; |
| 56 | +(function (Element) { |
| 57 | + function isElement(el) { |
| 58 | + return el.markAsChildOfRootElement !== undefined; |
| 59 | + } |
| 60 | + Element.isElement = isElement; |
| 61 | + function createElement(args) { |
| 62 | + return {}; |
| 63 | + } |
| 64 | + Element.createElement = createElement; |
| 65 | +})(Element = exports.Element || (exports.Element = {})); |
| 66 | +exports.createElement = Element.createElement; |
| 67 | +function toCamelCase(text) { |
| 68 | + return text[0].toLowerCase() + text.substring(1); |
| 69 | +} |
| 70 | +//// [test.js] |
| 71 | +"use strict"; |
| 72 | +const Element_1 = require("./Element"); |
| 73 | +let c; |
| 74 | +class A { |
| 75 | + view() { |
| 76 | + return [ |
| 77 | + Element_1.Element.createElement("meta", { content: "helloworld" }), |
| 78 | + Element_1.Element.createElement("meta", { content: c.a.b }) |
| 79 | + ]; |
| 80 | + } |
| 81 | +} |
0 commit comments