镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
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.

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; }
}

Activity

  1. added
    SuggestionAn idea for TypeScript
    DuplicateAn existing issue was already created
    and removed
    Domain: JSX/TSXRelates to the JSX parser and emitter
    SuggestionAn idea for TypeScript
    on Mar 7, 2019
  2. RyanCavanaugh commented on Mar 7, 2019

    @RyanCavanaugh
    Member

    Handled by #21699

  3. typescript-bot commented on Mar 10, 2019

    @typescript-bot
    Contributor

    This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

  4. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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