This is a migrated thread and some comments may be shown as answers.

Propose TypeScript definitions files structure update

1 Answer 34 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Seyfor
Top achievements
Rank 1
Seyfor asked on 12 Aug 2016, 05:24 AM

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

1 Answer, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 16 Aug 2016, 07:55 AM
Hi,

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.

Regards,
T. Tsonev
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
General Discussions
Asked by
Seyfor
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or