Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
antanas-arvasevicius opened this issue Jan 30, 2017 · 2 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@antanas-arvasevicius
Copy link

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; }
}
@yuit yuit added the Domain: JSX/TSX Relates to the JSX parser and emitter label Apr 6, 2017
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.7 milestone Oct 17, 2017
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript and removed Bug A bug in TypeScript labels Oct 17, 2017
@DanielRosenwasser DanielRosenwasser removed this from the TypeScript 2.7 milestone Oct 17, 2017
@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Duplicate An existing issue was already created and removed Domain: JSX/TSX Relates to the JSX parser and emitter Suggestion An idea for TypeScript labels Mar 7, 2019
@RyanCavanaugh
Copy link
Member

Handled by #21699

@typescript-bot
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants