Propose TypeScript definitions files structure update

2 posts, 1 answers
  1. Matjaž
    Matjaž avatar
    74 posts
    Member since:
    Jul 2015

    Posted 12 Aug Link to this post

    Idea was born because of this answer.

    I propose you should reconsider splitting options into two interfaces. One for constructor and one for common use. TypeScript users would gain a lot, since this tell us which properties exists on specific widget and are safe to use.

    The other benefit is to avoid typecasting to any.

    Propose definition structure:

    class Window extends kendo.ui.Widget
        static fn: Window;
        options: WindowProperties;      //notice a change
        readonly isMaximized?: boolean;
        element: JQuery;
        wrapper: JQuery;
        static extend(proto: Object): Window;
        constructor(element: Element, options?: WindowOptions);
        center(): kendo.ui.Window;
        close(): kendo.ui.Window;
        content(): string;
        content(content?: string): kendo.ui.Window;
        content(content?: JQuery): kendo.ui.Window;
        destroy(): void;
        maximize(): kendo.ui.Window;
        minimize(): kendo.ui.Window;
        open(): kendo.ui.Window;
        pin(): void;
        refresh(options: any): kendo.ui.Window;
        restore(): kendo.ui.Window;
        setOptions(options: any): void;
        title(): string;
        title(text?: string): kendo.ui.Window;
        toFront(): kendo.ui.Window;
        toggleMaximization(): kendo.ui.Window;
        unpin(): void;
    interface WindowOptions {
        name?: string;
        actions?: any;
        animation?: boolean|WindowAnimation;
        appendTo?: any|string;
        autoFocus?: boolean;
        content?: WindowContent;
        draggable?: boolean;
        iframe?: boolean;
        height?: number|string;
        maxHeight?: number;
        maxWidth?: number;
        minHeight?: number;
        minWidth?: number;
        modal?: boolean;
        pinned?: boolean;
        position?: WindowPosition;
        resizable?: boolean;
        scrollable?: boolean;
        title?: string|boolean;
        visible?: boolean;
        width?: number|string;
        activate?(e: WindowEvent): void;
        close?(e: WindowCloseEvent): void;
        deactivate?(e: WindowEvent): void;
        dragend?(e: WindowEvent): void;
        dragstart?(e: WindowEvent): void;
        error?(e: WindowErrorEvent): void;
        maximize?(e: WindowEvent): void;
        minimize?(e: WindowEvent): void;
        open?(e: WindowEvent): void;
        refresh?(e: WindowEvent): void;
        resize?(e: WindowEvent): void;
    interface WindowProperties extends WindowOptions
        isMaximized?: boolean;

  2. Answer
    T. Tsonev
    T. Tsonev avatar
    2762 posts

    Posted 16 Aug Link to this post


    I think this particular case is specific to the Window. Mutating the user-passed options is not something we want to do on purpose. Let alone using them as a state storage.

    In this case the Window should expose a isMaximized method or similar. I've opened an issue on our GitHub repo for discussion and tracking purposes.

    T. Tsonev
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top