Skip to content

Provide TypeScript Definitions #21

@mablay

Description

@mablay

Using TypeScript can be considered best practice for type checking in JS.
If you could provide the TS definitions for brite.js it would speed up development and increase the quality of applications using brite.js.

You can find more information about TypeScript here

With these quick and dirty stubs I made it through your "Task Manager" tutorial. They are certainly incomplete and might very well be wrong too, but it's a start.

FILE: "brite.d.ts"

/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="./brite.inMemoryDaoHandler.d.ts" />

// Type definitions for brite.js 1.1.2
// Project: http://britesnow.com/brite
// Definitions by: BriteSnow
// Definitions: https://github.com/BriteSnow/brite/DefinitelyTyped

declare module brite {

    export function registerView(name: String, config: Object, componentFactory?: any): void;
    export function display(viewName: String, parent: HTMLElement, data: Object, config: Object): void;
    export function display(name: String, selector: any, options?: Object);

    export interface DaoObject {
        create():any;
        list(options?:Object):any;
        get(id:String):any;
        update(id:String):any;
        delete(id:String):any;
    }
    export interface DaoHandler {
        entityType: any;        // support function or property
    }
    export function registerDao(daoHandler:DaoHandler):DaoObject;

    var config: {
        componentsHTMLHolder: String;
        tmplPath: String;
        jsPath: String;
        cssPath: String;
        tmplExt: String;
    }

    var viewDefaultConfig: {
        loadTmpl: boolean;
        loadCss: boolean;
        emptyParent : boolean;
        postDisplayDelay : number;
    }

}

file: "brite.InMemoryDaoHandler.d.ts"

/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="./brite.d.ts" />


declare module brite {
    export class InMemoryDaoHandler implements DaoHandler {
        entityType:any;
        constructor(entityType:String, seed:Array<Object>, opts?:Object);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions