Closed
Description
Hi,
I'm currently writing TSX support for existing GUI framework and the problem is that it works not like a ReactJS it does not have an AST which is transformed into real objects later in rendering.
The problem is that any JSX return type can only be strictly defined via JSX module Element interface so every time explicit casting to proper type is needed.
Is there any way to declare each return type per each class explicitly?
I think it would be useful for other GUI frameworks which works on objects directly instead of ASTs (as in React). Thanks.
const listGrid = <ListGrid dataSource={ds} canRemoveRecords/> as isc.IListGrid;
ListGrid is implemented as class:
class ListGrid extends Component<isc.IListGridOptions> {
static create(params, children) {
return isc.ListGrid.create({
...<any>params,
fields: params.fields ? [...params.fields, ...children] : children
});
}
}
abstract class Component<T> {
/** A bogus type-system-only property. */
private __bogusProps: T;
static create(params: any[], children) {
}
}
JSX declaration:
declare module JSX {
export interface IntrinsicElements {}
interface Element extends isc.ICanvas { }
interface ElementClass extends Component<any> {}
interface HtmlElementInstance extends ElementClass {}
interface ElementAttributesProperty { __bogusProps; }
}