Skip to content

[JSX] Cannot declare JSX elements to be in specific types. #13746

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.

constlistGrid=<ListGriddataSource={ds}canRemoveRecords/>asisc.IListGrid;

ListGrid is implemented as class:

classListGridextendsComponent<isc.IListGridOptions>{staticcreate(params,children){returnisc.ListGrid.create({
...<any>params,fields: params.fields ? [...params.fields, ...children] : children});}}abstractclassComponent<T>{/** A bogus type-system-only property. */private__bogusProps: T;staticcreate(params: any[],children){}}

JSX declaration:

declare module JSX{exportinterfaceIntrinsicElements{}interfaceElementextendsisc.ICanvas{}interfaceElementClassextendsComponent<any>{}interfaceHtmlElementInstanceextendsElementClass{}interfaceElementAttributesProperty{__bogusProps;}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions