From c16618cc4304b83e840ac3b7fa89be2d0771c3f8 Mon Sep 17 00:00:00 2001 From: soywiz Date: Wed, 23 Apr 2014 14:24:16 +0200 Subject: [PATCH 01/16] - Added tspromise definition --- tspromise/tspromise-test.ts | 21 +++++++++++++++++++++ tspromise/tspromise.d.ts | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tspromise/tspromise-test.ts create mode 100644 tspromise/tspromise.d.ts diff --git a/tspromise/tspromise-test.ts b/tspromise/tspromise-test.ts new file mode 100644 index 000000000..79903f0ce --- /dev/null +++ b/tspromise/tspromise-test.ts @@ -0,0 +1,21 @@ +/// + +import Promise = require('tspromise'); + +var MyFuncFunc = Promise.async((a: boolean, b: number) => { + console.log('[a] ' + a); + yield(Promise.waitAsync(1000)); + console.log('[b]' + b); +}); + +MyFuncFunc(true, 10); + +Promise.all([Promise.waitAsync(10), Promise.waitAsync(20)]).then(() => { + return new Promise((resolve, reject) => { + resolve('test'); + }); +}).then(() => { + throw (new Error()); +}).catch((e) => { + console.log(e.message); +}); \ No newline at end of file diff --git a/tspromise/tspromise.d.ts b/tspromise/tspromise.d.ts new file mode 100644 index 000000000..8608d105c --- /dev/null +++ b/tspromise/tspromise.d.ts @@ -0,0 +1,35 @@ +/// +declare class Thenable { + then(onFulfilled: (value: T) => Thenable, onRejected?: (error: Error) => TR): Thenable; + then(onFulfilled: (value: T) => Thenable, onRejected?: (error: Error) => void): Thenable; + then(onFulfilled: (value: T) => TR, onRejected?: (error: Error) => void): Thenable; + then(onFulfilled: (value: T) => TR, onRejected?: (error: Error) => TR): Thenable; + catch(onRejected: (error: Error) => T): Thenable; +} + +interface NodeCallback { + (err: Error, value: T): void; +} + +declare module "tspromise" { + class Promise extends Thenable { + constructor(callback: (resolve: (value?: T) => void, reject?: (error: Error) => void) => void); + static resolve(value?: T): Thenable; + static resolve(promise: Thenable): Thenable; + static reject(error: Error): Thenable; + static all(promises: Thenable[]): Thenable; + static async(callback: () => TR): () => Thenable; + static async(callback: (p1: T1) => TR): (p1: T1) => Thenable; + static async(callback: (p1: T1, p2: T2) => TR): (p1: T1, p2: T2) => Thenable; + static async(callback: (p1: T1, p2: T2, p3: T3) => TR): (p1: T1, p2: T2, p3: T3) => Thenable; + static async(callback: (p1: T1, p2: T2, p3: T3, p4: T4) => TR): (p1: T1, p2: T2, p3: T3, p4: T4) => Thenable; + static spawn(generatorFunction: () => TR): Thenable; + static rewriteFolderSync(path: string): void; + static waitAsync(time: number): Thenable<{}>; + static nfcall(obj: any, methodName: String, ...args: any[]): Thenable; + } + + export = Promise; +} + +declare function yield(promise: Thenable): T; From 6550e264a59748eb7027a417b05390d693e2aebe Mon Sep 17 00:00:00 2001 From: soywiz Date: Wed, 23 Apr 2014 14:26:24 +0200 Subject: [PATCH 02/16] - Added info to definition --- tspromise/tspromise.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tspromise/tspromise.d.ts b/tspromise/tspromise.d.ts index 8608d105c..0d1132ed1 100644 --- a/tspromise/tspromise.d.ts +++ b/tspromise/tspromise.d.ts @@ -1,4 +1,9 @@ -/// +// Type definitions for tspromise 0.0.4 +// Project: https://github.com/soywiz/tspromise +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// declare class Thenable { then(onFulfilled: (value: T) => Thenable, onRejected?: (error: Error) => TR): Thenable; then(onFulfilled: (value: T) => Thenable, onRejected?: (error: Error) => void): Thenable; From c4d0c9a5515c036e60e3809b4327eadf4056c643 Mon Sep 17 00:00:00 2001 From: "Omid K. Rad" Date: Thu, 24 Apr 2014 17:45:31 -0700 Subject: [PATCH 03/16] Backbone Generics --- backbone-relational/backbone-relational.d.ts | 25 +- backbone/backbone-tests.ts | 157 +++++++----- backbone/backbone.d.ts | 248 ++++++++++--------- backgrid/backgrid-tests.ts | 6 +- backgrid/backgrid.d.ts | 20 +- giraffe/giraffe-tests.ts | 12 +- giraffe/giraffe.d.ts | 75 +++--- jointjs/jointjs.d.ts | 14 +- knockback/knockback.d.ts | 6 +- marionette/marionette.d.ts | 164 ++++++------ 10 files changed, 395 insertions(+), 332 deletions(-) diff --git a/backbone-relational/backbone-relational.d.ts b/backbone-relational/backbone-relational.d.ts index 56dd2e9e8..4f4aa45cc 100644 --- a/backbone-relational/backbone-relational.d.ts +++ b/backbone-relational/backbone-relational.d.ts @@ -5,12 +5,15 @@ /// - /// declare module Backbone { - export class RelationalModel extends Model { - static extend(properties:any, classProperties?:any):any; // do not use, prefer TypeScript's extend functionality + class RelationalModel extends Model { + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + //private static extend(properties:any, classProperties?:any):any; + relations:any; subModelTypes:any; subModelTypeAttribute:any; @@ -58,7 +61,7 @@ declare module Backbone { setRelated(related:Model):void; - setRelated(related:Collection):void; + setRelated(related:Collection):void; getReverseRelations(model:RelationalModel):Relation; @@ -78,15 +81,15 @@ declare module Backbone { setKeyContents(keyContents:number[]):void; - setKeyContents(keyContents:Collection):void; + setKeyContents(keyContents:Collection):void; onChange(model:Model, attr:any, options:any):void; - handleAddition(model:Model, coll:Collection, options:any):void; + handleAddition(model:Model, coll:Collection, options:any):void; - handleRemoval(model:Model, coll:Collection, options:any):void; + handleRemoval(model:Model, coll:Collection, options:any):void; - handleReset(coll:Collection, options:any):void; + handleReset(coll:Collection, options:any):void; tryAddRelated(model:Model, coll:any, options:any):void; @@ -135,9 +138,9 @@ declare module Backbone { processOrphanRelations():void; - retroFitRelation(relation:RelationalModel, create:boolean):Collection; + retroFitRelation(relation:RelationalModel, create:boolean):Collection; - getCollection(type:RelationalModel, create:boolean):Collection; + getCollection(type:RelationalModel, create:boolean):Collection; getObjectByName(name:string):any; @@ -158,7 +161,7 @@ declare module Backbone { update(model:RelationalModel):void; - unregister(model:RelationalModel, collection:Collection, options:any):void; + unregister(model:RelationalModel, collection:Collection, options:any):void; reset():void; diff --git a/backbone/backbone-tests.ts b/backbone/backbone-tests.ts index c1292c1c2..bf44c56f7 100644 --- a/backbone/backbone-tests.ts +++ b/backbone/backbone-tests.ts @@ -4,7 +4,7 @@ function test_events() { var object = new Backbone.Events(); - object.on("alert", (msg) => alert("Triggered " + msg)); + object.on("alert", (eventName: string) => alert("Triggered " + eventName)); object.trigger("alert", "an event"); @@ -18,48 +18,74 @@ function test_events() { object.off(); } +class SettingDefaults extends Backbone.Model { + + // 'defaults' could be set in one of the following ways: + + defaults() { + return { + name: "Joe" + } + } + + constructor(attributes?: any, options?: any) { + this.defaults = { + name: "Joe" + } + // super has to come last + super(attributes, options); + } + + // or set it like this + initialize() { + this.defaults = { + name: "Joe" + } + + } + + // same patterns could be used for setting 'Router.routes' and 'View.events' +} + +class Sidebar extends Backbone.Model { + + promptColor() { + var cssColor = prompt("Please enter a CSS color:"); + this.set({ color: cssColor }); + } +} + +class Note extends Backbone.Model { + initialize() { } + author() { } + coordinates() { } + allowedToEdit(account: any) { + return true; + } +} + +class PrivateNote extends Note { + allowedToEdit(account: any) { + return account.owns(this); + } + + set(attributes: any, options?: any): Backbone.Model { + return Backbone.Model.prototype.set.call(this, attributes, options); + } +} + function test_models() { - var Sidebar = Backbone.Model.extend({ - promptColor: function () { - var cssColor = prompt("Please enter a CSS color:"); - this.set({ color: cssColor }); - } - }); - var sidebar = new Sidebar(); - sidebar.on('change:color', (model, color) => $('#sidebar').css({ background: color })); + sidebar.on('change:color', (model: {}, color: string) => $('#sidebar').css({ background: color })); sidebar.set({ color: 'white' }); sidebar.promptColor(); - //////// - - var Note = Backbone.Model.extend({ - initialize: () => { }, - author: () => { }, - coordinates: () => { }, - allowedToEdit: (account) => { - return true; - } - }); - - var PrivateNote = Note.extend({ - - allowedToEdit: function (account) { - return account.owns(this); - } - - }); - ////////// - var note = Backbone.Model.extend({ - set: function (attributes, options) { - Backbone.Model.prototype.set.call(this, attributes, options); - } - }); + var note = new PrivateNote(); - note.get("title") + note.get("title"); note.set({ title: "March 20", content: "In his eyes she eclipses..." }); @@ -69,7 +95,7 @@ function test_models() { class Employee extends Backbone.Model { reports: EmployeeCollection; - constructor (options? ) { + constructor(attributes?: any, options?: any) { super(options); this.reports = new EmployeeCollection(); this.reports.url = '../api/employees/' + this.id + '/reports'; @@ -80,29 +106,38 @@ class Employee extends Backbone.Model { } } -class EmployeeCollection extends Backbone.Collection { - findByName(key) { } +class EmployeeCollection extends Backbone.Collection { + findByName(key: any) { } } + +class Book extends Backbone.Model { + title: string; + author: string; +} + +class Library extends Backbone.Collection { + model: typeof Book; +} + +class Books extends Backbone.Collection { } + function test_collection() { - var Book: Backbone.Model; - var Library = Backbone.Collection.extend({ - model: Book + + var books = new Library(); + + books.each(book => { + book.get("title"); }); - var Books: Backbone.Collection; - - Books.each(function (book) { - }); - - var titles = Books.map(function (book) { + var titles = books.map(book => { return book.get("title"); }); - var publishedBooks = Books.filter(function (book) { + var publishedBooks = books.filter(book => { return book.get("published") === true; }); - var alphabetical = Books.sortBy(function (book) { + var alphabetical = books.sortBy((book: Book): number => { return null; }); } @@ -121,26 +156,26 @@ module v1Changes { function test_listenTo() { var model = new Employee; - var view = new Backbone.View; + var view = new Backbone.View(); view.listenTo(model, 'invalid', () => { }); } function test_listenToOnce() { var model = new Employee; - var view = new Backbone.View; + var view = new Backbone.View(); view.listenToOnce(model, 'invalid', () => { }); } function test_stopListening() { var model = new Employee; - var view = new Backbone.View; + var view = new Backbone.View(); view.stopListening(model, 'invalid', () => { }); view.stopListening(model, 'invalid'); view.stopListening(model); } } - module modelandcollection { + module ModelAndCollection { function test_url() { Employee.prototype.url = () => '/employees'; EmployeeCollection.prototype.url = () => '/employees'; @@ -168,7 +203,7 @@ module v1Changes { } } - module model { + module Model { function test_validationError() { var model = new Employee; if (model.validationError) { @@ -195,17 +230,17 @@ module v1Changes { model.destroy({ wait: true, success: (m?, response?, options?) => { }, - error: (m?, jqxhr?: JQueryXHR, options?) => { } + error: (m?, jqxhr?, options?) => { } }); model.destroy({ success: (m?, response?, options?) => { }, - error: (m?, jqxhr?: JQueryXHR) => { } + error: (m?, jqxhr?) => { } }); model.destroy({ success: () => { }, - error: (m?, jqxhr?: JQueryXHR) => { } + error: (m?, jqxhr?) => { } }); } @@ -220,7 +255,7 @@ module v1Changes { wait: true, validate: false, success: (m?, response?, options?) => { }, - error: (m?, jqxhr?: JQueryXHR, options?) => { } + error: (m?, jqxhr?, options?) => { } }); model.save({ @@ -229,7 +264,7 @@ module v1Changes { }, { success: () => { }, - error: (m?, jqxhr?: JQueryXHR) => { } + error: (m?, jqxhr?) => { } }); } @@ -240,7 +275,7 @@ module v1Changes { } } - module collection { + module Collection { function test_fetch() { var collection = new EmployeeCollection; collection.fetch({ reset: true }); @@ -256,7 +291,7 @@ module v1Changes { } } - module router { + module Router { function test_navigate() { var router = new Backbone.Router; @@ -264,4 +299,4 @@ module v1Changes { router.navigate('/employees', true); } } -} \ No newline at end of file +} diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index d94e9172b..6fa7e6d60 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -6,6 +6,7 @@ /// +/// declare module Backbone { @@ -67,7 +68,7 @@ declare module Backbone { } class Events { - on(eventName: any, callback?: Function, context?: any): any; + on(eventName: string, callback?: Function, context?: any): any; off(eventName?: string, callback?: Function, context?: any): any; trigger(eventName: string, ...args: any[]): any; bind(eventName: string, callback: Function, context?: any): any; @@ -86,17 +87,22 @@ declare module Backbone { sync(...arg: any[]): JQueryXHR; } - interface OptionalDefaults { - defaults?(): any; - } + class Model extends ModelBase { - class Model extends ModelBase implements OptionalDefaults { - - static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + private static extend(properties: any, classProperties?: any): any; attributes: any; changed: any[]; cid: string; + /** + * Default attributes for the model. It can be an object hash or a method returning an object hash. + * For assigning an object hash, do it like this: this.defaults = { attribute: value, ... }; + * That works only if you set it in the constructor or the initialize method. + **/ + defaults(): any; id: any; idAttribute: string; validationError: any; @@ -127,7 +133,7 @@ declare module Backbone { unset(attribute: string, options?: Silenceable): Model; validate(attributes: any, options?: any): any; - _validate(attrs: any, options: any): boolean; + private _validate(attrs: any, options: any): boolean; // mixins from underscore @@ -141,115 +147,125 @@ declare module Backbone { omit(...keys: string[]): any; } - class Collection extends ModelBase { + class Collection extends ModelBase { - static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + private static extend(properties: any, classProperties?: any): any; - model: any; - models: any; - collection: Model; + // TODO: this really has to be typeof TModel + //model: typeof TModel; + model: { new(): TModel; }; // workaround + models: TModel[]; + collection: TModel; length: number; - constructor(models?: any, options?: any); + constructor(models?: TModel[], options?: any); fetch(options?: CollectionFetchOptions): JQueryXHR; - comparator(element: Model): any; - comparator(compare: Model, to?: Model): any; + comparator(element: TModel): number; + comparator(compare: TModel, to?: TModel): number; - add(model: Model, options?: AddOptions): Collection; - add(model: any, options?: AddOptions): Collection; - add(models: Model[], options?: AddOptions): Collection; - add(models: any[], options?: AddOptions): Collection; - at(index: number): Model; - get(id: any): Model; - create(attributes: any, options?: ModelSaveOptions): Model; + add(model: TModel, options?: AddOptions): Collection; + add(models: TModel[], options?: AddOptions): Collection; + at(index: number): TModel; + get(id: string): TModel; + create(attributes: any, options?: ModelSaveOptions): TModel; pluck(attribute: string): any[]; - push(model: Model, options?: AddOptions): Model; - pop(options?: Silenceable): Model; - remove(model: Model, options?: Silenceable): Model; - remove(models: Model[], options?: Silenceable): Model[]; - reset(models?: Model[], options?: Silenceable): Model[]; - reset(models?: any[], options?: Silenceable): Model[]; - set(models?: any[], options?: Silenceable): Model[]; - shift(options?: Silenceable): Model; - sort(options?: Silenceable): Collection; - unshift(model: Model, options?: AddOptions): Model; - where(properies: any): Model[]; - findWhere(properties: any): Model; + push(model: TModel, options?: AddOptions): TModel; + pop(options?: Silenceable): TModel; + remove(model: TModel, options?: Silenceable): TModel; + remove(models: TModel[], options?: Silenceable): TModel[]; + reset(models?: TModel[], options?: Silenceable): TModel[]; + set(models?: TModel[], options?: Silenceable): TModel[]; + shift(options?: Silenceable): TModel; + sort(options?: Silenceable): Collection; + unshift(model: TModel, options?: AddOptions): TModel; + where(properies: any): TModel[]; + findWhere(properties: any): TModel; - _prepareModel(attrs?: any, options?: any): any; - _removeReference(model: Model): void; - _onModelEvent(event: string, model: Model, collection: Collection, options: any): void; + private _prepareModel(attrs?: any, options?: any): any; + private _removeReference(model: TModel): void; + private _onModelEvent(event: string, model: TModel, collection: Collection, options: any): void; // mixins from underscore - all(iterator: (element: Model, index: number) => boolean, context?: any): boolean; - any(iterator: (element: Model, index: number) => boolean, context?: any): boolean; - collect(iterator: (element: Model, index: number, context?: any) => any[], context?: any): any[]; + all(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; + any(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; + collect(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[]; chain(): any; - compact(): Model[]; + compact(): TModel[]; contains(value: any): boolean; - countBy(iterator: (element: Model, index: number) => any): any[]; - countBy(attribute: string): any[]; + countBy(iterator: (element: TModel, index: number) => any): _.Dictionary; + countBy(attribute: string): _.Dictionary; detect(iterator: (item: any) => boolean, context?: any): any; // ??? - difference(...model: Model[]): Model[]; - drop(): Model; - drop(n: number): Model[]; - each(iterator: (element: Model, index: number, list?: any) => void , context?: any): any; - every(iterator: (element: Model, index: number) => boolean, context?: any): boolean; - filter(iterator: (element: Model, index: number) => boolean, context?: any): Model[]; - find(iterator: (element: Model, index: number) => boolean, context?: any): Model; - first(): Model; - first(n: number): Model[]; - flatten(shallow?: boolean): Model[]; - foldl(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any; - forEach(iterator: (element: Model, index: number, list?: any) => void , context?: any): any; + difference(...model: TModel[]): TModel[]; + drop(): TModel; + drop(n: number): TModel[]; + each(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any; + every(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; + filter(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[]; + find(iterator: (element: TModel, index: number) => boolean, context?: any): TModel; + first(): TModel; + first(n: number): TModel[]; + flatten(shallow?: boolean): TModel[]; + foldl(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; + forEach(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any; + groupBy(iterator: (element: TModel, index: number) => string, context?: any): _.Dictionary; + groupBy(attribute: string, context?: any): _.Dictionary; include(value: any): boolean; - indexOf(element: Model, isSorted?: boolean): number; - initial(): Model; - initial(n: number): Model[]; - inject(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any; - intersection(...model: Model[]): Model[]; + indexOf(element: TModel, isSorted?: boolean): number; + initial(): TModel; + initial(n: number): TModel[]; + inject(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; + intersection(...model: TModel[]): TModel[]; isEmpty(object: any): boolean; invoke(methodName: string, arguments?: any[]): any; - last(): Model; - last(n: number): Model[]; - lastIndexOf(element: Model, fromIndex?: number): number; - map(iterator: (element: Model, index: number, context?: any) => any[], context?: any): any[]; - max(iterator?: (element: Model, index: number) => any, context?: any): Model; - min(iterator?: (element: Model, index: number) => any, context?: any): Model; + last(): TModel; + last(n: number): TModel[]; + lastIndexOf(element: TModel, fromIndex?: number): number; + map(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[]; + max(iterator?: (element: TModel, index: number) => any, context?: any): TModel; + min(iterator?: (element: TModel, index: number) => any, context?: any): TModel; object(...values: any[]): any[]; - reduce(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any; + reduce(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; select(iterator: any, context?: any): any[]; size(): number; shuffle(): any[]; - some(iterator: (element: Model, index: number) => boolean, context?: any): boolean; - sortBy(iterator: (element: Model, index: number) => number, context?: any): Model[]; - sortBy(attribute: string, context?: any): Model[]; - sortedIndex(element: Model, iterator?: (element: Model, index: number) => number): number; + some(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; + sortBy(iterator: (element: TModel, index: number) => number, context?: any): TModel[]; + sortBy(attribute: string, context?: any): TModel[]; + sortedIndex(element: TModel, iterator?: (element: TModel, index: number) => number): number; range(stop: number, step?: number): any; range(start: number, stop: number, step?: number): any; - reduceRight(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any[]; - reject(iterator: (element: Model, index: number) => boolean, context?: any): Model[]; - rest(): Model; - rest(n: number): Model[]; - tail(): Model; - tail(n: number): Model[]; + reduceRight(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any[]; + reject(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[]; + rest(): TModel; + rest(n: number): TModel[]; + tail(): TModel; + tail(n: number): TModel[]; toArray(): any[]; - union(...model: Model[]): Model[]; - uniq(isSorted?: boolean, iterator?: (element: Model, index: number) => boolean): Model[]; - without(...values: any[]): Model[]; - zip(...model: Model[]): Model[]; + union(...model: TModel[]): TModel[]; + uniq(isSorted?: boolean, iterator?: (element: TModel, index: number) => boolean): TModel[]; + without(...values: any[]): TModel[]; + zip(...model: TModel[]): TModel[]; } - interface OptionalRoutes { - routes?(): any; - } + class Router extends Events { - class Router extends Events implements OptionalRoutes { + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + private static extend(properties: any, classProperties?: any): any; - static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality + /** + * Routes hash or a method returning the routes hash that maps URLs with parameters to methods on your Router. + * For assigning routes as object hash, do it like this: this.routes = { "route": callback, ... }; + * That works only if you set it in the constructor or the initialize method. + **/ + routes(): any; constructor(options?: RouterOptions); initialize(options?: RouterOptions): void; @@ -257,9 +273,9 @@ declare module Backbone { navigate(fragment: string, options?: NavigateOptions): Router; navigate(fragment: string, trigger?: boolean): Router; - _bindRoutes(): void; - _routeToRegExp(route: string): RegExp; - _extractParameters(route: RegExp, fragment: string): string[]; + private _bindRoutes(): void; + private _routeToRegExp(route: string): RegExp; + private _extractParameters(route: RegExp, fragment: string): string[]; } var history: History; @@ -279,14 +295,14 @@ declare module Backbone { loadUrl(fragmentOverride: string): boolean; navigate(fragment: string, options?: any): boolean; started: boolean; - options: any; - - _updateHash(location: Location, fragment: string, replace: boolean): void; + options: any; + + private _updateHash(location: Location, fragment: string, replace: boolean): void; } - interface ViewOptions { - model?: Backbone.Model; - collection?: Backbone.Collection; + interface ViewOptions { + model?: TModel; + collection?: Backbone.Collection; el?: any; id?: string; className?: string; @@ -294,35 +310,41 @@ declare module Backbone { attributes?: any[]; } - interface OptionalEvents { - events?(): any; - } + class View extends Events { - class View extends Events implements OptionalEvents { + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + private static extend(properties: any, classProperties?: any): any; - static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality + constructor(options?: ViewOptions); - constructor(options?: ViewOptions); + /** + * Events hash or a method returning the events hash that maps events/selectors to methods on your View. + * For assigning events as object hash, do it like this: this.events = { "event:selector": callback, ... }; + * That works only if you set it in the constructor or the initialize method. + **/ + events(): any; $(selector: string): JQuery; - model: Model; - collection: Collection; - make(tagName: string, attrs?: any, opts?: any): View; - setElement(element: HTMLElement, delegate?: boolean): View; - setElement(element: JQuery, delegate?: boolean): View; + model: TModel; + collection: Collection; + //template: (json, options?) => string; + make(tagName: string, attrs?: any, opts?: any): View; + setElement(element: HTMLElement, delegate?: boolean): View; + setElement(element: JQuery, delegate?: boolean): View; id: string; cid: string; className: string; tagName: string; - options: any; el: any; $el: JQuery; - setElement(element: any): View; + setElement(element: any): View; attributes: any; $(selector: any): JQuery; - render(): View; - remove(): View; + render(): View; + remove(): View; make(tagName: any, attributes?: any, content?: any): any; delegateEvents(events?: any): any; undelegateEvents(): any; @@ -333,14 +355,12 @@ declare module Backbone { // SYNC function sync(method: string, model: Model, options?: JQueryAjaxSettings): any; function ajax(options?: JQueryAjaxSettings): JQueryXHR; - var emulateHTTP: boolean; + var emulateHTTP: boolean; var emulateJSONBackbone: boolean; // Utility function noConflict(): typeof Backbone; function setDomLibrary(jQueryNew: any): any; - - var $: JQueryStatic; } declare module "backbone" { diff --git a/backgrid/backgrid-tests.ts b/backgrid/backgrid-tests.ts index 0c681a1d3..a29a4ae7e 100644 --- a/backgrid/backgrid-tests.ts +++ b/backgrid/backgrid-tests.ts @@ -23,7 +23,7 @@ class TestModel extends Backbone.Model { } -class TestCollection extends Backbone.Collection { +class TestCollection extends Backbone.Collection { constructor(models?: any, options?: any) { this.model = TestModel; @@ -41,11 +41,11 @@ class TestCollection extends Backbone.Collection { } } -class TestView extends Backbone.View { +class TestView extends Backbone.View { gridView: Backgrid.Grid; testCollection: TestCollection; - constructor(viewOptions?: Backbone.ViewOptions) { + constructor(viewOptions?: Backbone.ViewOptions) { this.testCollection = new TestCollection(); this.gridView = new Backgrid.Grid({ columns: [new Backgrid.Column({name: "FirstName", cell: "string", label: "First Name"}), diff --git a/backgrid/backgrid.d.ts b/backgrid/backgrid.d.ts index 73cb12450..fcae05d80 100644 --- a/backgrid/backgrid.d.ts +++ b/backgrid/backgrid.d.ts @@ -9,20 +9,20 @@ declare module Backgrid { interface GridOptions { columns: Column[]; - collection: Backbone.Collection; + collection: Backbone.Collection; header: Header; body: Body; row: Row; footer: Footer; } - class Header extends Backbone.View { + class Header extends Backbone.View { } - class Footer extends Backbone.View { + class Footer extends Backbone.View { } - class Row extends Backbone.View { + class Row extends Backbone.View { } class Command { @@ -50,19 +50,19 @@ declare module Backgrid { initialize(options?: any); } - class Body extends Backbone.View { + class Body extends Backbone.View { tagName: string; initialize(options?: any); - insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any); + insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any); moveToNextCell(model: Backbone.Model, cell: Column, command: Command); refresh(): Body; remove(): Body; - removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any); + removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any); render(): Body; } - class Grid extends Backbone.View { + class Grid extends Backbone.View { body: Backgrid.Body; className: string; footer: any; @@ -72,10 +72,10 @@ declare module Backgrid { initialize(options: any); getSelectedModels(): Backbone.Model[]; insertColumn(...options: any[]): Grid; - insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any); + insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any); remove():Grid; removeColumn(...options: any[]): Grid; - removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any); + removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any); render():Grid; } diff --git a/giraffe/giraffe-tests.ts b/giraffe/giraffe-tests.ts index 70365bb59..4cd6694da 100644 --- a/giraffe/giraffe-tests.ts +++ b/giraffe/giraffe-tests.ts @@ -3,13 +3,13 @@ class User extends Giraffe.Model { } -class MainView extends Giraffe.View { +class MainView extends Giraffe.View { constructor(options?) { this.appEvents = { 'startup': 'app_onStartup' - } - super(options) + } + super(options); } app_onStartup() { @@ -23,15 +23,15 @@ class MyApp extends Giraffe.App { this.routes= { '': 'home' } - super() + super(); } home() { - this.attach( new MainView ) + this.attach(new MainView); } } var app= new MyApp(); -app.start(); \ No newline at end of file +app.start(); diff --git a/giraffe/giraffe.d.ts b/giraffe/giraffe.d.ts index 24c41aa24..998754898 100644 --- a/giraffe/giraffe.d.ts +++ b/giraffe/giraffe.d.ts @@ -38,8 +38,8 @@ declare module Giraffe { interface AppMap { [ cid:string ]: App; } - interface ViewMap { - [ cid:string ]: View; + interface ViewMap { + [ cid:string ]: View; } interface StringMap { [ def:string ]: string; @@ -49,7 +49,7 @@ declare module Giraffe { var apps: AppMap; var defaultOptions: DefaultOptions; var version: string; - var views: ViewMap; + var views: ViewMap; function bindAppEvents( instance:GiraffeObject ): GiraffeObject; function bindDataEvents( instance:GiraffeObject ): GiraffeObject; @@ -64,9 +64,10 @@ declare module Giraffe { function wrapFn( obj:any, name:string, before:Function, after:Function); - class Collection extends Backbone.Collection implements GiraffeObject { + class Collection extends Backbone.Collection implements GiraffeObject { app: App; - model: Model; + //model: typeof TModel; + model: { new (): TModel; }; // workaround } class Model extends Backbone.Model implements GiraffeObject { @@ -85,46 +86,46 @@ declare module Giraffe { reload( url:string ); } - class View extends Backbone.View implements GiraffeObject { + class View extends Backbone.View implements GiraffeObject { app: App; appEvents: StringMap; - children: View[]; + children: View[]; dataEvents: StringMap; defaultOptions: DefaultOptions; documentTitle: string; - parent: View; + parent: View; template: any; ui: StringMap; - attachTo( el:any, options?:AttachmentOptions ): View; - attach( view:View, options?:AttachmentOptions ): View; + attachTo( el:any, options?:AttachmentOptions ): View; + attach( view:View, options?:AttachmentOptions ): View; isAttached( el:any ): boolean; - render( options?:any ): View; + render( options?:any ): View; beforeRender(); afterRender(); templateStrategy(): string; serialize(): any; - setParent( parent:View ): View; + setParent( parent:View ): View; - addChild( child:View ): View; - addChildren( children:View[] ): View; - removeChild( child:View, preserve?:boolean ): View; - removeChildren( preserve?:boolean ): View; + addChild( child:View ): View; + addChildren( children:View[] ): View; + removeChild( child:View, preserve?:boolean ): View; + removeChildren( preserve?:boolean ): View; - detach( preserve?:boolean ): View; - detachChildren( preserve?:boolean ): View; + detach( preserve?:boolean ): View; + detachChildren( preserve?:boolean ): View; invoke( method:string, ...args:any[] ); - dispose(): View; - beforeDispose(): View; - afterDispose(): View; + dispose(): View; + beforeDispose(): View; + afterDispose(): View; - static detachByElement( el:any, preserve?:boolean ): View; - static getClosestView( el:any ): View; - static getByCid( cid:string ): View; + static detachByElement( el:any, preserve?:boolean ): View; + static getClosestView( el:any ): View; + static getByCid( cid:string ): View; static to$El( el:any, parent?:any, allowParentMatch?:boolean ): JQuery; static setDocumentEvents( events:string[], prefix?:string ): string[]; static removeDocumentEvents( prefix?:string ); @@ -132,7 +133,7 @@ declare module Giraffe { static setTemplateStrategy( strategy:any, instance?:any ); } - class App extends View { + class App extends View { routes: StringMap; addInitializer( initializer:( options?:any, callback?:()=>void )=>void ): App; @@ -146,23 +147,23 @@ declare module Giraffe { app: App; } - class CollectionView extends View { + class CollectionView extends View { - collection: Collection; - modelView: View; + collection: Collection; + modelView: View; modelViewArgs: any[]; modelViewEl: any; renderOnChange: boolean; - findByModel( model:Model ): View; - addOne( model:Model ): View; - removeOne( model:Model ): View; + findByModel( model:Model ): View; + addOne( model:Model ): View; + removeOne( model:Model ): View; static getDefaults( ctx:any ): any; } - class FastCollectionView extends View { - collection: Collection; + class FastCollectionView extends View { + collection: Collection; modelTemplate: any; modelTemplateStrategy: string; modelEl: any; @@ -170,11 +171,11 @@ declare module Giraffe { modelSerialize(): any; - addAll(): View; - addOne( model:Model ): View; - removeOne( model:Model ): View; + addAll(): View; + addOne( model:Model ): View; + removeOne( model:Model ): View; - removeByIndex( index:number ): View; + removeByIndex( index:number ): View; findElByModel( model:Model ): JQuery; findElByIndex( index:number ): JQuery; findModelByEl( el:any ): Model; diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts index f4e0926ea..c2ff9c1c7 100644 --- a/jointjs/jointjs.d.ts +++ b/jointjs/jointjs.d.ts @@ -38,20 +38,19 @@ declare module joint { attr(attrs: any): Cell; } - - class Element extends Cell { position(x: number, y: number): Element; translate(tx: number, ty?: number): Element; resize(width: number, height: number): Element; rotate(angle: number, absolute): Element; } + interface IDefaults { type: string; } class Link extends Cell { - defaults: IDefaults; + defaults(): IDefaults; disconnect(): Link; label(idx?: number, value?: any): any; // @todo: returns either a label under idx or Link if both idx and value were passed } @@ -65,7 +64,7 @@ declare module joint { linkView: LinkView; } - class Paper extends Backbone.View { + class Paper extends Backbone.View { options: IOptions; setDimensions(width: number, height: number); scale(sx: number, sy?: number, ox?: number, oy?: number): Paper; @@ -80,7 +79,8 @@ declare module joint { class ElementView extends CellView { scale(sx: number, sy: number); } - class CellView extends Backbone.View { + + class CellView extends Backbone.View { getBBox(): { x: number; y: number; width: number; height: number; }; highlight(el?: any); unhighlight(el?: any); @@ -94,7 +94,9 @@ declare module joint { } } + module ui { } + module shapes { module basic { class Generic extends joint.dia.Element { } @@ -104,6 +106,7 @@ declare module joint { class Image extends Generic { } } } + module util { function uuid(): string; function guid(obj: any): string; @@ -112,4 +115,5 @@ declare module joint { function deepMixin(objects: any[]): any; function deepSupplement(objects: any[], defaultIndicator?: any): any; } + } diff --git a/knockback/knockback.d.ts b/knockback/knockback.d.ts index 50848e684..71773ab92 100644 --- a/knockback/knockback.d.ts +++ b/knockback/knockback.d.ts @@ -126,8 +126,8 @@ declare module Knockback { } interface CollectionObservable extends KnockoutObservableArray { - collection(colleciton: Backbone.Collection); - collection(): Backbone.Collection; + collection(colleciton: Backbone.Collection); + collection(): Backbone.Collection; destroy(); shareOptions(): CollectionOptions; filters(id: any) : Backbone.Model; @@ -163,7 +163,7 @@ declare module Knockback { } interface Static extends Utils { - collectionObservable(model?: Backbone.Collection, options?: CollectionOptions): CollectionObservable; + collectionObservable(model?: Backbone.Collection, options?: CollectionOptions): CollectionObservable; /** Base class for observing model attributes. */ observable( /** the model to observe (can be null) */ diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index 0e501f6f8..7a52d7453 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -11,49 +11,49 @@ declare module Backbone { // Backbone.BabySitter - class ChildViewContainer { + class ChildViewContainer { constructor(initialViews?: any[]); - add(view: View, customIndex?: number); - findByModel(model): View; - findByModelCid(modelCid): View; - findByCustom(index: number): View; - findByIndex(index: number): View; - findByCid(cid): View; - remove(view: View); + add(view: View, customIndex?: number); + findByModel(model): View; + findByModelCid(modelCid): View; + findByCustom(index: number): View; + findByIndex(index: number): View; + findByCid(cid): View; + remove(view: View); call(method); apply(method: any, args?: any[]); //mixins from Collection (copied from Backbone's Collection declaration) - all(iterator: (element: View, index: number) => boolean, context?: any): boolean; - any(iterator: (element: View, index: number) => boolean, context?: any): boolean; + all(iterator: (element: View, index: number) => boolean, context?: any): boolean; + any(iterator: (element: View, index: number) => boolean, context?: any): boolean; contains(value: any): boolean; detect(iterator: (item: any) => boolean, context?: any): any; - each(iterator: (element: View, index: number, list?: any) => void , context?: any); - every(iterator: (element: View, index: number) => boolean, context?: any): boolean; - filter(iterator: (element: View, index: number) => boolean, context?: any): View[]; - find(iterator: (element: View, index: number) => boolean, context?: any): View; - first(): View; - forEach(iterator: (element: View, index: number, list?: any) => void , context?: any); + each(iterator: (element: View, index: number, list?: any) => void , context?: any); + every(iterator: (element: View, index: number) => boolean, context?: any): boolean; + filter(iterator: (element: View, index: number) => boolean, context?: any): View[]; + find(iterator: (element: View, index: number) => boolean, context?: any): View; + first(): View; + forEach(iterator: (element: View, index: number, list?: any) => void , context?: any); include(value: any): boolean; - initial(): View; - initial(n: number): View[]; + initial(): View; + initial(n: number): View[]; invoke(methodName: string, arguments?: any[]); isEmpty(object: any): boolean; - last(): View; - last(n: number): View[]; - lastIndexOf(element: View, fromIndex?: number): number; - map(iterator: (element: View, index: number, context?: any) => any[], context?: any): any[]; + last(): View; + last(n: number): View[]; + lastIndexOf(element: View, fromIndex?: number): number; + map(iterator: (element: View, index: number, context?: any) => any[], context?: any): any[]; pluck(attribute: string): any[]; - reject(iterator: (element: View, index: number) => boolean, context?: any): View[]; - rest(): View; - rest(n: number): View[]; + reject(iterator: (element: View, index: number) => boolean, context?: any): View[]; + rest(): View; + rest(n: number): View[]; select(iterator: any, context?: any): any[]; - some(iterator: (element: View, index: number) => boolean, context?: any): boolean; + some(iterator: (element: View, index: number) => boolean, context?: any): boolean; toArray(): any[]; - without(...values: any[]): View[]; + without(...values: any[]): View[]; } // Backbone.Wreqr @@ -107,7 +107,7 @@ declare module Marionette { function getOption(target, optionName): any; function triggerMethod(name, ...args: any[]): any; - function MonitorDOMRefresh(view: Backbone.View): void; + function MonitorDOMRefresh(view: Backbone.View): void; function bindEntityEvents(target, entity, bindings); function unbindEntityEvents(target, entity, bindings); @@ -121,24 +121,24 @@ declare module Marionette { close(); } - class Region extends Backbone.Events { + class Region extends Backbone.Events { - static buildRegion(regionConfig, defaultRegionType): Region; + static buildRegion(regionConfig, defaultRegionType): Region; el: any; - show(view: Backbone.View): void; + show(view: Backbone.View): void; ensureEl(): void; - open(view: Backbone.View): void; + open(view: Backbone.View): void; close(): void; - attachView(view: Backbone.View); + attachView(view: Backbone.View); reset(); } - class RegionManager extends Controller { + class RegionManager extends Controller { addRegions(regionDefinitions, defaults?): any; - addRegion(name, definition): Region; - get (name: string): Region; + addRegion(name, definition): Region; + get(name: string): Region; removeRegion(name): void; removeRegions(): void; closeRegions(): void; @@ -146,33 +146,33 @@ declare module Marionette { //mixins from Collection (copied from Backbone's Collection declaration) - all(iterator: (element: Region, index: number) => boolean, context?: any): boolean; - any(iterator: (element: Region, index: number) => boolean, context?: any): boolean; + all(iterator: (element: Region, index: number) => boolean, context?: any): boolean; + any(iterator: (element: Region, index: number) => boolean, context?: any): boolean; contains(value: any): boolean; detect(iterator: (item: any) => boolean, context?: any): any; - each(iterator: (element: Region, index: number, list?: any) => void , context?: any); - every(iterator: (element: Region, index: number) => boolean, context?: any): boolean; - filter(iterator: (element: Region, index: number) => boolean, context?: any): Region[]; - find(iterator: (element: Region, index: number) => boolean, context?: any): Region; - first(): Region; - forEach(iterator: (element: Region, index: number, list?: any) => void , context?: any); + each(iterator: (element: Region, index: number, list?: any) => void , context?: any); + every(iterator: (element: Region, index: number) => boolean, context?: any): boolean; + filter(iterator: (element: Region, index: number) => boolean, context?: any): Region[]; + find(iterator: (element: Region, index: number) => boolean, context?: any): Region; + first(): Region; + forEach(iterator: (element: Region, index: number, list?: any) => void , context?: any); include(value: any): boolean; - initial(): Region; - initial(n: number): Region[]; + initial(): Region; + initial(n: number): Region[]; invoke(methodName: string, arguments?: any[]); isEmpty(object: any): boolean; - last(): Region; - last(n: number): Region[]; - lastIndexOf(element: Region, fromIndex?: number): number; - map(iterator: (element: Region, index: number, context?: any) => any[], context?: any): any[]; + last(): Region; + last(n: number): Region[]; + lastIndexOf(element: Region, fromIndex?: number): number; + map(iterator: (element: Region, index: number, context?: any) => any[], context?: any): any[]; pluck(attribute: string): any[]; - reject(iterator: (element: Region, index: number) => boolean, context?: any): Region[]; - rest(): Region; - rest(n: number): Region[]; + reject(iterator: (element: Region, index: number) => boolean, context?: any): Region[]; + rest(): Region; + rest(n: number): Region[]; select(iterator: any, context?: any): any[]; - some(iterator: (element: Region, index: number) => boolean, context?: any): boolean; + some(iterator: (element: Region, index: number) => boolean, context?: any): boolean; toArray(): any[]; - without(...values: any[]): Region[]; + without(...values: any[]): Region[]; } class TemplateCache { @@ -187,7 +187,7 @@ declare module Marionette { static render(template, data): void; } - class View extends Backbone.View { + class View extends Backbone.View { constructor(options?: any); @@ -208,72 +208,72 @@ declare module Marionette { triggerMethod(name, ...args: any[]): any; } - class ItemView extends View { + class ItemView extends View { constructor(options?: any); ui: any; serializeData(): any; - render(): ItemView; + render(): ItemView; close(); } - class CollectionView extends View { + class CollectionView extends View { constructor(options?: any); itemView: any; children: any; //_initialEvents(); - addChildView(item: View, collection: View, options?: any); + addChildView(item: View, collection: View, options?: any); onShowCalled(); triggerBeforeRender(); triggerRendered(); - render(): CollectionView; + render(): CollectionView; - getItemView(item: any): ItemView; - addItemView(item: any, ItemView: ItemView, index: Number); - addChildViewEventForwarding(view: View); - renderItemView(view: View, index: Number); + getItemView(item: any): ItemView; + addItemView(item: any, ItemView: ItemView, index: Number); + addChildViewEventForwarding(view: View); + renderItemView(view: View, index: Number); buildItemView(item: any, ItemViewType: any, itemViewOptions: any): any; removeItemView(item: any); - removeChildView(view: View); + removeChildView(view: View); checkEmpty(); - appendHtml(collectionView: View, itemView: View, index: Number); + appendHtml(collectionView: View, itemView: View, index: Number); close(); closeChildren(); } - class CompositeView extends CollectionView { + class CompositeView extends CollectionView { constructor(options?: any); itemView: any; itemViewContainer: string; - render(): CompositeView; + render(): CompositeView; appendHtml(cv: any, iv: any); renderModel(): any; } - class Layout extends ItemView { + class Layout extends ItemView { constructor(options?: any); - addRegion(name: string, definition: any): Region; + addRegion(name: string, definition: any): Region; addRegions(regions: any): any; - render(): Layout; + render(): Layout; removeRegion(name: string); } interface AppRouterOptions extends Backbone.RouterOptions { - appRoutes: any; - controller: any; + appRoutes: any; + controller: any; } class AppRouter extends Backbone.Router { @@ -284,7 +284,7 @@ declare module Marionette { } - class Application extends Backbone.Events { + class Application extends Backbone.Events { vent: Backbone.Wreqr.EventAggregator; commands: Backbone.Wreqr.Commands; @@ -297,15 +297,15 @@ declare module Marionette { start(options?); addRegions(regions); closeRegions(): void; - removeRegion(region: Region); - getRegion(regionName: string): Region; + removeRegion(region: Region); + getRegion(regionName: string): Region; module(moduleNames, moduleDefinition); } // modules mapped for convenience, but you should probably use TypeScript modules instead - class Module extends Backbone.Events { + class Module extends Backbone.Events { - constructor(moduleName: string, app: Application); + constructor(moduleName: string, app: Application); submodules: any; triggerMethod(name, ...args: any[]): any; @@ -319,7 +319,7 @@ declare module Marionette { } declare module 'backbone.marionette' { - import Backbone = require('backbone'); - - export = Marionette; + import Backbone = require('backbone'); + + export = Marionette; } From 088f8056b138e7249c3ec28b22c4ba5ae5e42e5e Mon Sep 17 00:00:00 2001 From: SkyKnight Date: Mon, 28 Apr 2014 21:22:58 +0200 Subject: [PATCH 04/16] missing optional parameter in EM.exportEntities http://www.breezejs.com/documentation/exportimport --- breeze/breeze.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index 3614e3446..4ecb9bca6 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -382,7 +382,7 @@ declare module breeze { executeQuery(query: EntityQuery, callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): Q.Promise; executeQueryLocally(query: EntityQuery): Entity[]; - exportEntities(entities?: Entity[]): string; + exportEntities(entities?: Entity[], includeMetadata?: boolean): string; fetchEntityByKey(typeName: string, keyValue: any, checkLocalCacheFirst?: boolean): Q.Promise; fetchEntityByKey(typeName: string, keyValues: any[], checkLocalCacheFirst?: boolean): Q.Promise; fetchEntityByKey(entityKey: EntityKey, checkLocalCacheFirst?: boolean): Q.Promise; From 77329c13e49aa8471fd4fb1ec11757af0115e85b Mon Sep 17 00:00:00 2001 From: SkyKnight Date: Mon, 28 Apr 2014 21:25:51 +0200 Subject: [PATCH 05/16] optional second parameter of getAdapterInstance according to description on page http://www.breezejs.com/documentation/customizing-ajax adapterName is not required --- breeze/breeze.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index 4ecb9bca6..fab5dd077 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -877,7 +877,7 @@ declare module breeze.config { var dataService: string; var functionRegistry: Object; export function getAdapter(interfaceName: string, adapterName: string): Object; - export function getAdapterInstance(interfaceName: string, adapterName: string): Object; + export function getAdapterInstance(interfaceName: string, adapterName?: string): Object; export function initializeAdapterInstance(interfaceName: string, adapterName: string, isDefault: boolean): void; export function initializeAdapterInstances(config: Object): void; var interfaceInitialized: Event; From fb6da7e0ab86520969b145c3c51a174bd59fd660 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 28 Apr 2014 22:37:39 +0200 Subject: [PATCH 06/16] external module for uuid, removed var with global interfaces for existing users --- node-uuid/node-uuid.d.ts | 13 ++++++++----- node-uuid/node-uuid.tests.ts | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/node-uuid/node-uuid.d.ts b/node-uuid/node-uuid.d.ts index 8c287bb2e..48a342204 100644 --- a/node-uuid/node-uuid.d.ts +++ b/node-uuid/node-uuid.d.ts @@ -34,16 +34,19 @@ interface UUIDOptions { interface UUID { v1(options?: UUIDOptions, buffer?: number[], offset?: number): string - v1(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + v1(options?: UUIDOptions, buffer?: Buffer, offset?: number): string v2(options?: UUIDOptions, buffer?: number[], offset?: number): string - v2(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + v2(options?: UUIDOptions, buffer?: Buffer, offset?: number): string v3(options?: UUIDOptions, buffer?: number[], offset?: number): string - v3(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + v3(options?: UUIDOptions, buffer?: Buffer, offset?: number): string v4(options?: UUIDOptions, buffer?: number[], offset?: number): string - v4(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + v4(options?: UUIDOptions, buffer?: Buffer, offset?: number): string } -declare var uuid: UUID; +declare module 'uuid' { + var uuid: UUID; + export = uuid; +} diff --git a/node-uuid/node-uuid.tests.ts b/node-uuid/node-uuid.tests.ts index 6e1d7bd8c..49c8f165a 100644 --- a/node-uuid/node-uuid.tests.ts +++ b/node-uuid/node-uuid.tests.ts @@ -1,5 +1,7 @@ /// +import uuid = require('node-uuid'); + var uid1: string = uuid.v1() var uid2: string = uuid.v2() var uid3: string = uuid.v3() From ac79fdd11b4240a36b75a378a7e7ebb5f4c5b92a Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 28 Apr 2014 23:42:21 +0200 Subject: [PATCH 07/16] added definitions for lockfile --- lockfile/lockfile-tests.ts | 31 +++++++++++++++++++++++++++++++ lockfile/lockfile.d.ts | 24 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 lockfile/lockfile-tests.ts create mode 100644 lockfile/lockfile.d.ts diff --git a/lockfile/lockfile-tests.ts b/lockfile/lockfile-tests.ts new file mode 100644 index 000000000..49aa423d9 --- /dev/null +++ b/lockfile/lockfile-tests.ts @@ -0,0 +1,31 @@ +/// + +import lockfile = require('lockfile'); + +var bool: boolean; +var num: number; +var path: string; + +var opts: lockfile.Options; +var callback: (err: Error) => { + +}; + +opts = { + wait: num, + stale: num, + retries: num, + retryWait: num +}; + +lockfile.lock(path, opts, callback); +lockfile.lock(path, callback); +lockfile.lockSync(path, opts); + +lockfile.unlock(path, callback);; +lockfile.unlockSync(path); + +lockfile.check(path, opts, callback); +lockfile.check(path, callback); + +bool = lockfile.checkSync(path, opts); diff --git a/lockfile/lockfile.d.ts b/lockfile/lockfile.d.ts new file mode 100644 index 000000000..99dfbe28d --- /dev/null +++ b/lockfile/lockfile.d.ts @@ -0,0 +1,24 @@ +// Type definitions for lockfile v0.4.2 +// Project: https://github.com/isaacs/lockfile +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'lockfile' { + export interface Options { + wait?: number; + stale?: number; + retries?: number; + retryWait?: number; + } + + export function lock(path: string, opts: Options, callback: (err: Error) => void): void; + export function lock(path: string, callback: (err: Error) => void): void; + export function lockSync(path: string, opts: Options):void; + + export function unlock(path: string, callback: (err: Error) => void): void; + export function unlockSync(path: string):void; + + export function check(path: string, opts: Options, callback: (err: Error) => void): void; + export function check(path: string, callback: (err: Error) => void): void; + export function checkSync(path: string, opts: Options): boolean; +} From 9259180be85f4e7dfdbefda8a0078502650ff927 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 28 Apr 2014 23:19:28 +0200 Subject: [PATCH 08/16] added definitions for tape --- tape/tape-tests.ts | 106 +++++++++++++++++++++++++++++ tape/tape.d.ts | 161 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 267 insertions(+) create mode 100644 tape/tape-tests.ts create mode 100644 tape/tape.d.ts diff --git a/tape/tape-tests.ts b/tape/tape-tests.ts new file mode 100644 index 000000000..2c4e4ec1b --- /dev/null +++ b/tape/tape-tests.ts @@ -0,0 +1,106 @@ +/// + +/// + +import tape = require('tape'); + +var x: any; +var value: any; +var err: any; +var a: any; +var b: any; +var err: any; +var num: number; +var name: string; +var msg: string; +var rs: NodeJS.ReadableStream; + +var cb: tape.TestCase; +var t: tape.Test; + +tape(name, cb); +tape(name, (test: tape.Test) => { + t = test; +}); + +tape.skip(name, cb); +tape.only(name, cb); + +rs = tape.createStream(); +rs = tape.createStream(x); + +var tx = tape.createHarness(); +tx(name, cb); +tape.skip(name, cb); +tape.only(name, cb); + +tape(name, (test: tape.Test) => { + + test.plan(num); + test.end(); + + test.fail(msg); + test.pass(msg); + test.skip(msg); + + test.ok(value, msg); + test.true(value, msg); + test.assert(value, msg); + + test.notOk(value, msg); + test.false(value, msg); + test.notok(value, msg); + + test.error(err, msg); + test.ifError(err, msg); + test.ifErr(err, msg); + test.iferror(err, msg); + + test.equal(a, b, msg); + test.equals(a, b, msg); + test.isEqual(a, b, msg); + test.is(a, b, msg); + test.strictEqual(a, b, msg); + test.strictEquals(a, b, msg); + + test.notEqual(a, b, msg); + test.notEquals(a, b, msg); + test.notStrictEqual(a, b, msg); + test.notStrictEquals(a, b, msg); + test.isNotEqual(a, b, msg); + test.isNot(a, b, msg); + test.not(a, b, msg); + test.doesNotEqual(a, b, msg); + test.notEqual(a, b, msg); + test.isInequal(a, b, msg); + + test.deepEqual(a, b, msg); + test.deepEquals(a, b, msg); + test.isEquivalent(a, b, msg); + test.same(a, b, msg); + + test.notDeepEqual(a, b, msg); + test.notEquivalent(a, b, msg); + test.notDeeply(a, b, msg); + test.notSame(a, b, msg); + test.isNotDeepEqual(a, b, msg); + test.isNotDeeply(a, b, msg); + test.isNotEquivalent(a, b, msg); + test.isInequivalent(a, b, msg); + + test.deepLooseEqual(a, b, msg); + test.looseEqual(a, b, msg); + test.looseEquals(a, b, msg); + + test.notDeepLooseEqual(a, b, msg); + test.notLooseEqual(a, b, msg); + test.notLooseEquals(a, b, msg); + + test.throws(() => { + + }, value, msg); + + test.doesNotThrow(() => { + + }, value, msg); +}); diff --git a/tape/tape.d.ts b/tape/tape.d.ts new file mode 100644 index 000000000..4746e148a --- /dev/null +++ b/tape/tape.d.ts @@ -0,0 +1,161 @@ +// Type definitions for tape v2.12.3 +// Project: https://github.com/substack/tape +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'tape' { + export = tape; + + /** + * Create a new test with an optional name string. cb(t) fires with the new test object t once all preceeding tests have finished. Tests execute serially. + */ + function tape(name: string, cb: tape.TestCase): void; + module tape { + + interface TestCase { + (test: Test): void; + } + + /** + * Generate a new test that will be skipped over. + */ + export function skip(name: string, cb: tape.TestCase): void; + + /** + * Like test(name, cb) except if you use .only this is the only test case that will run for the entire process, all other test cases using tape will be ignored + */ + export function only(name: string, cb: tape.TestCase): void; + + /** + * Create a new test harness instance, which is a function like test(), but with a new pending stack and test state. + */ + export function createHarness(): typeof tape; + /** + * Create a stream of output, bypassing the default output stream that writes messages to console.log(). + */ + export function createStream(opts?: any): NodeJS.ReadableStream; + + interface Test { + /** + * Create a subtest with a new test handle st from cb(st) inside the current test cb(st) will only fire when t finishes. Additional tests queued up after t will not be run until all subtests finish. + */ + test(name: string, cb: tape.TestCase): void; + + /** + * Declare that n assertions should be run. end() will be called automatically after the nth assertion. If there are any more assertions after the nth, or after end() is called, they will generate errors. + */ + plan(n: number): void; + + /** + * Declare the end of a test explicitly. + */ + end(): void; + + /** + * Generate a failing assertion with a message msg. + */ + fail(msg?: string): void; + + /** + * Generate a passing assertion with a message msg. + */ + pass(msg?: string): void; + + /** + * Generate an assertion that will be skipped over. + */ + skip(msg?: string): void; + + /** + * Assert that value is truthy with an optional description message msg. + */ + ok(value: any, msg?: string): void; + true(value: any, msg?: string): void; + assert(value: any, msg?: string): void; + + /** + * Assert that value is falsy with an optional description message msg. + */ + notOk(value: any, msg?: string): void; + false(value: any, msg?: string): void; + notok(value: any, msg?: string): void; + + /** + * Assert that err is falsy. If err is non-falsy, use its err.message as the description message. + */ + error(err: any, msg?: string): void; + ifError(err: any, msg?: string): void; + ifErr(err: any, msg?: string): void; + iferror(err: any, msg?: string): void; + + /** + * Assert that a === b with an optional description msg. + */ + equal(a: any, b: any, msg?: string): void; + equals(a: any, b: any, msg?: string): void; + isEqual(a: any, b: any, msg?: string): void; + is(a: any, b: any, msg?: string): void; + strictEqual(a: any, b: any, msg?: string): void; + strictEquals(a: any, b: any, msg?: string): void; + + /** + * Assert that a !== b with an optional description msg. + */ + notEqual(a: any, b: any, msg?: string): void; + notEquals(a: any, b: any, msg?: string): void; + notStrictEqual(a: any, b: any, msg?: string): void; + notStrictEquals(a: any, b: any, msg?: string): void; + isNotEqual(a: any, b: any, msg?: string): void; + isNot(a: any, b: any, msg?: string): void; + not(a: any, b: any, msg?: string): void; + doesNotEqual(a: any, b: any, msg?: string): void; + isInequal(a: any, b: any, msg?: string): void; + + /** + * Assert that a and b have the same structure and nested values using node's deepEqual() algorithm with strict comparisons (===) on leaf nodes and an optional description msg. + */ + deepEqual(a: any, b: any, msg?: string): void; + deepEquals(a: any, b: any, msg?: string): void; + isEquivalent(a: any, b: any, msg?: string): void; + same(a: any, b: any, msg?: string): void; + + /** + * Assert that a and b do not have the same structure and nested values using node's deepEqual() algorithm with strict comparisons (===) on leaf nodes and an optional description msg. + */ + notDeepEqual(a: any, b: any, msg?: string): void; + notEquivalent(a: any, b: any, msg?: string): void; + notDeeply(a: any, b: any, msg?: string): void; + notSame(a: any, b: any, msg?: string): void; + isNotDeepEqual(a: any, b: any, msg?: string): void; + isNotDeeply(a: any, b: any, msg?: string): void; + isNotEquivalent(a: any, b: any, msg?: string): void; + isInequivalent(a: any, b: any, msg?: string): void; + + /** + * Assert that a and b have the same structure and nested values using node's deepEqual() algorithm with loose comparisons (==) on leaf nodes and an optional description msg. + */ + deepLooseEqual(a: any, b: any, msg?: string): void; + looseEqual(a: any, b: any, msg?: string): void; + looseEquals(a: any, b: any, msg?: string): void; + + /** + * Assert that a and b do not have the same structure and nested values using node's deepEqual() algorithm with loose comparisons (==) on leaf nodes and an optional description msg. + */ + notDeepLooseEqual(a: any, b: any, msg?: string): void; + notLooseEqual(a: any, b: any, msg?: string): void; + notLooseEquals(a: any, b: any, msg?: string): void; + + /** + * Assert that the function call fn() throws an exception. + */ + throws(fn: () => void, expected: any, msg?: string): void; + + /** + * Assert that the function call fn() does not throw an exception. + */ + doesNotThrow(fn: () => void, expected: any, msg?: string): void; + } + } +} From 01b7049c180f3e283dad69ce88fba78baf67bc21 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 28 Apr 2014 23:35:04 +0200 Subject: [PATCH 09/16] added definitions for lru-cache --- lru-cache/lru-cache-tests.ts | 56 ++++++++++++++++++++++++++++++++++++ lru-cache/lru-cache.d.ts | 34 ++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 lru-cache/lru-cache-tests.ts create mode 100644 lru-cache/lru-cache.d.ts diff --git a/lru-cache/lru-cache-tests.ts b/lru-cache/lru-cache-tests.ts new file mode 100644 index 000000000..9121ca791 --- /dev/null +++ b/lru-cache/lru-cache-tests.ts @@ -0,0 +1,56 @@ +/// + +import lru = require('lru-cache'); + +var x: any; +var num: number; +var bool: boolean; +var key: string; +var strArr: string[]; + +interface Foo { + foo(): void; +} + +var foo: Foo; +var fooArr: Foo[]; + +var opts: lru.Options; +opts = { + max: num, + maxAge: num, + stale: bool +}; +var cache: lru.Cache = lru({ + max: num, + maxAge: num, + length: (value: Foo) => { + return num + }, + dispose: (key: string, value: Foo) => { + + }, + stale: bool +}); + +cache = lru(num); + +cache.set(key, foo); +foo = cache.get(key); +foo = cache.peek(key); +bool = cache.has(key); +cache.del(key); +cache.reset(); + +cache.forEach((value: Foo, key: string, cache: lru.Cache) => { + +}); +cache.forEach((value: Foo, key: string, cache: lru.Cache) => { + +}, x); +cache.forEach((value, key, cache) => { + foo = cache.peek(key); +}); + +strArr = cache.keys(); +fooArr = cache.values(); diff --git a/lru-cache/lru-cache.d.ts b/lru-cache/lru-cache.d.ts new file mode 100644 index 000000000..ae028a553 --- /dev/null +++ b/lru-cache/lru-cache.d.ts @@ -0,0 +1,34 @@ +// Type definitions for lru-cache v2.5.0 +// Project: https://github.com/isaacs/node-lru-cache +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'lru-cache' { + function LRU(opts: LRU.Options): LRU.Cache; + function LRU(max: number): LRU.Cache; + + module LRU { + interface Options { + max?: number; + maxAge?: number; + length?: (value: T) => number; + dispose?: (key: string, value: T) => void; + stale?: boolean; + } + + interface Cache { + set(key: string, value: T): void; + get(key: string): T; + peek(key: string): T; + has(key: string): boolean + del(key: string): void; + reset(): void; + forEach(iter: (value: T, key: string, cache: Cache) => void, thisp?: any): void; + + keys(): string[]; + values(): T[]; + } + } + + export = LRU; +} From d5c287f16a080bdb18a92025cc47975b41834369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?De=CC=81nes=20Harmath?= Date: Tue, 29 Apr 2014 00:03:57 +0200 Subject: [PATCH 10/16] Add type definition for Elm --- CONTRIBUTORS.md | 1 + elm/elm-tests.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ elm/elm.d.ts | 28 ++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 elm/elm-tests.ts create mode 100644 elm/elm.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a3f729ca9..74c0363b0 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -58,6 +58,7 @@ All definitions files include a header with the author and editors, so at some p * [dust](http://linkedin.github.com/dustjs) (by [Marcelo Dezem](https://github.com/mdezem)) * [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [EasyStar](http://easystarjs.com/) (by [Magnus Gustafsson](https://github.com/Borundin)) +* [Elm](http://elm-lang.org) (by [Dénes Harmath](https://github.com/thSoft)) * [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [emissary](https://github.com/atom/emissary) (by [vvakame](https://github.com/vvakame)) * [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/elm/elm-tests.ts b/elm/elm-tests.ts new file mode 100644 index 000000000..dd0c60197 --- /dev/null +++ b/elm/elm-tests.ts @@ -0,0 +1,42 @@ +/// + +// Based on https://gist.github.com/evancz/8521339 + +interface Elm { + Shanghai: ElmModule; +} + +interface ShanghaiPorts { + coordinates: PortToElm>; + incomingShip: PortToElm; + outgoingShip: PortToElm; + totalCapacity: PortFromElm; +} + +interface Ship { + name: string; + capacity: number; +} + +// initialize the Shanghai component which keeps track of +// shipping data in and out of the Port of Shanghai. +var shanghai = Elm.worker(Elm.Shanghai, { + coordinates: [0, 0], + incomingShip: { name: "", capacity: 0 }, + outgoingShip: "" +}); + +function logger(x: any) { console.log(x) } +shanghai.ports.totalCapacity.subscribe(logger); +// send some ships to the port of Shanghai +shanghai.ports.incomingShip.send({ + name: "Mary Mærsk", + capacity: 18270 +}); +shanghai.ports.incomingShip.send({ + name: "Emma Mærsk", + capacity: 15500 +}); +// have those ships leave the port of Shanghai +shanghai.ports.outgoingShip.send("Mary Mærsk"); +shanghai.ports.outgoingShip.send("Emma Mærsk"); \ No newline at end of file diff --git a/elm/elm.d.ts b/elm/elm.d.ts new file mode 100644 index 000000000..1185394be --- /dev/null +++ b/elm/elm.d.ts @@ -0,0 +1,28 @@ +// Type definitions for Elm 0.12 +// Project: http://elm-lang.org +// Definitions by: Dénes Harmath +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var Elm: Elm; + +interface Elm { + embed

(elmModule: ElmModule

, element: Node, initialValues?: Object): ElmComponent

; + fullscreen

(elmModule: ElmModule

, initialValues?: Object): ElmComponent

; + worker

(elmModule: ElmModule

, initialValues?: Object): ElmComponent

; +} + +interface ElmModule

{ +} + +interface ElmComponent

{ + ports: P; +} + +interface PortToElm { + send(value: V): void; +} + +interface PortFromElm { + subscribe(handler: (value: V) => void): void; + unsubscribe(handler: (value: V) => void): void; +} \ No newline at end of file From 47c26a46641dfd6d3c794b1e5fd3697e714ce825 Mon Sep 17 00:00:00 2001 From: Utkarsh Upadhyay Date: Tue, 29 Apr 2014 10:37:33 +0200 Subject: [PATCH 11/16] Allow setting of styles/properties via objects. Additionally: 1. Make the type for setting attributes via objects slightly stricter. 2. Add tests for style/property setting via object maps. --- d3/d3-tests.ts | 15 +++++++++++++++ d3/d3.d.ts | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index aab65c06c..5bee2b84a 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -2286,6 +2286,21 @@ function attrObjTest () { .attr({"xlink:href": function(d, i) { return d + "-" + i + ".png"; }}); } +// Test for setting styles as an object +// From https://github.com/mbostock/d3/blob/master/test/selection/style-test.js +function styleObjTest () { + d3.select('body') + .style({"background-color": "white", opacity: .42}); +} + +// Test for setting styles as an object +// From https://github.com/mbostock/d3/blob/master/test/selection/property-test.js +function propertyObjTest () { + d3.select('body') + .property({bgcolor: "purple", opacity: .41}); +} + + // Test for brushes // This triggers a bug (shown below) in the 0.9.0 compiler, but works with // 0.9.1 compiler. diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 5f68f6f36..0b049726b 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -710,7 +710,7 @@ declare module D3 { (name: string): string; (name: string, value: any): Selection; (name: string, valueFunction: (data: any, index: number) => any): Selection; - (attrValueMap : any): Selection; + (attrValueMap : Object): Selection; }; classed: { @@ -723,12 +723,14 @@ declare module D3 { (name: string): string; (name: string, value: any, priority?: string): Selection; (name: string, valueFunction: (data: any, index: number) => any, priority?: string): Selection; + (styleValueMap : Object): Selection; }; property: { (name: string): void; (name: string, value: any): Selection; (name: string, valueFunction: (data: any, index: number) => any): Selection; + (propertyValueMap : Object): Selection; }; text: { From e113f195f3b60e76b2c1079621c510fbe37e3a36 Mon Sep 17 00:00:00 2001 From: Utkarsh Upadhyay Date: Tue, 29 Apr 2014 10:38:44 +0200 Subject: [PATCH 12/16] Re-enable the test for brush() This was failing with 0.9.0. Now the test no longer crashes the compiler. --- d3/d3-tests.ts | 86 +++++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 53 deletions(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 5bee2b84a..1a1acc324 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -2302,61 +2302,41 @@ function propertyObjTest () { // Test for brushes -// This triggers a bug (shown below) in the 0.9.0 compiler, but works with -// 0.9.1 compiler. +function brushTest() { + var xScale = d3.scale.linear(), + yScale = d3.scale.linear(); -// Stack trace: -// /usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:38215 -// return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); -// ^ -// TypeError: Cannot call method 'isError' of null -// at PullTypeResolver.isAnyOrEquivalent (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:38215:76) -// at PullTypeResolver.resolveNameExpression (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:39953:39) -// at PullTypeResolver.resolveAST (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:39758:37) -// at PullTypeResolver.computeIndexExpressionSymbol (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:40933:37) -// at PullTypeResolver.resolveIndexExpression (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:40925:45) -// at PullTypeResolver.resolveAST (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:39870:33) -// at PullTypeResolver.resolveOverloads (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:42917:43) -// at PullTypeResolver.computeCallExpressionSymbol (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:41373:34) -// at PullTypeResolver.resolveCallExpression (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:41175:29) -// at PullTypeChecker.typeCheckCallExpression (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:45111:58) -// at PullTypeChecker.typeCheckAST (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:43786:33) + var xMin = 0, xMax = 1, + yMin = 0, yMax = 1; -// function brushTest() { -// var xScale = d3.scale.linear(), -// yScale = d3.scale.linear(); -// -// var xMin = 0, xMax = 1, -// yMin = 0, yMax = 1; -// -// // Setting only x scale. -// var brush1 = d3.svg.brush() -// .x(xScale) -// .on('brush', function () { -// var extent = brush1.extent(); -// xMin = Math.max(extent[0], 0); -// xMax = Math.min(extent[1], 1); -// brush1.extent([xMin, xMax]); -// }); -// -// // Setting both the x and y scale -// var brush2 = d3.svg.brush() -// .x(xScale) -// .y(yScale) -// .on('brush', function () { -// var extent = brush2.extent(); -// var xExtent = extent[0], -// yExtent = extent[1]; -// -// xMin = Math.max(xExtent[0], 0); -// xMax = Math.min(xExtent[1], 1); -// -// yMin = Math.max(yExtent[0], 0); -// yMax = Math.min(yExtent[1], 1); -// -// brush1.extent([[xMin, xMax], [yMin, yMax]]); -// }); -// } + // Setting only x scale. + var brush1 = d3.svg.brush() + .x(xScale) + .on('brush', function () { + var extent = brush1.extent(); + xMin = Math.max(extent[0], 0); + xMax = Math.min(extent[1], 1); + brush1.extent([xMin, xMax]); + }); + + // Setting both the x and y scale + var brush2 = d3.svg.brush() + .x(xScale) + .y(yScale) + .on('brush', function () { + var extent = brush2.extent(); + var xExtent = extent[0], + yExtent = extent[1]; + + xMin = Math.max(xExtent[0], 0); + xMax = Math.min(xExtent[1], 1); + + yMin = Math.max(yExtent[0], 0); + yMax = Math.min(yExtent[1], 1); + + brush1.extent([[xMin, xMax], [yMin, yMax]]); + }); +} // Tests for area From 7c8a67a4026c233af5eb8d81e38890999cd0f5ff Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 29 Apr 2014 13:48:00 +0100 Subject: [PATCH 13/16] jQuery: Add more specific val setters --- jquery/jquery.d.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 8f1bf2527..6d8551f44 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1512,7 +1512,19 @@ interface JQuery { * * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. */ - val(func: (index: number, value: any) => any): JQuery; + val(func: (index: number, value: string) => any): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: string[]) => any): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: number) => any): JQuery; /** * Get the value of style properties for the first element in the set of matched elements. From c259dba094121a389b41c573d5000dda7bdf2092 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 29 Apr 2014 13:52:47 +0100 Subject: [PATCH 14/16] jQuery: Add even more specific val setters --- jquery/jquery.d.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 6d8551f44..b378dfd0a 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1512,19 +1512,37 @@ interface JQuery { * * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. */ - val(func: (index: number, value: string) => any): JQuery; + val(func: (index: number, value: string) => string): JQuery; /** * Set the value of each element in the set of matched elements. * * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. */ - val(func: (index: number, value: string[]) => any): JQuery; + val(func: (index: number, value: string[]) => string): JQuery; /** * Set the value of each element in the set of matched elements. * * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. */ - val(func: (index: number, value: number) => any): JQuery; + val(func: (index: number, value: number) => string): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: string) => string[]): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: string[]) => string[]): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: number) => string[]): JQuery; /** * Get the value of style properties for the first element in the set of matched elements. From 7b8666ad0e9c74d2bf0b38ff47ed65cf265cd4fe Mon Sep 17 00:00:00 2001 From: nktpro Date: Tue, 29 Apr 2014 06:09:02 -0700 Subject: [PATCH 15/16] Add less.tree.Attribute typing --- less/less.d.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/less/less.d.ts b/less/less.d.ts index 1ab9293c4..1b063e39c 100644 --- a/less/less.d.ts +++ b/less/less.d.ts @@ -497,6 +497,16 @@ declare module "less" { toCSS(env?: Options): string; eval(): UnicodeDescriptor; } + + export class Attribute implements IInjectable { + constructor(value: string); + + value: string; + + toCSS(env?: Options): string; + genCSS(env?: Options, output): string; + eval(): Attribute; + } export var debugInfo: DebugInfoFunction; export function find(obj: any[], fun: Function): any; @@ -539,4 +549,4 @@ declare module "less" { export function writeError(ctx, options: { color: boolean; }): void; export var version: number[]; -} \ No newline at end of file +} From 9ca5d2fbca5a8efa1740f847c4c924cbe736b86a Mon Sep 17 00:00:00 2001 From: nktpro Date: Tue, 29 Apr 2014 06:12:02 -0700 Subject: [PATCH 16/16] Fixed optional argument --- less/less.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/less/less.d.ts b/less/less.d.ts index 1b063e39c..d5787913b 100644 --- a/less/less.d.ts +++ b/less/less.d.ts @@ -504,7 +504,7 @@ declare module "less" { value: string; toCSS(env?: Options): string; - genCSS(env?: Options, output): string; + genCSS(env: Options, output): string; eval(): Attribute; }