From e4ff04e164e36ee9a9de52268be208f4a162c36e Mon Sep 17 00:00:00 2001 From: lgrignon Date: Mon, 14 Sep 2015 10:56:09 +0200 Subject: [PATCH 01/66] added polymer ts definition --- polymer-ts/polymer-ts.d.ts | 127 +++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 polymer-ts/polymer-ts.d.ts diff --git a/polymer-ts/polymer-ts.d.ts b/polymer-ts/polymer-ts.d.ts new file mode 100644 index 0000000000..4f44de6d28 --- /dev/null +++ b/polymer-ts/polymer-ts.d.ts @@ -0,0 +1,127 @@ +declare module polymer { + class PolymerBase extends HTMLElement { + $: any; + $$: any; + root: HTMLElement; + shadyRoot: HTMLElement; + style: CSSStyleDeclaration; + customStyle: { + [property: string]: string; + }; + arrayDelete(path: string, item: string | any): any; + async(callback: Function, waitTime?: number): any; + attachedCallback(): void; + attributeFollows(name: string, toElement: HTMLElement, fromElement: HTMLElement): void; + cancelAsync(handle: number): void; + cancelDebouncer(jobName: string): void; + classFollows(name: string, toElement: HTMLElement, fromElement: HTMLElement): void; + create(tag: string, props: Object): any; + debounce(jobName: string, callback: Function, wait?: number): void; + deserialize(value: string, type: any): any; + distributeContent(): void; + domHost(): void; + elementMatches(selector: string, node: Element): any; + fire(type: string, detail?: Object, options?: FireOptions): any; + flushDebouncer(jobName: string): void; + get(path: string | Array): any; + getContentChildNodes(slctr: string): any; + getContentChildren(slctr: string): any; + getNativePrototype(tag: string): any; + getPropertyInfo(property: string): any; + importHref(href: string, onload?: Function, onerror?: Function): any; + instanceTemplate(template: any): any; + isDebouncerActive(jobName: string): any; + linkPaths(to: string, from: string): void; + listen(node: Element, eventName: string, methodName: string): void; + mixin(target: Object, source: Object): void; + notifyPath(path: string, value: any, fromAbove?: any): void; + pop(path: string): any; + push(path: string, value: any): any; + reflectPropertyToAttribute(name: string): void; + resolveUrl(url: string): any; + scopeSubtree(container: Element, shouldObserve: boolean): void; + serialize(value: string): any; + serializeValueToAttribute(value: any, attribute: string, node: Element): void; + set(path: string, value: any, root?: Object): any; + setScrollDirection(direction: string, node: HTMLElement): void; + shift(path: string, value: any): any; + splice(path: string, start: number, deleteCount: number): any; + toggleAttribute(name: string, bool: boolean, node?: HTMLElement): void; + toggleClass(name: string, bool: boolean, node?: HTMLElement): void; + transform(transform: string, node?: HTMLElement): void; + translate3d(x: any, y: any, z: any, node?: HTMLElement): void; + unlinkPaths(path: string): void; + unshift(path: string, value: any): any; + updateStyles(): void; + } + interface dom { + (node: HTMLElement): HTMLElement; + (node: polymer.Base): HTMLElement; + flush(): any; + } + interface FireOptions { + node?: HTMLElement | polymer.Base; + bubbles?: boolean; + cancelable?: boolean; + } + interface Element { + properties?: Object; + listeners?: Object; + behaviors?: Object[]; + observers?: String[]; + factoryImpl?(...args: any[]): void; + ready?(): void; + created?(): void; + attached?(): void; + detached?(): void; + attributeChanged?(attrName: string, oldVal: any, newVal: any): void; + prototype?: Object; + } + interface PolymerTSElement { + $custom_cons?: FunctionConstructor; + $custom_cons_args?: any[]; + template?: string; + style?: string; + } + interface Property { + name?: string; + type?: any; + value?: any; + reflectToAttribute?: boolean; + readonly?: boolean; + notify?: boolean; + computed?: string; + observer?: string; + } + class Base extends polymer.PolymerBase implements polymer.Element { + static create(...args: any[]): T; + static register(): void; + is: string; + } + function createEs6PolymerBase(): void; + function prepareForRegistration(elementClass: Function): polymer.Element; + function createDomModule(definition: polymer.Element): void; + function createElement(element: new (...args: any[]) => T): new (...args: any[]) => T; + function createClass(element: new (...args: any[]) => T): new (...args: any[]) => T; + function isRegistered(element: polymer.Element): boolean; +} +declare var Polymer: { + (prototype: polymer.Element): FunctionConstructor; + Class(prototype: polymer.Element): Function; + dom: polymer.dom; + appendChild(node: HTMLElement): HTMLElement; + insertBefore(node: HTMLElement, beforeNode: HTMLElement): HTMLElement; + removeChild(node: HTMLElement): HTMLElement; + updateStyles(): void; + Base: any; +}; +declare function component(tagname: string, extendsTag?: string): (target: Function) => void; +declare function extend(tagname: string): (target: Function) => void; +declare function template(templateString: string): (target: Function) => void; +declare function style(styleString: string): (target: Function) => void; +declare function hostAttributes(attributes: Object): (target: Function) => void; +declare function property(ob?: polymer.Property): (target: polymer.Element, propertyKey: string) => void; +declare function computed(ob?: polymer.Property): (target: polymer.Element, computedFuncName: string) => void; +declare function listen(eventName: string): (target: polymer.Element, propertyKey: string) => void; +declare function behavior(behaviorObject: any): any; +declare function observe(observedProps: string): (target: polymer.Element, observerFuncName: string) => void; From da0bddb559bd1dc599237a0fbc808d45bb71ad87 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:33:30 +0200 Subject: [PATCH 02/66] added backbone local storage def --- .../backbone.localStorage.d.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 backbone.localStorage/backbone.localStorage.d.ts diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts new file mode 100644 index 0000000000..b0a554828e --- /dev/null +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -0,0 +1,46 @@ + + +declare module Backbone { + interface Serializer { + serialize(item: any): any; + deserialize(data: any): any; + } + + declare class LocalStorage { + name: string; + serializer: Serializer; + records: string[]; + + constructor(name: string, serializer?: Serializer); + + save(); + + // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already + // have an id of it's own. + create(model: any): any; + + // Update a model by replacing its copy in `this.data`. + update(model: any): any; + + // Retrieve a model from `this.data` by id. + find(model: any): any; + + // Return the array of all models currently in storage. + findAll(): any; + + // Delete a model from `this.data`, returning it. + destroy(model: T): T; + + localStorage(): any; + + // Clear localStorage for specific collection. + _clear(): void; + + _storageSize(): number; + + _itemName(id): string; + }; +} + +export Store = Backbone.LocalStorage; + From ea76cec95c4f1698cda13ae5f0393eb30dcbc178 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:40:41 +0200 Subject: [PATCH 03/66] wrong version committed --- backbone.localStorage/backbone.localStorage.d.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts index b0a554828e..e0af97e1d2 100644 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -1,12 +1,11 @@ - declare module Backbone { interface Serializer { serialize(item: any): any; deserialize(data: any): any; } - declare class LocalStorage { + class LocalStorage { name: string; serializer: Serializer; records: string[]; @@ -39,8 +38,8 @@ declare module Backbone { _storageSize(): number; _itemName(id): string; - }; + } } -export Store = Backbone.LocalStorage; +import Store = Backbone.LocalStorage; From 581d094508cb40e4b571e2027142d5dd6134722e Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:44:37 +0200 Subject: [PATCH 04/66] added def typed header comments --- backbone.localStorage/backbone.localStorage.d.ts | 6 ++++++ polymer-ts/polymer-ts.d.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts index e0af97e1d2..5696fa3d9f 100644 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -1,3 +1,9 @@ +// Type definitions for backbone.localStorage 1.0.0 +// Project: https://github.com/jeromegn/Backbone.localStorage +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// declare module Backbone { interface Serializer { diff --git a/polymer-ts/polymer-ts.d.ts b/polymer-ts/polymer-ts.d.ts index 4f44de6d28..cd96dfe21a 100644 --- a/polymer-ts/polymer-ts.d.ts +++ b/polymer-ts/polymer-ts.d.ts @@ -1,3 +1,8 @@ +// Type definitions for PolymerTS 0.1.17 +// Project: https://github.com/nippur72/PolymerTS +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + declare module polymer { class PolymerBase extends HTMLElement { $: any; From 99a76bb80179d43f48d5e942257135e41ddc4781 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:46:49 +0200 Subject: [PATCH 05/66] fixed implicit any --- backbone.localStorage/backbone.localStorage.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts index 5696fa3d9f..122c475876 100644 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -18,7 +18,7 @@ declare module Backbone { constructor(name: string, serializer?: Serializer); - save(); + save(): void; // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already // have an id of it's own. @@ -43,7 +43,7 @@ declare module Backbone { _storageSize(): number; - _itemName(id): string; + _itemName(id: any): string; } } From 8088f834010654f82033838c8baabc1b35c285e9 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Sun, 20 Sep 2015 10:17:47 +0200 Subject: [PATCH 06/66] deleted for rename --- .../backbone.localStorage.d.ts | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 backbone.localStorage/backbone.localStorage.d.ts diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts deleted file mode 100644 index 122c475876..0000000000 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -// Type definitions for backbone.localStorage 1.0.0 -// Project: https://github.com/jeromegn/Backbone.localStorage -// Definitions by: Louis Grignon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module Backbone { - interface Serializer { - serialize(item: any): any; - deserialize(data: any): any; - } - - class LocalStorage { - name: string; - serializer: Serializer; - records: string[]; - - constructor(name: string, serializer?: Serializer); - - save(): void; - - // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already - // have an id of it's own. - create(model: any): any; - - // Update a model by replacing its copy in `this.data`. - update(model: any): any; - - // Retrieve a model from `this.data` by id. - find(model: any): any; - - // Return the array of all models currently in storage. - findAll(): any; - - // Delete a model from `this.data`, returning it. - destroy(model: T): T; - - localStorage(): any; - - // Clear localStorage for specific collection. - _clear(): void; - - _storageSize(): number; - - _itemName(id: any): string; - } -} - -import Store = Backbone.LocalStorage; - From 7f6349d245f67a5b56cf6c339a51bd80a293a359 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Sun, 20 Sep 2015 10:20:47 +0200 Subject: [PATCH 07/66] renamed backbone.localStorage to backbone.localstorage --- .../backbone.localstorage.d.ts | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 backbone.localstorage/backbone.localstorage.d.ts diff --git a/backbone.localstorage/backbone.localstorage.d.ts b/backbone.localstorage/backbone.localstorage.d.ts new file mode 100644 index 0000000000..122c475876 --- /dev/null +++ b/backbone.localstorage/backbone.localstorage.d.ts @@ -0,0 +1,51 @@ +// Type definitions for backbone.localStorage 1.0.0 +// Project: https://github.com/jeromegn/Backbone.localStorage +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Backbone { + interface Serializer { + serialize(item: any): any; + deserialize(data: any): any; + } + + class LocalStorage { + name: string; + serializer: Serializer; + records: string[]; + + constructor(name: string, serializer?: Serializer); + + save(): void; + + // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already + // have an id of it's own. + create(model: any): any; + + // Update a model by replacing its copy in `this.data`. + update(model: any): any; + + // Retrieve a model from `this.data` by id. + find(model: any): any; + + // Return the array of all models currently in storage. + findAll(): any; + + // Delete a model from `this.data`, returning it. + destroy(model: T): T; + + localStorage(): any; + + // Clear localStorage for specific collection. + _clear(): void; + + _storageSize(): number; + + _itemName(id: any): string; + } +} + +import Store = Backbone.LocalStorage; + From 709f97cb32513e322a3ad98b71af51a48788b3e8 Mon Sep 17 00:00:00 2001 From: Dan Marshall Date: Sat, 14 Nov 2015 12:47:05 -0800 Subject: [PATCH 08/66] update to maker.js 0.5.3 --- maker.js/makerjs-tests.ts | 10 +++ maker.js/makerjs.d.ts | 135 +++++++++++++++++++++++++++++++++++--- 2 files changed, 135 insertions(+), 10 deletions(-) diff --git a/maker.js/makerjs-tests.ts b/maker.js/makerjs-tests.ts index 59a50e4fce..ae17a8fe9b 100644 --- a/maker.js/makerjs-tests.ts +++ b/maker.js/makerjs-tests.ts @@ -40,6 +40,8 @@ function test() { function testExporter() { new makerjs.exporter.Exporter({}); makerjs.exporter.toDXF(model); + makerjs.exporter.toOpenJsCad(model); + makerjs.exporter.toSTL(model); makerjs.exporter.toSVG(model); makerjs.exporter.tryGetModelUnits(model); } @@ -66,12 +68,17 @@ function test() { function testModel(){ makerjs.model.combine(model, model, true, false, true, false); makerjs.model.convertUnits(model, makerjs.unitType.Centimeter); + makerjs.model.countChildModels(model); + makerjs.model.detachLoop(model); + makerjs.model.findLoops(model); makerjs.model.getSimilarPathId(model, 'foo'); + makerjs.model.isPathInsideModel(paths.line, model); makerjs.model.mirror(model, false, true); makerjs.model.move(makerjs.model.originate(model, [9,9]), [0,0]); makerjs.model.moveRelative(model, [1,1]); makerjs.model.originate(model); makerjs.model.rotate(makerjs.model.scale(model, 6), 45, [0,0]); + makerjs.model.scale(model, 7); makerjs.model.walkPaths(model, (modelContext: MakerJs.IModel, pathId: string, pathContext: MakerJs.IPath) => {}); } @@ -80,6 +87,7 @@ function test() { new makerjs.models.BoltCircle(7, 7, 7, 7), new makerjs.models.BoltRectangle(2, 2, 2), new makerjs.models.ConnectTheDots(true, [ [0,0], [1,1] ]), + new makerjs.models.Dome(5, 7), new makerjs.models.Oval(7, 7), new makerjs.models.OvalArc(6, 4, 2, 12), new makerjs.models.Polygon(7, 5), @@ -141,7 +149,9 @@ function test() { makerjs.point.middle(paths.line); makerjs.point.mirror(p1, true, false); makerjs.point.rotate(p1, 5, p2); + makerjs.point.rounded(p1); makerjs.point.scale(p2, 8); + makerjs.point.serialize(p1); makerjs.point.subtract(p2, p1); makerjs.point.zero(); } diff --git a/maker.js/makerjs.d.ts b/maker.js/makerjs.d.ts index 69cd3dbb7f..779af05345 100644 --- a/maker.js/makerjs.d.ts +++ b/maker.js/makerjs.d.ts @@ -247,6 +247,37 @@ declare module MakerJs { */ path2Angles?: number[]; } + /** + * Options when matching points + */ + interface IPointMatchOptions { + /** + * Optional exemplar of number of decimal places. + */ + accuracy?: number; + } + /** + * Options to pass to model.findLoops. + */ + interface IFindLoopsOptions extends IPointMatchOptions { + /** + * Flag to remove looped paths from the original model. + */ + removeFromOriginal?: boolean; + } + /** + * A path that may be indicated to "flow" in either direction between its endpoints. + */ + interface IPathDirectional extends IPath { + /** + * The endpoints of the path. + */ + endPoints: IPoint[]; + /** + * Path flows forwards or reverse. + */ + reversed?: boolean; + } /** * Path objects by id. */ @@ -302,6 +333,12 @@ declare module MakerJs { */ layer?: string; } + /** + * Callback signature for model.walkPaths(). + */ + interface IModelPathCallback { + (modelContext: IModel, pathId: string, pathContext: IPath): void; + } /** * Test to see if an object implements the required properties of a model. */ @@ -408,6 +445,7 @@ declare module MakerJs.point { * * @param a First point. * @param b Second point. + * @param accuracy Optional exemplar of number of decimal places. * @returns true if points are the same, false if they are not */ function areEqualRounded(a: IPoint, b: IPoint, accuracy?: number): boolean; @@ -456,7 +494,7 @@ declare module MakerJs.point { */ function fromPathEnds(pathContext: IPath): IPoint[]; /** - * Get the middle point of a path. Currently only supports Arc and Line paths. + * Get the middle point of a path. * * @param pathContext The path object. * @param ratio Optional ratio (between 0 and 1) of point along the path. Default is .5 for middle. @@ -472,6 +510,14 @@ declare module MakerJs.point { * @returns Mirrored point. */ function mirror(pointToMirror: IPoint, mirrorX: boolean, mirrorY: boolean): IPoint; + /** + * Round the values of a point. + * + * @param pointContext The point to serialize. + * @param accuracy Optional exemplar number of decimal places. + * @returns A new point with the values rounded. + */ + function rounded(pointContext: IPoint, accuracy?: number): IPoint; /** * Rotate a point. * @@ -489,6 +535,14 @@ declare module MakerJs.point { * @returns A new point. */ function scale(pointToScale: IPoint, scaleValue: number): IPoint; + /** + * Get a string representation of a point. + * + * @param pointContext The point to serialize. + * @param accuracy Optional exemplar of number of decimal places. + * @returns String representing the point. + */ + function serialize(pointContext: IPoint, accuracy?: number): string; /** * Subtract a point from another point, and return the result as a new point. Shortcut to Add(a, b, subtract = true). * @@ -637,6 +691,13 @@ declare module MakerJs.paths { } } declare module MakerJs.model { + /** + * Count the number of child models within a given model. + * + * @param modelContext The model containing other models. + * @returns Number of child models. + */ + function countChildModels(modelContext: IModel): number; /** * Get an unused id in the paths map with the same prefix. * @@ -702,12 +763,6 @@ declare module MakerJs.model { * @returns The scaled model (for chaining). */ function convertUnits(modeltoConvert: IModel, destUnitType: string): IModel; - /** - * Callback signature for walkPaths. - */ - interface IModelPathCallback { - (modelContext: IModel, pathId: string, pathContext: IPath): void; - } /** * Recursively walk through all paths for a given model. * @@ -717,6 +772,15 @@ declare module MakerJs.model { function walkPaths(modelContext: IModel, callback: IModelPathCallback): void; } declare module MakerJs.model { + /** + * Check to see if a path is inside of a model. + * + * @param pathContext The path to check. + * @param modelContext The model to check against. + * @param farPoint Optional point of reference which is outside the bounds of the modelContext. + * @returns Boolean true if the path is inside of the modelContext. + */ + function isPathInsideModel(pathContext: IPath, modelContext: IModel, farPoint?: IPoint): boolean; /** * Combine 2 models. The models should be originated. * @@ -726,9 +790,10 @@ declare module MakerJs.model { * @param includeAOutsideB Flag to include paths from modelA which are outside of modelB. * @param includeBInsideA Flag to include paths from modelB which are inside of modelA. * @param includeBOutsideA Flag to include paths from modelB which are outside of modelA. + * @param keepDuplicates Flag to include paths which are duplicate in both models. * @param farPoint Optional point of reference which is outside the bounds of both models. */ - function combine(modelA: IModel, modelB: IModel, includeAInsideB: boolean, includeAOutsideB: boolean, includeBInsideA: boolean, includeBOutsideA: boolean, farPoint?: IPoint): void; + function combine(modelA: IModel, modelB: IModel, includeAInsideB?: boolean, includeAOutsideB?: boolean, includeBInsideA?: boolean, includeBOutsideA?: boolean, keepDuplicates?: boolean, farPoint?: IPoint): void; } declare module MakerJs.units { /** @@ -927,7 +992,7 @@ declare module MakerJs.path { * @param line2 Second line to fillet, which will be modified to fit the fillet. * @returns Arc path object of the new fillet. */ - function dogbone(line1: IPathLine, line2: IPathLine, filletRadius: number): IPathArc; + function dogbone(line1: IPathLine, line2: IPathLine, filletRadius: number, options?: IPointMatchOptions): IPathArc; /** * Adds a round corner to the inside angle between 2 paths. The paths must meet at one point. * @@ -935,7 +1000,7 @@ declare module MakerJs.path { * @param path2 Second path to fillet, which will be modified to fit the fillet. * @returns Arc path object of the new fillet. */ - function fillet(path1: IPath, path2: IPath, filletRadius: number): IPathArc; + function fillet(path1: IPath, path2: IPath, filletRadius: number, options?: IPointMatchOptions): IPathArc; } declare module MakerJs.kit { /** @@ -998,6 +1063,22 @@ declare module MakerJs.kit { */ function getParameterValues(ctor: IKit): any[]; } +declare module MakerJs.model { + /** + * Find paths that have common endpoints and form loops. + * + * @param modelContext The model to search for loops. + * @param options Optional options object. + * @returns A new model with child models ranked according to their containment within other found loops. The paths of models will be IPathDirectionalWithPrimeContext. + */ + function findLoops(modelContext: IModel, options?: IFindLoopsOptions): IModel; + /** + * Remove all paths in a loop model from the model(s) which contained them. + * + * @param loopToDetach The model to search for loops. + */ + function detachLoop(loopToDetach: IModel): void; +} declare module MakerJs.exporter { /** * Attributes for an XML tag. @@ -1052,6 +1133,34 @@ declare module MakerJs.exporter { toString(): string; } } +declare module MakerJs.exporter { + function toOpenJsCad(modelToExport: IModel, options?: IOpenJsCadOptions): string; + function toOpenJsCad(pathsToExport: IPath[], options?: IOpenJsCadOptions): string; + function toOpenJsCad(pathToExport: IPath, options?: IOpenJsCadOptions): string; + /** + * Executes a JavaScript string with the OpenJsCad engine - converts 2D to 3D. + * + * @param modelToExport Model object to export. + * @param options Export options object. + * @param options.extrusion Height of 3D extrusion. + * @param options.resolution Size of facets. + * @returns String of STL format of 3D object. + */ + function toSTL(modelToExport: IModel, options?: IOpenJsCadOptions): string; + /** + * OpenJsCad export options. + */ + interface IOpenJsCadOptions extends IFindLoopsOptions { + /** + * Optional depth of 3D extrusion. + */ + extrusion?: number; + /** + * Optional size of curve facets. + */ + facetSize?: number; + } +} declare module MakerJs.exporter { function toSVG(modelToExport: IModel, options?: ISVGRenderOptions): string; function toSVG(pathsToExport: IPath[], options?: ISVGRenderOptions): string; @@ -1118,6 +1227,12 @@ declare module MakerJs.models { constructor(width: number, height: number, holeRadius: number); } } +declare module MakerJs.models { + class Dome implements IModel { + paths: IPathMap; + constructor(width: number, height: number, radius?: number); + } +} declare module MakerJs.models { class RoundRectangle implements IModel { paths: IPathMap; From 3a605075a65f9d994c0878ca16f0151085a9db55 Mon Sep 17 00:00:00 2001 From: Denis Sokolov Date: Mon, 30 Nov 2015 12:05:22 +0200 Subject: [PATCH 09/66] Add debounce --- debounce/debounce.d.ts | 11 +++++++++++ debounce/debounce.ts | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 debounce/debounce.d.ts create mode 100644 debounce/debounce.ts diff --git a/debounce/debounce.d.ts b/debounce/debounce.d.ts new file mode 100644 index 0000000000..7aa24601a7 --- /dev/null +++ b/debounce/debounce.d.ts @@ -0,0 +1,11 @@ +// Type definitions for compose-function +// Project: https://github.com/component/debounce +// Definitions by: Denis Sokolov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "debounce" { + // Overload on boolean constants would allow us to narrow further, + // but it is not implemented for TypeScript yet + function f(f: A, interval?: number, immediate?: boolean): A + export default f; +} diff --git a/debounce/debounce.ts b/debounce/debounce.ts new file mode 100644 index 0000000000..fb0e52b467 --- /dev/null +++ b/debounce/debounce.ts @@ -0,0 +1,14 @@ +/// + +import debounce = require("debounce"); + +const doThings = () => 1; + +debounce(function(){ doThings(); })(); + +debounce(function(){ doThings(); }, 1000)(); + +debounce(function(a: string){ doThings(); }, 1000)("foo"); + +// Immediate true should return the value +const imm1: number = (debounce((x: number) => x * 2, 100, true))(2); From a900641acedbaa2c647513f353ca5850aac33980 Mon Sep 17 00:00:00 2001 From: Kaoru Hagihara Date: Sun, 6 Dec 2015 16:55:24 +0900 Subject: [PATCH 10/66] update vue.js --- vue/vue-tests.ts | 240 ++++++++++++++++++++++++++-- vue/vue.d.ts | 406 +++++++++++++++++++++++++++++------------------ 2 files changed, 476 insertions(+), 170 deletions(-) diff --git a/vue/vue-tests.ts b/vue/vue-tests.ts index 297379bbb1..03c3e684f1 100644 --- a/vue/vue-tests.ts +++ b/vue/vue-tests.ts @@ -1,33 +1,241 @@ /// -module myapp { + +namespace TestConfig { "use strict"; + + Vue.config.debug = true; + Vue.config.delimiters = ["${", "}"]; + Vue.config.unsafeDelimiters = ['{!!', '!!}']; + Vue.config.silent = true; + Vue.config.async = false; + Vue.config.convertAllProperties = true; +} + +namespace TestGlobalAPI { + "use strict"; + + var AppConstructor = Vue.extend({}); + var extendedApp = new AppConstructor(); + Vue.nextTick(() => {}); + Vue.set({}, "key", "value"); + Vue.delete({}, "key"); + Vue.directive("directive", { + bind: function() {}, + update: function(val: any, oldVal: any) {}, + unbind: function() {}, + params: ['a'], + paramWatchers: { + a: function(val: any, oldVal: any) {} + }, + twoWay: true, + acceptStatement: true, + priority: 1, + count: 30 + }); + Vue.directive("my-directive", () => {}); + var myDirective = Vue.directive("my-directive"); + var elementDirective = Vue.elementDirective("element-directive"); + Vue.elementDirective("element-directive", elementDirective); + Vue.elementDirective("element-directive", { + bind: function() {}, + unbind: function() {} + }); + var filter = Vue.filter("filter"); + Vue.filter("filter", filter); + Vue.filter("filter", function(val: any) { + return val; + }); + Vue.filter("filter", { + read: function(val: any) {}, + write: function(val: any, oldVal: any) {} + }); + var Component = Vue.component("component"); + Vue.component("component", Component); + Vue.component("component", { + data: function() { + return { d: 0 } + }, + methods: { + action: function() {} + }, + props: ["a", "b"], + computed: { + a: function() { return this.d; }, + b: { + get: function() { return this.a; }, + set: function(val: number) { this.d = val; } + } + } + }); + var transition = Vue.transition("transition"); + Vue.transition("transition", transition); + Vue.transition("transition", { + css: false, + stagger: function(index) { + return index; + }, + beforeEnter: function(el) { + el.textContent = 'beforeEnter'; + }, + enter: function(el, done) { + el.textContent = 'enter'; + setTimeout(function() { + done(); + }, 1000); + }, + afterEnter: function(el) { + el.textContent = 'afterEnter'; + }, + enterCancelled: function(el) { + el.textContent = 'enterCancelled'; + }, + beforeLeave: function (el) { + el.textContent = 'beforeLeave'; + }, + leave: function (el, done) { + el.textContent = 'leave'; + done(); + }, + afterLeave: function (el) { + el.textContent = 'afterLeave'; + }, + leaveCancelled: function (el) { + el.textContent = 'leaveCancelled'; + } + }); + var myPartial: string = Vue.partial("my-partial", "
Hello
"); + myPartial = Vue.partial("my-partial"); + Vue.use(() => {}, {}); + Vue.use({install: () => {}, option: () => {}}); + Vue.mixin({ready() {}}); +} + +namespace TestInstanceProperty { + "use strict"; + + var vm = new Vue({el: '#app'}); + var data: any = vm.$data; + var el: HTMLElement = vm.$el; + var options: any = vm.$options; + var parent: any = vm.$parent; + var root: any = vm.$root; + var children: any[] = vm.$children; + var refs: any = vm.$refs; + var els: any = vm.$els; +} + +namespace TestInscanceMethods { + "use strict"; + + var vm = new Vue({el: '#app'}); + vm.$watch('a.b.c', function(newVal: string, oldVal: number) {}); + vm.$watch(function() {return this.a + this.b}, function(newVal: string, oldVal: string) {}); + var unwatch = vm.$watch('a', (value: any) => {}); + unwatch(); + vm.$watch('someObject', (value: any) => {}, {deep: true}); + vm.$watch('a', (value: any) => {}, {immidiate: true}); + vm.$get('a.b'); + vm.$set('a.b', 2); + vm.$delete('a'); + var s: string = vm.$eval('msg | uppercase'); + s = vm.$interpolate('{{msg}} world!'); + vm.$log(); + vm.$log('item'); + + vm + .$on('test', (msg: any) => {}) + .$once('testOnce', (msg: any) => {}) + .$off("event", () => {}) + .$emit("event", 1, 2) + .$dispatch("event", 1, 2, 3) + .$broadcast("event", 1, 2, 3, 4) + + .$appendTo(document.createElement("div"), () => {}) + .$before('#app', () => {}) + .$after(document.getElementById('app')) + .$remove(() => {}) + .$nextTick(() => {}); + + vm + .$mount('#app') + .$destroy(false); +} + +namespace TestVueUtil { + "use strict"; + + var _ = Vue.util; + var target = document.createElement('div'); + var child = document.createElement('div'); + var parent = document.createElement('div'); + var a: any[]; + var b: boolean; + var f: Function; + var n: number; + var s: string; + var o: any; + o = _.checkComponentAttr(target, {}); + _.warn('oops', new Error()); + b = _.inDoc(target); + s = _.getAttr(target, 'v-test'); + _.before(target, child); + _.after(target, child); + _.remove(target); + _.prepend(target, parent); + _.replace(child, target); + _.on(target, 'click', () => {}); + _.off(target, 'click', () => {}); + _.removeClass(target, 'header'); + _.addClass(target, 'header'); + _.nextTick(() => {}, {}); + b = _.isLiteral('123'); + s = _._toString('hi'); + var ns: number | string = _.toNumber('12'); + s = _.stripQuotes('"123"'); + s = _.camelize('abc'); + s = _.hyphenate('whatsUp'); + s = _.classify('abc'); + f = _.bind(() => {}, {}); + a = _.toAarray(document.getElementsByClassName('target')); + o = _.extend({}, {a: 1, b: 2}); + b = _.isObject({}); + b = _.isPlainObject({}); + b = _.isArray([]); + _.def({}, 'test', 123); + _.def({}, 'test2', 123, true); + f = _.debounce(() => {}, 100); + b = _.looseEqual(1, '1'); +} + +namespace TestExplicitExtend { + "use strict"; + export class Application extends Vue { + text: string; constructor() { super(); - Vue.config.debug = true; this._init({ // data is necessary to always write in init() data: { text: "hello world." - // }, - // methods : { - // action : this.action - /* same as unser */ + }, + methods: { + action: this.action } }); - this.methods = { - action: this.action - }; } action(): void { console.log("action"); + this.$on("event", (value: any) => {}).anotherAction(); + } + anotherAction(): void { + this.$emit("event"); + } + $els: { + target: HTMLDivElement; } } + + var app = new Application(); + app.$mount("#main").$destroy(); } - -var app = new myapp.Application(); -app.$mount("#main"); - -var AppConstructor = Vue.extend({}); -var extendedApp = new AppConstructor(); -app.$mount("#main"); diff --git a/vue/vue.d.ts b/vue/vue.d.ts index cb707348a9..4af732579e 100644 --- a/vue/vue.d.ts +++ b/vue/vue.d.ts @@ -1,171 +1,269 @@ -// Type definitions for vuejs 0.11.0 -// Project: https://github.com/yyx990803/vue -// Definitions by: odangosan +// Type definitions for vuejs 1.0.10 +// Project: https://github.com/vuejs/vue +// Definitions by: odangosan , kaorun343 // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module vuejs { - export class Vue { - /** - * The Vue Constructor - * http://vuejs.org/api/index.html - */ - constructor(options?: {}); +interface Array { + $remove(item: T): Array; + $set(index: number, val: T): T; +} - /** - * Options - * http://vuejs.org/api/options.html - */ - /** - * Data - * http://vuejs.org/api/options.html#Data - */ - data: {}; - methods: {}; - computed: {}; - paramAttributes:{}[]; - /** - * DOM - * http://vuejs.org/api/options.html#DOM - */ - el: {}; - template: string; - replace: boolean; - /** - * Lifecycle - * http://vuejs.org/api/options.html#Lifecycle - */ - created: VueCallback; - beforeCompile: VueCallback; - compiled: VueCallback; - ready: VueCallback; - attached: VueCallback; - detached: VueCallback; - beforeDestroy: VueCallback; - destroyed: VueCallback; - /** - * Assets - * http://vuejs.org/api/options.html#Assets - */ - directives: {}; - filters: {}; - components: {}; - partials: {}; - transitions: {}; - /** - * Others - * http://vuejs.org/api/options.html#Others - */ - inherit: boolean; - events: {}; - watch: {}; - mixins:{}[]; - name: string; - /** - * Instance Properties - * http://vuejs.org/api/instance-properties.html - */ - $el: HTMLElement; - $data: any; - $options: any; - $parent: Vue; - $root: Vue; - $: {}; - $$: {}; - - /** - * Instance Methods - * http://vuejs.org/api/instance-methods.html - */ - /** - * Data - */ - $watch(expression: string, callback: ValueCallback, deep?: boolean, immediate?: boolean): void; - $get(expression: string): any; - $set(keypath: string, value: any): void; - $add(keypath: string, value: any): void; - $delete(keypath: string): void; - $eval(expression: string): any; - $interpolate(templateString: string): string; - $log(keypath?: string): void; - - /** - * Events - */ - $dispatch(event: string, ...args: any[]): Vue; - $broadcast(event: string, ...args: any[]): Vue; - $emit(event: string, ...args: any[]): Vue; - $on(event: string, callback: Function): Vue; - $once(event: string, callback: Function): Vue; - $off(event?: string, callback?: Function): Vue; - - /** - * DOM - */ - $appendTo(element: any, callback?: Function): Vue;// element or selector - $prependTo(element: any, callback?: Function): Vue;// element or selector - $before(element: any, callback?: Function): Vue;// element or selector - $after(element: any, callback?: Function): Vue;// element or selector - $remove(callback?: Function): Vue; - - /** - * Lifecycle - */ - $mount(element?: any): Vue;// element or selector - $destroy(remove?: boolean): void; - $compile(element: HTMLElement): VueCallback;// returns a decompile function - $addChild(options?: {}, constructor?: Function): Vue; - - /** - * Global Api - * http://vuejs.org/api/global-api.html - */ - static config: VueConfig; - static extend(options: {}): typeof Vue; - static directive(id: string, definition?: {}): void; - static directive(id: string, definition?: VueCallback): void; - static filter(id: string, definition?: FilterCallback): void; - static component(id: string, definition: Vue): void; - static component(id: string, definition?: {}): void; - static transition(id: string, definition?: {}): void; - static partial(id: string, definition?: string): void; - static partial(id: string, definition?: HTMLElement): void; - static nextTick(callback: VueCallback): void; - static require(module: string): void; - static use(plugin: {}, ...args: any[]): Vue; - static use(plugin: VueCallback, ...args: any[]): Vue; - - /** - * exports members. - */ - _init(options: {}): void; - _cleanup(): void; - // static require(module:string) : void; +declare namespace vuejs { + + interface PropOption { + type?: any; + required?: boolean; + default?: boolean; + twoWay?: boolean; + validator?(value: any): boolean; + } + + interface ComputedOption { + get(): any; + set(value: any): void; + } + + interface WatchOption { + handler(val: any, oldVal: any): void; + deep?: boolean; + immidiate?: boolean; + } + + interface DirectiveOption { + bind?(): any; + update?(newVal?: any, oldVal?: any): any; + unbind?(): any; + params?: string[]; + deep?: boolean; + twoWay?: boolean; + acceptStatement?: boolean; + priority?: number; + [key: string]: any; + } + + interface FilterOption { + read: Function; + write: Function; + } + + interface TransitionOption { + css?: boolean; + beforeEnter?(el: HTMLElement): void; + enter?(el: HTMLElement, done?: () => void): void; + afterEnter?(el: HTMLElement): void; + enterCancelled?(el: HTMLElement): void; + beforeLeave?(el: HTMLElement): void; + leave?(el: HTMLElement, done?: () => void): void; + afterLeave?(el: HTMLElement): void; + leaveCancelled?(el: HTMLElement): void; + stagger?(index: number): number; + } + + interface ComponentOption { + data?: {[key: string]: any } | Function; + props?: string[] | { [key: string]: PropOption }; + computed?: { [key: string]: ( Function | ComputedOption ) }; + methods?: { [key: string]: Function }; + watch?: { [key: string]: ( (val: any, oldVal: any) => void | string | WatchOption )}; + el?: string | HTMLElement | ( () => HTMLElement ); + template?: string; + replace?: boolean; + created?(): void; + beforeCompile?(): void; + compiled?(): void; + ready?(): void; + attached?(): void; + detached?(): void; + beforeDestroy?(): void; + destroyed?(): void; + directives?: { [key: string]: ( DirectiveOption | Function ) }; + elementDirectives?: { [key: string]: ( DirectiveOption | Function ) }; + filters?: { [key: string]: ( Function | FilterOption ) }; + components?: { [key: string]: ComponentOption }; + transitions?: { [key: string]: TransitionOption }; + partials?: { [key: string]: string }; + parent?: Vue; + events?: { [key: string]: ( (...args: any[]) => (boolean | void) ) | string }; + mixins?: ComponentOption[]; + name?: string; + [key: string]: any; } - class VueConfig { - prefix: string; + // instance/api/data.js + interface $get { ( exp: string, asStatement?: boolean ): any; } + interface $set { ( key: string | number, value: any ): void; } + interface $delete { ( key: string) : void; } + interface $watch { ( expOrFn: string | Function, callback: ( (newVal: any, oldVal?: any) => any ) | string, options?: { deep?: boolean, immidiate?: boolean } ): Function; } + interface $eval { ( expression: string ): string; } + interface $interpolate { ( expression: string ): string; } + interface $log { ( keypath?: string ): void; } + // instance/api/dom.js + interface $nextTick { ( callback: Function ): void; } + interface $appendTo { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } + interface $prependTo { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } + interface $before { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } + interface $after { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } + interface $remove { ( callback?: Function ): V; } + // instance/api/events.js + interface $on { (event: string, callback: Function): V; } + interface $once { (event: string, callback: Function): V; } + interface $off { (event?: string, callback?: Function): V; } + interface $emit { (event: string, ...args: any[]): V; } + interface $broadcast { (event: string, ...args: any[]): V; } + interface $dispatch { (event: string, ...args: any[]): V; } + // instance/api/lifecycle.js + interface $mount { ( elementOrSelector?: ( HTMLElement | string ) ): V; } + interface $destroy { (remove?: boolean): void; } + interface $compile { (el: Element | DocumentFragment, host?: Vue): Function; } + + interface Vue { + $data?: any; + $el?: HTMLElement; + $options?: Object; + $parent?: Vue; + $root?: Vue; + $children?: Vue[]; + $refs?: Object; + $els?: Object; + + $get?: $get; + $set?: $set; + $delete?: $delete; + $eval?: $eval; + $interpolate?: $interpolate; + $log?: $log; + $watch?: $watch; + $on?: $on; + $once?: $once; + $off?: $off; + $emit?: $emit; + $dispatch?: $dispatch; + $broadcast?: $broadcast; + $appendTo?: $appendTo; + $before?: $before; + $after?: $after; + $remove?: $remove; + $nextTick?: $nextTick; + $mount?: $mount; + $destroy?: $destroy; + $compile?: $compile; + + _init?(options?: ComponentOption): void; + } + + interface VueConfig { debug: boolean; + delimiters: [string, string]; + unsafeDelimiters: [string, string]; silent: boolean; - proto: boolean; - interpolate: boolean; async: boolean; - delimiters: string[]; + convertAllProperties: boolean; } - interface ValueCallback { - (newValue: {}, oldValue: {}): void; + interface VueUtil { + // util/lang.js + set(obj: Object, key: string, value: any): void; + del(obj: Object, key: string): void; + hasOwn(obj: Object, key: string): boolean; + isLiteral(exp: string): boolean; + isReserved(str: string): boolean; + _toString(value: any): string; + toNumber(value: T): T | number; + toBoolean(value: T): T | boolean; + stripQuotes(str: string): string; + camelize(str: string): string; + hyphenate(str: string): string; + classify(str: string): string; + bind(fn: Function, ctx: Object): Function; + toAarray(list: ArrayLike, start?: number): Array; + extend(to: T, from: F): ( T & F ); + isObject(obj: any): boolean; + isPlainObject(obj: any): boolean; + isArray: typeof Array.isArray; + def(obj: Object, key: string, value: any, enumerable?: boolean): void; + debounce(func: Function, wait: number): Function; + indexOf(arr: Array, obj: T): number; + cancellable(fn: Function): Function; + looseEqual(a: any, b: any): boolean; + // util/env.js + hasProto: boolean; + inBrowser: boolean; + isIE9: boolean; + isAndroid: boolean; + transitionProp: string; + transitionEndEvent: string; + animationProp: string; + animationEndEvent: string; + nextTick(cb: Function, ctx?: Object): void; + // util/dom.js + query(el: string | Element): Element; + inDoc(node: Node): boolean; + getAttr(node: Node, _attr: string): string; + getBindAttr(node: Node, name: string): string; + before(el: Element, target: Element): void; + after(el: Element, target: Element): void; + remove(el: Element): void; + prepend(el: Element, target: Element): void; + replace(target: Element, el: Element): void; + on(el: Element, event: string, cb: Function): void; + off(el: Element, event: string, cb: Function): void; + addClass(el: Element, cls: string): void; + removeClass(el: Element, cls: string): void; + extractContent(el: Element, asFragment: boolean): ( HTMLDivElement | DocumentFragment ); + trimNode(node: Node): void; + isTemplate(el: Element): boolean; + createAnchor(content: string, persist: boolean): ( Comment | Text ); + findRef(node: Element): string; + mapNodeRange(node: Node, end: Node, op: Function): void; + removeNodeRange(start: Node, end: Node, vm: any, frag: DocumentFragment, cb: Function): void; + // util/options.js + mergeOptions(parent: P, child: C, vm?: any): ( P & C ); + resolveAsset(options: Object, type: string, id: string): ( Object | Function ); + assertAsset(val: any, type: string, id: string): void; + // util/component.js + commonTagRE: RegExp; + checkComponentAttr(el: Element, options?: Object): Object; + initProp(vm: Vue, prop: Object, value: any): void; + assertProp(prop: Object, value: any): boolean; + // util/debug.js + warn(msg: string, e?: Error): void; + // observer/index.js + defineReactive(obj: Object, key: string, val: any): void; } - interface VueCallback { - (): void; - } - interface FilterCallback { - (value:{},begin?:{},end?:{}): {}; + // instance/api/global.js + interface VueStatic { + new(options?: any): Vue; + prototype: Vue; + util: VueUtil; + config: VueConfig; + set(object: Object, key: string, value: any): void; + delete(object: Object, key: string): void; + nextTick(callback: Function): any; + + cid: number; + + extend(options?: ComponentOption): VueStatic; + use(callback: Function | {install: Function, [key: string]: any}, option?: Object): VueStatic; + mixin(mixin: Object): void; + + directive(id: string, definition: T): T; + directive(id: string): any; + elementDirective(id: string, definition: T): T; + elementDirective(id: string): any; + filter(id: string, definition: T): T; + filter(id: string): any; + component(id: string, definition: ComponentOption): any; + component(id: string): any; + transition(id: string, hooks: T): T; + transition(id: string): TransitionOption; + partial(id: string, partial: string): string; + partial(id: string): string; } } -import Vue = vuejs.Vue; + +declare var Vue: vuejs.VueStatic; declare module "vue" { - import vue = vuejs.Vue; - export = vue; + export default Vue; } From b2ee74c4c726246604c9e6dd8f8f5cab98b03eda Mon Sep 17 00:00:00 2001 From: Andrzej Gis Date: Mon, 7 Dec 2015 18:22:45 +0100 Subject: [PATCH 11/66] Add L.Map.eachLayer method typing --- leaflet/leaflet-tests.ts | 3 ++- leaflet/leaflet.d.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 0ea66d32e0..2a7e418f71 100755 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -131,6 +131,7 @@ var layer = L.tileLayer("http://{s}.example.net/{x}/{y}/{z}.png"); map.addLayer(layer); map.addLayer(layer, false); +map.eachLayer(l => {}); map.removeLayer(layer); map.hasLayer(layer); @@ -423,4 +424,4 @@ var zoomCtrl = L.control.zoom({ position: "topleft", zoomInText: '+', zoomOutText: '-' -}); +}); \ No newline at end of file diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 565a3c25de..94e6ab51c3 100755 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -516,7 +516,7 @@ declare module L { function (options?: ControlOptions): Control; } - namespace control { + export namespace control { /** * Creates a zoom control. @@ -2441,6 +2441,12 @@ declare namespace L { */ options: Map.MapOptions; + /** + * Iterates over the layers of the map, optionally specifying context + * of the iterator function. + */ + eachLayer(fn: (layer: ILayer) => void, context?: any): Map; + //////////////// //////////////// addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Map; @@ -3261,7 +3267,7 @@ declare namespace L { off(eventMap?: any, context?: any): Path; } - namespace Path { + export namespace Path { /** * True if SVG is used for vector rendering (true for most modern browsers). */ From be0eda50824f411753ec1364d341e5305000b4ab Mon Sep 17 00:00:00 2001 From: lgrignon Date: Tue, 8 Dec 2015 10:59:11 +0100 Subject: [PATCH 12/66] gulp jshint + gulp notify + typescript require --- gulp-jshint/gulp-jshint-tests.ts | 16 +++ gulp-jshint/gulp-jshint.d.ts | 29 +++++ gulp-notify/gulp-notify-tests.ts | 41 +++++++ gulp-notify/gulp-notify.d.ts | 113 ++++++++++++++++++ .../typescript-require-tests.ts | 7 ++ typescript-require/typescript-require.d.ts | 31 +++++ 6 files changed, 237 insertions(+) create mode 100644 gulp-jshint/gulp-jshint-tests.ts create mode 100644 gulp-jshint/gulp-jshint.d.ts create mode 100644 gulp-notify/gulp-notify-tests.ts create mode 100644 gulp-notify/gulp-notify.d.ts create mode 100644 typescript-require/typescript-require-tests.ts create mode 100644 typescript-require/typescript-require.d.ts diff --git a/gulp-jshint/gulp-jshint-tests.ts b/gulp-jshint/gulp-jshint-tests.ts new file mode 100644 index 0000000000..fe4d930418 --- /dev/null +++ b/gulp-jshint/gulp-jshint-tests.ts @@ -0,0 +1,16 @@ +/// +/// +import gulp = require("gulp"); +import jshint = require("gulp-jshint"); + + +gulp.task('check1', function() { + gulp.src('lib/*.ts') + .pipe(jshint()) + .pipe(jshint.reporter('default')); +}); + +gulp.task('check2', function() { + gulp.src('lib/*.ts') + .pipe(jshint({ linter: 'jshint', lookup: true })); +}); \ No newline at end of file diff --git a/gulp-jshint/gulp-jshint.d.ts b/gulp-jshint/gulp-jshint.d.ts new file mode 100644 index 0000000000..5e57694e48 --- /dev/null +++ b/gulp-jshint/gulp-jshint.d.ts @@ -0,0 +1,29 @@ +// Type definitions for gulp-jshint +// Project: https://github.com/spalger/gulp-jshint +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-jshint" { + function GulpJSHint(options?: IGulpJSHintOptions): NodeJS.ReadWriteStream; + + interface IGulpJSHintOptions { + /** + * When false do not lookup .jshintrc files. See the JSHint docs for more info. + * Default true. + */ + lookup?: boolean; + + /** + * Either the name of a module to use for linting the code or a linting function itself. This enables using an alternate (but jshint compatible) linter like "jsxhint". + * Default is "jshint" + */ + linter?: string; + } + + namespace GulpJSHint { + declare function reporter(kind: (string | Object)); + } + export = GulpJSHint; +} diff --git a/gulp-notify/gulp-notify-tests.ts b/gulp-notify/gulp-notify-tests.ts new file mode 100644 index 0000000000..0c434b4321 --- /dev/null +++ b/gulp-notify/gulp-notify-tests.ts @@ -0,0 +1,41 @@ +/// +/// +import gulp = require("gulp"); +import notify = require("gulp-notify"); + +var custom = notify.withReporter(function(options, callback) { + console.log("Title:", options.title); + console.log("Message:", options.message); + callback(); +}); + +notify.on('click', (options) => { + console.log('I clicked something!', options); +}); + +notify.on('timeout', (options) => { + console.log('The notification timed out', options); +}); + +gulp.task('notify1', function() { + gulp.src("./src/test.ext") + .pipe(notify("Hello Gulp! From file: <%= file.relative %>")); +}); + +gulp.task('notify2', function() { + gulp.src("./src/test.ext") + .pipe(notify({ + message: "Generated file: <%= file.relative %> @ <%= options.date %>", + templateOptions: { + date: new Date() + } + })); +}); + +gulp.task('notify3', function() { + gulp.src("./src/test.ext") + .pipe(custom("This is a message.")) + .on("error", notify.onError((error: Error) => { + return "Message to the notifier: " + error.message; + }); +}); \ No newline at end of file diff --git a/gulp-notify/gulp-notify.d.ts b/gulp-notify/gulp-notify.d.ts new file mode 100644 index 0000000000..a1e00514fa --- /dev/null +++ b/gulp-notify/gulp-notify.d.ts @@ -0,0 +1,113 @@ +// Type definitions for gulp-jshint +// Project: https://github.com/mikaelbr/gulp-notify +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-notify" { + function GulpNotify(param: string | Function | GulpNotifyOptions): NodeJS.ReadWriteStream; + + interface GulpNotifyOptions { + /** + * Type: Boolean Default: false + * If the notification should only happen on the last file of the stream. Per default a notification is triggered on each file. + */ + onLast?: boolean; + + /** + * Type: Boolean Default: false + * If the returned stream should emit an error or not. If emitError is true, you have to handle .on('error') manually in case the notifier (gulp-notify) fails. If the default false is set, the error will not be emitted but simply printed to the console. + * This means you can run the notifier on a CI system without opting it out but simply letting it fail gracefully. + */ + emitError?: boolean; + + /** + * Type: String Default: File path in stream + * + * The message you wish to attach to file. The string can be a lodash template as it is passed through gulp-util.template. + * + * Example: Created <%= file.relative %>. + * as function + * + * Type: Function(vinylFile) + * + * See notify(Function). + */ + message?: string | Function; + + /** + * Type: String Default: "Gulp Notification" + * + * The title of the notification. The string can be a lodash template as it is passed through gulp-util.template. + * + * Example: Created <%= file.relative %>. + * as function + * + * Type: Function(vinylFile) + * + * See notify(Function). + */ + title?: string | Function; + + /** + * Object passed to the lodash template, for additional properties passed to the template. + */ + templateOptions?: Object; + + /** + * Type: Function(options, callback) Default: node-notifier module + * + * Swap out the notifier by passing in an function. The function expects two arguments: options and callback. + * + * The callback must be called when the notification is finished. Options will contain both title and message. + * + * See notify.withReporter for syntactic sugar. + */ + notifier?: (options, callback) => void; + + /** + * If the wait option is set to true, the notifier will tigger events click or timeout, whether the user clicks the notification or it times out. You listen to these events on the main notify object, not the produces stream. + */ + wait?: boolean; + } + + namespace GulpNotify { + + /** + * If the wait option is set to true, the notifier will tigger events click or timeout, whether the user clicks the notification or it times out. You listen to these events on the main notify object, not the produces stream. + */ + function on(event: string, callback: (notificationOptions?: Object) => void): void; + + /** + * Wraps options.notifier to return a new notify-function only using the passed in reporter. + */ + function withReporter(reporter: (options: GulpNotifyOptions, callback: () => void) => void): (message: string | Function) => NodeJS.ReadWriteStream; + + + /** + * The exact same API as using notify(), but where a vinyl File is passed, the error object is passed instead. + */ + function onError(callback: (string | (error: Error) => string | GulpNotifyOptions)): NodeJS.ReadWriteStream; + + /** + * Type: Integer Default: 2 + * + * Set if logger should be used or not. If log level is set to 0, no logging will be used. If no new log level is passed, the current log level is returned. + * + * 0: No logging + * 1: Log on error + * 2: Log both on error and regular notification. + * + * If logging is set to > 0, the title and message passed to gulp-notify will be logged like so: + * ➜ gulp-notify git:(master) ✗ gulp --gulpfile examples/gulpfile.js one + * [gulp] Using file /Users/example/gulp-notify/examples/gulpfile.js + * [gulp] Working directory changed to /Users/example/repos/gulp-notify/examples + * [gulp] Running 'one'... + * [gulp] Finished 'one' in 4.08 ms + * [gulp] gulp-notify: [Gulp notification] /Users/example/gulp-notify/test/fixtures/1.txt + */ + function logLevel(level: number): void; + } + export = GulpNotify; +} diff --git a/typescript-require/typescript-require-tests.ts b/typescript-require/typescript-require-tests.ts new file mode 100644 index 0000000000..6269a4b9d3 --- /dev/null +++ b/typescript-require/typescript-require-tests.ts @@ -0,0 +1,7 @@ +/// + +require('typescript-require')({ + nodeLib: false, + targetES5: true, + exitOnError: true +}); diff --git a/typescript-require/typescript-require.d.ts b/typescript-require/typescript-require.d.ts new file mode 100644 index 0000000000..68b24ca274 --- /dev/null +++ b/typescript-require/typescript-require.d.ts @@ -0,0 +1,31 @@ +// Type definitions for typescript-require +// Project: https://github.com/theblacksmith/typescript-require +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "typescript-require" { + function TypeScriptRequire(options?: TypeScriptRequireOptions): void; + + interface TypeScriptRequireOptions { + /** + * If true node.d.ts definitions file is loaded before custom ts files. This is disabled by default and you should use. + * Default false. + */ + nodeLib?: boolean; + + /** + * Target ES5 / ES3 output mode. + * Default true. + */ + targetES5?: boolean; + + /** + * Wether execution should stop on compile error. + */ + exitOnError?: boolean; + } + + export = TypeScriptRequire; +} From 29c447bbed3d657a09b2309098362460e5e681fc Mon Sep 17 00:00:00 2001 From: lgrignon Date: Tue, 8 Dec 2015 11:07:52 +0100 Subject: [PATCH 13/66] fixed syntax --- gulp-notify/gulp-notify.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulp-notify/gulp-notify.d.ts b/gulp-notify/gulp-notify.d.ts index a1e00514fa..34b752065d 100644 --- a/gulp-notify/gulp-notify.d.ts +++ b/gulp-notify/gulp-notify.d.ts @@ -88,7 +88,7 @@ declare module "gulp-notify" { /** * The exact same API as using notify(), but where a vinyl File is passed, the error object is passed instead. */ - function onError(callback: (string | (error: Error) => string | GulpNotifyOptions)): NodeJS.ReadWriteStream; + function onError(param: string | (error: Error): string | GulpNotifyOptions): NodeJS.ReadWriteStream; /** * Type: Integer Default: 2 From 737e8319a93d28f0fe903b9200d67394c593cb81 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Tue, 8 Dec 2015 11:08:46 +0100 Subject: [PATCH 14/66] fixed declare --- gulp-jshint/gulp-jshint.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulp-jshint/gulp-jshint.d.ts b/gulp-jshint/gulp-jshint.d.ts index 5e57694e48..8c10fe0de8 100644 --- a/gulp-jshint/gulp-jshint.d.ts +++ b/gulp-jshint/gulp-jshint.d.ts @@ -23,7 +23,7 @@ declare module "gulp-jshint" { } namespace GulpJSHint { - declare function reporter(kind: (string | Object)); + function reporter(kind: (string | Object)); } export = GulpJSHint; } From 0aa8a6c9f51f8c736f44dfcc2413e57356c7cd68 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Tue, 8 Dec 2015 11:09:01 +0100 Subject: [PATCH 15/66] fixed test syntax --- gulp-notify/gulp-notify-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulp-notify/gulp-notify-tests.ts b/gulp-notify/gulp-notify-tests.ts index 0c434b4321..4175d08628 100644 --- a/gulp-notify/gulp-notify-tests.ts +++ b/gulp-notify/gulp-notify-tests.ts @@ -37,5 +37,5 @@ gulp.task('notify3', function() { .pipe(custom("This is a message.")) .on("error", notify.onError((error: Error) => { return "Message to the notifier: " + error.message; - }); + })); }); \ No newline at end of file From 709cf2cb918b1fff49bcbfa041f48fefa5462786 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Tue, 8 Dec 2015 11:16:17 +0100 Subject: [PATCH 16/66] fixed syntax and implicit any --- gulp-jshint/gulp-jshint.d.ts | 2 +- gulp-notify/gulp-notify.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gulp-jshint/gulp-jshint.d.ts b/gulp-jshint/gulp-jshint.d.ts index 8c10fe0de8..20db40a62a 100644 --- a/gulp-jshint/gulp-jshint.d.ts +++ b/gulp-jshint/gulp-jshint.d.ts @@ -23,7 +23,7 @@ declare module "gulp-jshint" { } namespace GulpJSHint { - function reporter(kind: (string | Object)); + function reporter(kind: (string | Object)): NodeJS.ReadWriteStream; } export = GulpJSHint; } diff --git a/gulp-notify/gulp-notify.d.ts b/gulp-notify/gulp-notify.d.ts index 34b752065d..96b11f95d1 100644 --- a/gulp-notify/gulp-notify.d.ts +++ b/gulp-notify/gulp-notify.d.ts @@ -88,7 +88,7 @@ declare module "gulp-notify" { /** * The exact same API as using notify(), but where a vinyl File is passed, the error object is passed instead. */ - function onError(param: string | (error: Error): string | GulpNotifyOptions): NodeJS.ReadWriteStream; + function onError(param: string | { (error: Error): string } | GulpNotifyOptions): NodeJS.ReadWriteStream; /** * Type: Integer Default: 2 From dc05db5550ce7bd5156db2b6f228ad17185f3740 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Tue, 8 Dec 2015 11:20:52 +0100 Subject: [PATCH 17/66] fixed implicit any --- gulp-notify/gulp-notify.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gulp-notify/gulp-notify.d.ts b/gulp-notify/gulp-notify.d.ts index 96b11f95d1..4658616447 100644 --- a/gulp-notify/gulp-notify.d.ts +++ b/gulp-notify/gulp-notify.d.ts @@ -64,7 +64,7 @@ declare module "gulp-notify" { * * See notify.withReporter for syntactic sugar. */ - notifier?: (options, callback) => void; + notifier?: (options: GulpNotifyOptions, callback: () => void) => void; /** * If the wait option is set to true, the notifier will tigger events click or timeout, whether the user clicks the notification or it times out. You listen to these events on the main notify object, not the produces stream. @@ -77,7 +77,7 @@ declare module "gulp-notify" { /** * If the wait option is set to true, the notifier will tigger events click or timeout, whether the user clicks the notification or it times out. You listen to these events on the main notify object, not the produces stream. */ - function on(event: string, callback: (notificationOptions?: Object) => void): void; + function on(event: string, callback: (notificationOptions?: GulpNotifyOptions) => void): void; /** * Wraps options.notifier to return a new notify-function only using the passed in reporter. @@ -88,7 +88,7 @@ declare module "gulp-notify" { /** * The exact same API as using notify(), but where a vinyl File is passed, the error object is passed instead. */ - function onError(param: string | { (error: Error): string } | GulpNotifyOptions): NodeJS.ReadWriteStream; + function onError(param: string | { (error: Error): string } | GulpNotifyOptions): Function; /** * Type: Integer Default: 2 From 82764e58b49c370eff7127ae961750ed9f9921ac Mon Sep 17 00:00:00 2001 From: lgrignon Date: Tue, 8 Dec 2015 20:18:08 +0100 Subject: [PATCH 18/66] jade definition --- gulp-jade/gulp-jade-tests.ts | 25 +++++++++++++++++++++++++ gulp-jade/gulp-jade.d.ts | 24 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 gulp-jade/gulp-jade-tests.ts create mode 100644 gulp-jade/gulp-jade.d.ts diff --git a/gulp-jade/gulp-jade-tests.ts b/gulp-jade/gulp-jade-tests.ts new file mode 100644 index 0000000000..7334afc838 --- /dev/null +++ b/gulp-jade/gulp-jade-tests.ts @@ -0,0 +1,25 @@ +/// +/// +/// + +import gulp = require("gulp"); +import jade = require("gulp-jade"); + + +gulp.task('check1', function() { + gulp.src('lib/*.jade') + .pipe(jade({ + locals: {}, + client: false + })); +}); + +import jadeLib = require('jade'); + +gulp.task('check2', function() { + gulp.src('lib/*.jade') + .pipe(jade({ + jade: jadeLib, + pretty: true + })); +}); \ No newline at end of file diff --git a/gulp-jade/gulp-jade.d.ts b/gulp-jade/gulp-jade.d.ts new file mode 100644 index 0000000000..2f31889c22 --- /dev/null +++ b/gulp-jade/gulp-jade.d.ts @@ -0,0 +1,24 @@ +// Type definitions for gulp-jade +// Project: https://github.com/phated/gulp-jade +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-jade" { + function GulpJade(options?: GulpJadeOptions): NodeJS.ReadWriteStream; + + interface GulpJadeOptions { + client?: boolean; + + locals?: Object; + + jade?: any; + + pretty?: boolean; + } + + namespace GulpJade { + } + export = GulpJade; +} From acf0d0f007bcfe03b62fcf14a68e6d275228640d Mon Sep 17 00:00:00 2001 From: Leon Yu Date: Sat, 5 Dec 2015 15:45:33 -0500 Subject: [PATCH 19/66] eventemitter3 to 1.1.1 --- eventemitter3/eventemitter3-tests.ts | 548 ++++++++++++++++++++++++++- eventemitter3/eventemitter3.d.ts | 81 ++-- 2 files changed, 582 insertions(+), 47 deletions(-) diff --git a/eventemitter3/eventemitter3-tests.ts b/eventemitter3/eventemitter3-tests.ts index da13434135..4fa378bc20 100644 --- a/eventemitter3/eventemitter3-tests.ts +++ b/eventemitter3/eventemitter3-tests.ts @@ -1,16 +1,41 @@ -/// +/// +/// +/// 'use strict'; import EventEmitter = require('eventemitter3'); +import util = require('util'); +import * as EventEmitter3ImportedAsES6Module from 'eventemitter3'; + +declare namespace Assume { + interface Class { + new(...args: any[]): T; + } + + interface Assume { + equals(compare: T): Assume; + equal(compare: T): Assume; + eqls(compare: T): Assume; + is: Assume; + deep: Assume; + to: Assume; + either(arr: T[]): Assume; + instanceOf(clazz: Class): Assume; + a(typeofString: string): Assume; + } + + export function assume(input: T): Assume; +} + +let assume = Assume.assume; class EventEmitterTest { - v: EventEmitter; + v: EventEmitter3.EventEmitter; constructor() { this.v = new EventEmitter(); - this.v = new EventEmitter.EventEmitter(); - this.v = new EventEmitter.EventEmitter2(); - this.v = new EventEmitter.EventEmitter3(); + this.v = new EventEmitter3ImportedAsES6Module(); + var n: NodeJS.EventEmitter = this.v; } listeners() { @@ -27,39 +52,528 @@ class EventEmitterTest { on() { var fn = () => console.log(1); - var v1: EventEmitter = this.v.on('click', fn); - var v2: EventEmitter = this.v.on('click', fn, this); + var v1: EventEmitter3.EventEmitter = this.v.on('click', fn); + var v2: EventEmitter3.EventEmitter = this.v.on('click', fn, this); } once() { var fn = () => console.log(1); - var v1: EventEmitter = this.v.once('click', fn); - var v2: EventEmitter = this.v.once('click', fn, this); + var v1: EventEmitter3.EventEmitter = this.v.once('click', fn); + var v2: EventEmitter3.EventEmitter = this.v.once('click', fn, this); } removeListener() { var fn = () => console.log(1); - var v1: EventEmitter = this.v.removeListener('click', fn); - var v2: EventEmitter = this.v.removeListener('click', fn, true); + var v1: EventEmitter3.EventEmitter = this.v.removeListener('click', fn); + var v2: EventEmitter3.EventEmitter = this.v.removeListener('click', fn, true); } removeAllListeners() { - var v1: EventEmitter = this.v.removeAllListeners('click'); + var v1: EventEmitter3.EventEmitter = this.v.removeAllListeners('click'); } off() { var fn = () => console.log(1); - var v1: EventEmitter = this.v.off('click', fn); - var v2: EventEmitter = this.v.off('click', fn, true); + var v1: EventEmitter3.EventEmitter = this.v.off('click', fn); + var v2: EventEmitter3.EventEmitter = this.v.off('click', fn, true); } addListener() { var fn = () => console.log(1); - var v1: EventEmitter = this.v.addListener('click', fn); - var v2: EventEmitter = this.v.addListener('click', fn, this); + var v1: EventEmitter3.EventEmitter = this.v.addListener('click', fn); + var v2: EventEmitter3.EventEmitter = this.v.addListener('click', fn, this); } setMaxListeners() { - var v1: EventEmitter = this.v.setMaxListeners(); + var v1: EventEmitter3.EventEmitter = this.v.setMaxListeners(); } } + + +describe('EventEmitter', function tests() { + 'use strict'; + + it('exposes a `prefixed` property', function () { + assume(EventEmitter.prefixed).is.either([false, '~']); + }); + + it('inherits when used with require(util).inherits', function () { + class Beast extends EventEmitter { + /* rawr, i'm a beast */ + } + + util.inherits(Beast, EventEmitter); + + var moop = new Beast() + , meap = new Beast(); + + assume(moop).is.instanceOf(Beast); + assume(moop).is.instanceOf(EventEmitter); + + moop.listeners(); + meap.listeners(); + + moop.on('data', function () { + throw new Error('I should not emit'); + }); + + meap.emit('data', 'rawr'); + meap.removeListener('foo'); + meap.removeAllListeners(); + }); + + describe('EventEmitter#emit', function () { + it('should return false when there are not events to emit', function () { + var e = new EventEmitter(); + + assume(e.emit('foo')).equals(false); + assume(e.emit('bar')).equals(false); + }); + + it('emits with context', function (done) { + var context = { bar: 'baz' } + , e = new EventEmitter(); + + e.on('foo', function (bar: string) { + assume(bar).equals('bar'); + assume(this).equals(context); + + done(); + }, context).emit('foo', 'bar'); + }); + + it('emits with context, multiple arguments (force apply)', function (done) { + var context = { bar: 'baz' } + , e = new EventEmitter(); + + e.on('foo', function (bar: string) { + assume(bar).equals('bar'); + assume(this).equals(context); + + done(); + }, context).emit('foo', 'bar', 1,2,3,4,5,6,7,8,9,0); + }); + + it('can emit the function with multiple arguments', function () { + var e = new EventEmitter(); + + for(var i = 0; i < 100; i++) { + (function (j: number) { + for (var i = 0, args: number[] = []; i < j; i++) { + args.push(j); + } + + e.once('args', function () { + assume(arguments.length).equals(args.length); + }); + + e.emit.apply(e, (['args'] as any[]).concat(args)); + })(i); + } + }); + + it('can emit the function with multiple arguments, multiple listeners', function () { + var e = new EventEmitter(); + + for(var i = 0; i < 100; i++) { + (function (j: number) { + for (var i = 0, args: number[] = []; i < j; i++) { + args.push(j); + } + + e.once('args', function () { + assume(arguments.length).equals(args.length); + }); + + e.once('args', function () { + assume(arguments.length).equals(args.length); + }); + + e.once('args', function () { + assume(arguments.length).equals(args.length); + }); + + e.once('args', function () { + assume(arguments.length).equals(args.length); + }); + + e.emit.apply(e, (['args'] as any[]).concat(args)); + })(i); + } + }); + + it('emits with context, multiple listeners (force loop)', function () { + var e = new EventEmitter(); + + e.on('foo', function (bar: string) { + assume(this).eqls({ foo: 'bar' }); + assume(bar).equals('bar'); + }, { foo: 'bar' }); + + e.on('foo', function (bar: string) { + assume(this).eqls({ bar: 'baz' }); + assume(bar).equals('bar'); + }, { bar: 'baz' }); + + e.emit('foo', 'bar'); + }); + + it('emits with different contexts', function () { + var e = new EventEmitter() + , pattern = ''; + + function writer() { + pattern += this; + } + + e.on('write', writer, 'foo'); + e.on('write', writer, 'baz'); + e.once('write', writer, 'bar'); + e.once('write', writer, 'banana'); + + e.emit('write'); + assume(pattern).equals('foobazbarbanana'); + }); + + it('should return true when there are events to emit', function (done) { + var e = new EventEmitter(); + + e.on('foo', function () { + process.nextTick(done); + }); + + assume(e.emit('foo')).equals(true); + assume(e.emit('foob')).equals(false); + }); + + it('receives the emitted events', function (done) { + var e = new EventEmitter(); + + e.on('data', function (a: string, b: EventEmitter3.EventEmitter, c: Date, d: void, undef: void) { + assume(a).equals('foo'); + assume(b).equals(e); + assume(c).is.instanceOf(Date); + assume(undef).equals(undefined); + assume(arguments.length).equals(3); + + done(); + }); + + e.emit('data', 'foo', e, new Date()); + }); + + it('emits to all event listeners', function () { + var e = new EventEmitter() + , pattern: string[] = []; + + e.on('foo', function () { + pattern.push('foo1'); + }); + + e.on('foo', function () { + pattern.push('foo2'); + }); + + e.emit('foo'); + + assume(pattern.join(';')).equals('foo1;foo2'); + }); + + (function each(keys: string[]) { + var key = keys.shift(); + + if (!key) return; + + it('can store event which is a known property: '+ key, function (next) { + var e = new EventEmitter(); + + e.on(key, function (key: string) { + assume(key).equals(key); + next(); + }).emit(key, key); + }); + + each(keys); + })([ + 'hasOwnProperty', + 'constructor', + '__proto__', + 'toString', + 'toValue', + 'unwatch', + 'watch' + ]); + }); + + describe('EventEmitter#listeners', function () { + it('returns an empty array if no listeners are specified', function () { + var e = new EventEmitter(); + + assume(e.listeners('foo')).is.a('array'); + assume(e.listeners('foo').length).equals(0); + }); + + it('returns an array of function', function () { + var e = new EventEmitter(); + + function foo() {} + + e.on('foo', foo); + assume(e.listeners('foo')).is.a('array'); + assume(e.listeners('foo').length).equals(1); + assume(e.listeners('foo')).deep.equals([foo]); + }); + + it('is not vulnerable to modifications', function () { + var e = new EventEmitter(); + + function foo() {} + + e.on('foo', foo); + + assume(e.listeners('foo')).deep.equals([foo]); + + e.listeners('foo').length = 0; + assume(e.listeners('foo')).deep.equals([foo]); + }); + + it('can return a boolean as indication if listeners exist', function () { + var e = new EventEmitter(); + + function foo() {} + + e.once('once', foo); + e.once('multiple', foo); + e.once('multiple', foo); + e.on('on', foo); + e.on('multi', foo); + e.on('multi', foo); + + assume(e.listeners('foo', true)).equals(false); + assume(e.listeners('multiple', true)).equals(true); + assume(e.listeners('on', true)).equals(true); + assume(e.listeners('multi', true)).equals(true); + + e.removeAllListeners(); + + assume(e.listeners('multiple', true)).equals(false); + assume(e.listeners('on', true)).equals(false); + assume(e.listeners('multi', true)).equals(false); + }); + }); + + describe('EventEmitter#once', function () { + it('only emits it once', function () { + var e = new EventEmitter() + , calls = 0; + + e.once('foo', function () { + calls++; + }); + + e.emit('foo'); + e.emit('foo'); + e.emit('foo'); + e.emit('foo'); + e.emit('foo'); + + assume(e.listeners('foo').length).equals(0); + assume(calls).equals(1); + }); + + it('only emits once if emits are nested inside the listener', function () { + var e = new EventEmitter() + , calls = 0; + + e.once('foo', function () { + calls++; + e.emit('foo'); + }); + + e.emit('foo'); + assume(e.listeners('foo').length).equals(0); + assume(calls).equals(1); + }); + + it('only emits once for multiple events', function () { + var e = new EventEmitter() + , multi = 0 + , foo = 0 + , bar = 0; + + e.once('foo', function () { + foo++; + }); + + e.once('foo', function () { + bar++; + }); + + e.on('foo', function () { + multi++; + }); + + e.emit('foo'); + e.emit('foo'); + e.emit('foo'); + e.emit('foo'); + e.emit('foo'); + + assume(e.listeners('foo').length).equals(1); + assume(multi).equals(5); + assume(foo).equals(1); + assume(bar).equals(1); + }); + + it('only emits once with context', function (done) { + var context = { foo: 'bar' } + , e = new EventEmitter(); + + e.once('foo', function (bar: string) { + assume(this).equals(context); + assume(bar).equals('bar'); + + done(); + }, context).emit('foo', 'bar'); + }); + }); + + describe('EventEmitter#removeListener', function () { + it('should only remove the event with the specified function', function () { + var e = new EventEmitter(); + + function bar() {} + e.on('foo', function () {}); + e.on('bar', function () {}); + e.on('bar', bar); + + assume(e.removeListener('foo', bar)).equals(e); + assume(e.listeners('foo').length).equals(1); + assume(e.listeners('bar').length).equals(2); + + assume(e.removeListener('foo')).equals(e); + assume(e.listeners('foo').length).equals(0); + assume(e.listeners('bar').length).equals(2); + + assume(e.removeListener('bar', bar)).equals(e); + assume(e.listeners('bar').length).equals(1); + assume(e.removeListener('bar')).equals(e); + assume(e.listeners('bar').length).equals(0); + }); + + it('should only remove once events when using the once flag', function () { + var e = new EventEmitter(); + + function foo() {} + e.on('foo', foo); + + assume(e.removeListener('foo', function () {}, undefined, true)).equals(e); + assume(e.listeners('foo').length).equals(1); + assume(e.removeListener('foo', foo, undefined, true)).equals(e); + assume(e.listeners('foo').length).equals(1); + assume(e.removeListener('foo', foo)).equals(e); + assume(e.listeners('foo').length).equals(0); + + e.on('foo', foo); + e.once('foo', foo); + + assume(e.removeListener('foo', function () {}, undefined, true)).equals(e); + assume(e.listeners('foo').length).equals(2); + assume(e.removeListener('foo', foo, undefined, true)).equals(e); + assume(e.listeners('foo').length).equals(1); + + e.once('foo', foo); + + assume(e.removeListener('foo', foo)).equals(e); + assume(e.listeners('foo').length).equals(0); + }); + + it('should only remove listeners matching the correct context', function () { + var e = new EventEmitter() + , context = { foo: 'bar' }; + + function foo() {} + function bar() {} + e.on('foo', foo, context); + + assume(e.listeners('foo').length).equals(1); + assume(e.removeListener('foo', function () {}, context)).equals(e); + assume(e.listeners('foo').length).equals(1); + assume(e.removeListener('foo', foo, { baz: 'quux' })).equals(e); + assume(e.listeners('foo').length).equals(1); + assume(e.removeListener('foo', foo, context)).equals(e); + assume(e.listeners('foo').length).equals(0); + + e.on('foo', foo, context); + e.on('foo', bar); + + assume(e.listeners('foo').length).equals(2); + assume(e.removeListener('foo', foo, { baz: 'quux' })).equals(e); + assume(e.listeners('foo').length).equals(2); + assume(e.removeListener('foo', foo, context)).equals(e); + assume(e.listeners('foo').length).equals(1); + assume(e.listeners('foo')[0]).equals(bar); + + e.on('foo', foo, context); + + assume(e.listeners('foo').length).equals(2); + assume(e.removeAllListeners('foo')).equals(e); + assume(e.listeners('foo').length).equals(0); + }); + }); + + describe('EventEmitter#removeAllListeners', function () { + it('removes all events for the specified events', function () { + var e = new EventEmitter(); + + e.on('foo', function () { throw new Error('oops'); }); + e.on('foo', function () { throw new Error('oops'); }); + e.on('bar', function () { throw new Error('oops'); }); + e.on('aaa', function () { throw new Error('oops'); }); + + assume(e.removeAllListeners('foo')).equals(e); + assume(e.listeners('foo').length).equals(0); + assume(e.listeners('bar').length).equals(1); + assume(e.listeners('aaa').length).equals(1); + + assume(e.removeAllListeners('bar')).equals(e); + assume(e.removeAllListeners('aaa')).equals(e); + + assume(e.emit('foo')).equals(false); + assume(e.emit('bar')).equals(false); + assume(e.emit('aaa')).equals(false); + }); + + it('just nukes the fuck out of everything', function () { + var e = new EventEmitter(); + + e.on('foo', function () { throw new Error('oops'); }); + e.on('foo', function () { throw new Error('oops'); }); + e.on('bar', function () { throw new Error('oops'); }); + e.on('aaa', function () { throw new Error('oops'); }); + + assume(e.removeAllListeners()).equals(e); + assume(e.listeners('foo').length).equals(0); + assume(e.listeners('bar').length).equals(0); + assume(e.listeners('aaa').length).equals(0); + + assume(e.emit('foo')).equals(false); + assume(e.emit('bar')).equals(false); + assume(e.emit('aaa')).equals(false); + }); + }); + + describe('#setMaxListeners', function () { + it('is a function', function () { + var e = new EventEmitter(); + + assume(e.setMaxListeners).is.a('function'); + }); + + it('returns self when called', function () { + var e = new EventEmitter(); + + assume(e.setMaxListeners()).to.equal(e); + }); + }); +}); diff --git a/eventemitter3/eventemitter3.d.ts b/eventemitter3/eventemitter3.d.ts index f5cf9bcb2d..0d692b8247 100644 --- a/eventemitter3/eventemitter3.d.ts +++ b/eventemitter3/eventemitter3.d.ts @@ -1,11 +1,14 @@ -// Type definitions for EventEmitter3 0.1.6 +// Type definitions for EventEmitter3 1.1.1 // Project: https://github.com/primus/eventemitter3 -// Definitions by: Yuichi Murata -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions by: Yuichi Murata , Leon Yu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module EventEmitter3 { - // __Base is hack for https://github.com/Microsoft/TypeScript/issues/3602 - class __Base { +declare namespace EventEmitter3 { + interface EventEmitter3Static { + new (): EventEmitter; + prefixed: string | boolean; + } + class EventEmitter { /** * Minimal EventEmitter interface that is molded against the Node.js * EventEmitter interface. @@ -22,7 +25,17 @@ declare module EventEmitter3 { * @returns {Array} * @api public */ - listeners(event: string): Function[]; + listeners(event?: string): Function[]; + + /** + * Return a list of assigned event listeners. + * + * @param {String} event The events that should be listed. + * @param {Boolean} exists We only need to know if there are listeners. + * @returns {Boolean} + * @api public + */ + listeners(event: string, param: boolean): boolean; /** * Emit an event to all registered event listeners. @@ -37,8 +50,8 @@ declare module EventEmitter3 { * Register a new EventListener for the given event. * * @param {String} event Name of the event. - * @param {Functon} fn Callback function. - * @param {Mixed} context The context of the function. + * @param {Function} fn Callback function. + * @param {Mixed} [context=this] The context of the function. * @api public */ on(event: string, fn: Function, context?: any): EventEmitter; @@ -48,7 +61,7 @@ declare module EventEmitter3 { * * @param {String} event Name of the event. * @param {Function} fn Callback function. - * @param {Mixed} context The context of the function. + * @param {Mixed} [context=this] The context of the function. * @api public */ once(event: string, fn: Function, context?: any): EventEmitter; @@ -58,10 +71,11 @@ declare module EventEmitter3 { * * @param {String} event The event we want to remove. * @param {Function} fn The listener that we need to find. + * @param {Mixed} context Only remove listeners matching this context. * @param {Boolean} once Only remove once listeners. * @api public */ - removeListener(event: string, fn: Function, once?: boolean): EventEmitter; + removeListener(event: string, fn?: Function, context?: any, once?: boolean): EventEmitter; /** * Remove all listeners or only the listeners for the specified event. @@ -69,34 +83,41 @@ declare module EventEmitter3 { * @param {String} event The event want to remove all listeners for. * @api public */ - removeAllListeners(event: string): EventEmitter; + removeAllListeners(event?: string): EventEmitter; - // - // Alias methods names because people roll like that. - // - off(event: string, fn: Function, once?: boolean): EventEmitter; + /** + * Remove event listeners. + * + * @param {String} event The event we want to remove. + * @param {Function} fn The listener that we need to find. + * @param {Mixed} context Only remove listeners matching this context. + * @param {Boolean} once Only remove once listeners. + * @api public + */ + off(event: string, fn?: Function, context?: any, once?: boolean): EventEmitter; + + /** + * Register a new EventListener for the given event. + * + * @param {String} event Name of the event. + * @param {Function} fn Callback function. + * @param {Mixed} [context=this] The context of the function. + * @api public + */ addListener(event: string, fn: Function, context?: any): EventEmitter; - // - // This function doesn't apply anymore. - // + /** + * This function doesn't apply anymore. + * @deprecated + */ setMaxListeners(): EventEmitter; } - export class EventEmitter extends __Base { } - export module EventEmitter { - // - // Expose the module. - // - export class EventEmitter extends __Base {} - export class EventEmitter2 extends __Base {} - export class EventEmitter3 extends __Base {} - } } declare module 'eventemitter3' { // // Expose the module. // - class EventEmitter extends EventEmitter3.EventEmitter {} - export = EventEmitter; + var EventEmitter3: EventEmitter3.EventEmitter3Static; + export = EventEmitter3; } From 87b5e5f03fdfa0e2561c87c9cca4a3c4d8817d64 Mon Sep 17 00:00:00 2001 From: Kaoru Hagihara Date: Thu, 10 Dec 2015 23:01:39 +0900 Subject: [PATCH 20/66] update vue.js to 1.0.11 --- vue/vue.d.ts | 509 ++++++++++++++++++++++++++------------------------- 1 file changed, 255 insertions(+), 254 deletions(-) diff --git a/vue/vue.d.ts b/vue/vue.d.ts index 4af732579e..650c8d98c4 100644 --- a/vue/vue.d.ts +++ b/vue/vue.d.ts @@ -1,269 +1,270 @@ -// Type definitions for vuejs 1.0.10 +// Type definitions for vuejs 1.0.11 // Project: https://github.com/vuejs/vue // Definitions by: odangosan , kaorun343 // Definitions: https://github.com/borisyankov/DefinitelyTyped interface Array { - $remove(item: T): Array; - $set(index: number, val: T): T; + $remove(item: T): Array; + $set(index: number, val: T): T; } declare namespace vuejs { + + interface PropOption { + type?: any; + required?: boolean; + default?: boolean; + twoWay?: boolean; + validator?(value: any): boolean; + } - interface PropOption { - type?: any; - required?: boolean; - default?: boolean; - twoWay?: boolean; - validator?(value: any): boolean; - } - - interface ComputedOption { - get(): any; - set(value: any): void; - } - - interface WatchOption { - handler(val: any, oldVal: any): void; - deep?: boolean; - immidiate?: boolean; - } - - interface DirectiveOption { - bind?(): any; - update?(newVal?: any, oldVal?: any): any; - unbind?(): any; - params?: string[]; - deep?: boolean; - twoWay?: boolean; - acceptStatement?: boolean; - priority?: number; - [key: string]: any; - } - - interface FilterOption { - read: Function; - write: Function; - } - - interface TransitionOption { - css?: boolean; - beforeEnter?(el: HTMLElement): void; - enter?(el: HTMLElement, done?: () => void): void; - afterEnter?(el: HTMLElement): void; - enterCancelled?(el: HTMLElement): void; - beforeLeave?(el: HTMLElement): void; - leave?(el: HTMLElement, done?: () => void): void; - afterLeave?(el: HTMLElement): void; - leaveCancelled?(el: HTMLElement): void; - stagger?(index: number): number; - } - - interface ComponentOption { - data?: {[key: string]: any } | Function; - props?: string[] | { [key: string]: PropOption }; - computed?: { [key: string]: ( Function | ComputedOption ) }; - methods?: { [key: string]: Function }; - watch?: { [key: string]: ( (val: any, oldVal: any) => void | string | WatchOption )}; - el?: string | HTMLElement | ( () => HTMLElement ); - template?: string; - replace?: boolean; - created?(): void; - beforeCompile?(): void; - compiled?(): void; - ready?(): void; - attached?(): void; - detached?(): void; - beforeDestroy?(): void; - destroyed?(): void; - directives?: { [key: string]: ( DirectiveOption | Function ) }; - elementDirectives?: { [key: string]: ( DirectiveOption | Function ) }; - filters?: { [key: string]: ( Function | FilterOption ) }; - components?: { [key: string]: ComponentOption }; - transitions?: { [key: string]: TransitionOption }; - partials?: { [key: string]: string }; - parent?: Vue; - events?: { [key: string]: ( (...args: any[]) => (boolean | void) ) | string }; - mixins?: ComponentOption[]; - name?: string; - [key: string]: any; - } - - // instance/api/data.js - interface $get { ( exp: string, asStatement?: boolean ): any; } - interface $set { ( key: string | number, value: any ): void; } - interface $delete { ( key: string) : void; } - interface $watch { ( expOrFn: string | Function, callback: ( (newVal: any, oldVal?: any) => any ) | string, options?: { deep?: boolean, immidiate?: boolean } ): Function; } - interface $eval { ( expression: string ): string; } - interface $interpolate { ( expression: string ): string; } - interface $log { ( keypath?: string ): void; } - // instance/api/dom.js - interface $nextTick { ( callback: Function ): void; } - interface $appendTo { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } - interface $prependTo { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } - interface $before { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } - interface $after { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } - interface $remove { ( callback?: Function ): V; } - // instance/api/events.js - interface $on { (event: string, callback: Function): V; } - interface $once { (event: string, callback: Function): V; } - interface $off { (event?: string, callback?: Function): V; } - interface $emit { (event: string, ...args: any[]): V; } - interface $broadcast { (event: string, ...args: any[]): V; } - interface $dispatch { (event: string, ...args: any[]): V; } - // instance/api/lifecycle.js - interface $mount { ( elementOrSelector?: ( HTMLElement | string ) ): V; } - interface $destroy { (remove?: boolean): void; } - interface $compile { (el: Element | DocumentFragment, host?: Vue): Function; } - - interface Vue { - $data?: any; - $el?: HTMLElement; - $options?: Object; - $parent?: Vue; - $root?: Vue; - $children?: Vue[]; - $refs?: Object; - $els?: Object; - - $get?: $get; - $set?: $set; - $delete?: $delete; - $eval?: $eval; - $interpolate?: $interpolate; - $log?: $log; - $watch?: $watch; - $on?: $on; - $once?: $once; - $off?: $off; - $emit?: $emit; - $dispatch?: $dispatch; - $broadcast?: $broadcast; - $appendTo?: $appendTo; - $before?: $before; - $after?: $after; - $remove?: $remove; - $nextTick?: $nextTick; - $mount?: $mount; - $destroy?: $destroy; - $compile?: $compile; - - _init?(options?: ComponentOption): void; - } - - interface VueConfig { - debug: boolean; - delimiters: [string, string]; - unsafeDelimiters: [string, string]; - silent: boolean; - async: boolean; - convertAllProperties: boolean; - } - - interface VueUtil { - // util/lang.js - set(obj: Object, key: string, value: any): void; - del(obj: Object, key: string): void; - hasOwn(obj: Object, key: string): boolean; - isLiteral(exp: string): boolean; - isReserved(str: string): boolean; - _toString(value: any): string; - toNumber(value: T): T | number; - toBoolean(value: T): T | boolean; - stripQuotes(str: string): string; - camelize(str: string): string; - hyphenate(str: string): string; - classify(str: string): string; - bind(fn: Function, ctx: Object): Function; - toAarray(list: ArrayLike, start?: number): Array; - extend(to: T, from: F): ( T & F ); - isObject(obj: any): boolean; - isPlainObject(obj: any): boolean; - isArray: typeof Array.isArray; - def(obj: Object, key: string, value: any, enumerable?: boolean): void; - debounce(func: Function, wait: number): Function; - indexOf(arr: Array, obj: T): number; - cancellable(fn: Function): Function; - looseEqual(a: any, b: any): boolean; - // util/env.js - hasProto: boolean; - inBrowser: boolean; - isIE9: boolean; - isAndroid: boolean; - transitionProp: string; - transitionEndEvent: string; - animationProp: string; - animationEndEvent: string; - nextTick(cb: Function, ctx?: Object): void; - // util/dom.js - query(el: string | Element): Element; - inDoc(node: Node): boolean; - getAttr(node: Node, _attr: string): string; - getBindAttr(node: Node, name: string): string; - before(el: Element, target: Element): void; - after(el: Element, target: Element): void; - remove(el: Element): void; - prepend(el: Element, target: Element): void; - replace(target: Element, el: Element): void; - on(el: Element, event: string, cb: Function): void; - off(el: Element, event: string, cb: Function): void; - addClass(el: Element, cls: string): void; - removeClass(el: Element, cls: string): void; - extractContent(el: Element, asFragment: boolean): ( HTMLDivElement | DocumentFragment ); - trimNode(node: Node): void; - isTemplate(el: Element): boolean; - createAnchor(content: string, persist: boolean): ( Comment | Text ); - findRef(node: Element): string; - mapNodeRange(node: Node, end: Node, op: Function): void; - removeNodeRange(start: Node, end: Node, vm: any, frag: DocumentFragment, cb: Function): void; - // util/options.js - mergeOptions(parent: P, child: C, vm?: any): ( P & C ); - resolveAsset(options: Object, type: string, id: string): ( Object | Function ); - assertAsset(val: any, type: string, id: string): void; - // util/component.js - commonTagRE: RegExp; - checkComponentAttr(el: Element, options?: Object): Object; - initProp(vm: Vue, prop: Object, value: any): void; - assertProp(prop: Object, value: any): boolean; - // util/debug.js - warn(msg: string, e?: Error): void; - // observer/index.js - defineReactive(obj: Object, key: string, val: any): void; - } - - // instance/api/global.js - interface VueStatic { - new(options?: any): Vue; - prototype: Vue; - util: VueUtil; - config: VueConfig; - set(object: Object, key: string, value: any): void; - delete(object: Object, key: string): void; - nextTick(callback: Function): any; - - cid: number; - - extend(options?: ComponentOption): VueStatic; - use(callback: Function | {install: Function, [key: string]: any}, option?: Object): VueStatic; - mixin(mixin: Object): void; - - directive(id: string, definition: T): T; - directive(id: string): any; - elementDirective(id: string, definition: T): T; - elementDirective(id: string): any; - filter(id: string, definition: T): T; - filter(id: string): any; - component(id: string, definition: ComponentOption): any; - component(id: string): any; - transition(id: string, hooks: T): T; - transition(id: string): TransitionOption; - partial(id: string, partial: string): string; - partial(id: string): string; - } + interface ComputedOption { + get(): any; + set(value: any): void; + } + + interface WatchOption { + handler(val: any, oldVal: any): void; + deep?: boolean; + immidiate?: boolean; + } + + interface DirectiveOption { + bind?(): any; + update?(newVal?: any, oldVal?: any): any; + unbind?(): any; + params?: string[]; + deep?: boolean; + twoWay?: boolean; + acceptStatement?: boolean; + priority?: number; + [key: string]: any; + } + + interface FilterOption { + read: Function; + write: Function; + } + + interface TransitionOption { + css?: boolean; + beforeEnter?(el: HTMLElement): void; + enter?(el: HTMLElement, done?: () => void): void; + afterEnter?(el: HTMLElement): void; + enterCancelled?(el: HTMLElement): void; + beforeLeave?(el: HTMLElement): void; + leave?(el: HTMLElement, done?: () => void): void; + afterLeave?(el: HTMLElement): void; + leaveCancelled?(el: HTMLElement): void; + stagger?(index: number): number; + } + + interface ComponentOption { + data?: {[key: string]: any } | Function; + props?: string[] | { [key: string]: PropOption }; + computed?: { [key: string]: ( Function | ComputedOption ) }; + methods?: { [key: string]: Function }; + watch?: { [key: string]: ( (val: any, oldVal: any) => void | string | WatchOption )}; + el?: string | HTMLElement | ( () => HTMLElement ); + template?: string; + replace?: boolean; + created?(): void; + beforeCompile?(): void; + compiled?(): void; + ready?(): void; + attached?(): void; + detached?(): void; + beforeDestroy?(): void; + destroyed?(): void; + activate?(): void; + directives?: { [key: string]: ( DirectiveOption | Function ) }; + elementDirectives?: { [key: string]: ( DirectiveOption | Function ) }; + filters?: { [key: string]: ( Function | FilterOption ) }; + components?: { [key: string]: ComponentOption }; + transitions?: { [key: string]: TransitionOption }; + partials?: { [key: string]: string }; + parent?: Vue; + events?: { [key: string]: ( (...args: any[]) => ( boolean | void ) ) | string }; + mixins?: ComponentOption[]; + name?: string; + [key: string]: any; + } + + // instance/api/data.js + interface $get { ( exp: string, asStatement?: boolean ): any; } + interface $set { ( key: string | number, value: T ): T; } + interface $delete { ( key: string) : void; } + interface $watch { ( expOrFn: string | Function, callback: ( (newVal: any, oldVal?: any) => any ) | string, options?: { deep?: boolean, immidiate?: boolean } ): Function; } + interface $eval { ( expression: string ): string; } + interface $interpolate { ( expression: string ): string; } + interface $log { ( keypath?: string ): void; } + // instance/api/dom.js + interface $nextTick { ( callback: Function ): void; } + interface $appendTo { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } + interface $prependTo { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } + interface $before { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } + interface $after { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; } + interface $remove { ( callback?: Function ): V; } + // instance/api/events.js + interface $on { (event: string, callback: Function): V; } + interface $once { (event: string, callback: Function): V; } + interface $off { (event?: string, callback?: Function): V; } + interface $emit { (event: string, ...args: any[]): V; } + interface $broadcast { (event: string, ...args: any[]): V; } + interface $dispatch { (event: string, ...args: any[]): V; } + // instance/api/lifecycle.js + interface $mount { ( elementOrSelector?: ( HTMLElement | string ) ): V; } + interface $destroy { (remove?: boolean): void; } + interface $compile { (el: Element | DocumentFragment, host?: Vue): Function; } + + interface Vue { + $data?: any; + $el?: HTMLElement; + $options?: Object; + $parent?: Vue; + $root?: Vue; + $children?: Vue[]; + $refs?: Object; + $els?: Object; + + $get?: $get; + $set?: $set; + $delete?: $delete; + $eval?: $eval; + $interpolate?: $interpolate; + $log?: $log; + $watch?: $watch; + $on?: $on; + $once?: $once; + $off?: $off; + $emit?: $emit; + $dispatch?: $dispatch; + $broadcast?: $broadcast; + $appendTo?: $appendTo; + $before?: $before; + $after?: $after; + $remove?: $remove; + $nextTick?: $nextTick; + $mount?: $mount; + $destroy?: $destroy; + $compile?: $compile; + + _init(options?: ComponentOption): void; + } + + interface VueConfig { + debug: boolean; + delimiters: [string, string]; + unsafeDelimiters: [string, string]; + silent: boolean; + async: boolean; + convertAllProperties: boolean; + } + + interface VueUtil { + // util/lang.js + set(obj: Object, key: string, value: any): void; + del(obj: Object, key: string): void; + hasOwn(obj: Object, key: string): boolean; + isLiteral(exp: string): boolean; + isReserved(str: string): boolean; + _toString(value: any): string; + toNumber(value: T): T | number; + toBoolean(value: T): T | boolean; + stripQuotes(str: string): string; + camelize(str: string): string; + hyphenate(str: string): string; + classify(str: string): string; + bind(fn: Function, ctx: Object): Function; + toAarray(list: ArrayLike, start?: number): Array; + extend(to: T, from: F): ( T & F ); + isObject(obj: any): boolean; + isPlainObject(obj: any): boolean; + isArray: typeof Array.isArray; + def(obj: Object, key: string, value: any, enumerable?: boolean): void; + debounce(func: Function, wait: number): Function; + indexOf(arr: Array, obj: T): number; + cancellable(fn: Function): Function; + looseEqual(a: any, b: any): boolean; + // util/env.js + hasProto: boolean; + inBrowser: boolean; + isIE9: boolean; + isAndroid: boolean; + transitionProp: string; + transitionEndEvent: string; + animationProp: string; + animationEndEvent: string; + nextTick(cb: Function, ctx?: Object): void; + // util/dom.js + query(el: string | Element): Element; + inDoc(node: Node): boolean; + getAttr(node: Node, _attr: string): string; + getBindAttr(node: Node, name: string): string; + before(el: Element, target: Element): void; + after(el: Element, target: Element): void; + remove(el: Element): void; + prepend(el: Element, target: Element): void; + replace(target: Element, el: Element): void; + on(el: Element, event: string, cb: Function): void; + off(el: Element, event: string, cb: Function): void; + addClass(el: Element, cls: string): void; + removeClass(el: Element, cls: string): void; + extractContent(el: Element, asFragment: boolean): ( HTMLDivElement | DocumentFragment ); + trimNode(node: Node): void; + isTemplate(el: Element): boolean; + createAnchor(content: string, persist: boolean): ( Comment | Text ); + findRef(node: Element): string; + mapNodeRange(node: Node, end: Node, op: Function): void; + removeNodeRange(start: Node, end: Node, vm: any, frag: DocumentFragment, cb: Function): void; + // util/options.js + mergeOptions(parent: P, child: C, vm?: any): ( P & C ); + resolveAsset(options: Object, type: string, id: string): ( Object | Function ); + assertAsset(val: any, type: string, id: string): void; + // util/component.js + commonTagRE: RegExp; + checkComponentAttr(el: Element, options?: Object): Object; + initProp(vm: Vue, prop: Object, value: any): void; + assertProp(prop: Object, value: any): boolean; + // util/debug.js + warn(msg: string, e?: Error): void; + // observer/index.js + defineReactive(obj: Object, key: string, val: any): void; + } + + // instance/api/global.js + interface VueStatic { + new(options?: ComponentOption): Vue; + prototype: Vue; + util: VueUtil; + config: VueConfig; + set(object: Object, key: string, value: any): void; + delete(object: Object, key: string): void; + nextTick(callback: Function): any; + + cid: number; + + extend(options?: ComponentOption): VueStatic; + use(callback: Function | {install: Function, [key: string]: any}, option?: Object): VueStatic; + mixin(mixin: Object): void; + + directive(id: string, definition: T): T; + directive(id: string): any; + elementDirective(id: string, definition: T): T; + elementDirective(id: string): any; + filter(id: string, definition: T): T; + filter(id: string): any; + component(id: string, definition: ComponentOption): any; + component(id: string): any; + transition(id: string, hooks: T): T; + transition(id: string): TransitionOption; + partial(id: string, partial: string): string; + partial(id: string): string; + } } declare var Vue: vuejs.VueStatic; declare module "vue" { - export default Vue; + export = Vue; } From 07deed85edf73b0d794db713559eb9a4f1f476ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elis=C3=A9e?= Date: Thu, 10 Dec 2015 19:16:01 +0100 Subject: [PATCH 21/66] Fix electron.nativeImage's type --- github-electron/github-electron.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 7c5fa8b4d6..48f893d06b 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1700,7 +1700,7 @@ declare module GitHubElectron { interface Electron { clipboard: GitHubElectron.Clipboard; crashReporter: GitHubElectron.CrashReporter; - nativeImage: GitHubElectron.NativeImage; + nativeImage: typeof GitHubElectron.NativeImage; screen: GitHubElectron.Screen; shell: GitHubElectron.Shell; remote: GitHubElectron.Remote; From 2e21448655e5819dce96ad255a9f119f5a6fd982 Mon Sep 17 00:00:00 2001 From: phiresky Date: Mon, 21 Sep 2015 00:45:56 +0200 Subject: [PATCH 22/66] add wu typings --- wu/wu-tests.ts | 411 +++++++++++++++++++++++++++++++++++++++ wu/wu-tests.ts.tscparams | 1 + wu/wu.d.ts | 117 +++++++++++ wu/wu.d.ts.tscparams | 1 + 4 files changed, 530 insertions(+) create mode 100644 wu/wu-tests.ts create mode 100644 wu/wu-tests.ts.tscparams create mode 100644 wu/wu.d.ts create mode 100644 wu/wu.d.ts.tscparams diff --git a/wu/wu-tests.ts b/wu/wu-tests.ts new file mode 100644 index 0000000000..c207820303 --- /dev/null +++ b/wu/wu-tests.ts @@ -0,0 +1,411 @@ +// adapted from `cat wu.js/test/* |sed '/= require/d'> wu-tests.ts` +/// +declare var describe: any, it: any, mocha: any, assert: { + iterable:any; + eqSet(expected:Set, actual: Iterable): any; + ok:any; + equal(x:T, y:T): any; + eqArray(x:T[], y:Iterable): any; + deepEqual(x:T, y:T): any; +} + +// Helper for asserting that the given thing is iterable. +assert.iterable = thing => { + assert.ok(wu(thing)); +}; + +// Helper for asserting that all the elements yielded from the |actual| +// iterator are in the |expected| set. +assert.eqSet = (expected, actual) => { + assert.iterable(actual); + for (var x of actual) { + assert.ok(expected.has(x)); + expected.delete(x); + } +}; + +// Helper for asserting that all the elements yielded from the |actual| +// iterator are equal to and in the same order as the elements of the +// |expected| array. +assert.eqArray = (expected, actual) => { + assert.iterable(actual); + assert.deepEqual(expected, [...actual]); +}; + +mocha.setup('bdd'); +describe("wu.asyncEach", () => { + it("should iterate over each item", () => { + const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + let n = 0; + + return wu(arr) + .asyncEach(x => { + n++; + const start = Date.now(); + while (Date.now() - start <= 3) { + // Kill time. + } + }, 3) + .then(() => { + assert.equal(n, arr.length); + }); + }); +}); +describe("wu.chain", () => { + it("should concatenate iterables", () => { + assert.eqArray([1, 2, 3, 4, 5, 6], + wu.chain([1, 2], [3, 4], [5, 6])); + }); +}); +describe("wu.chunk", () => { + it("should chunk items into tuples", () => { + assert.eqArray([[1,2,3], [4,5,6]], + wu.chunk(3, [1,2,3,4,5,6])); + }); +}); +describe("wu.concatMap", () => { + it("should map the function over the iterable and concatenate results", () => { + assert.eqArray([1, 1, 2, 4, 3, 9], + wu.concatMap(x => [x, x * x], [1, 2, 3])); + }); +}); +describe("wu.count", () => { + it("should keep incrementing", () => { + const count = wu.count(); + assert.equal(count.next().value, 0); + assert.equal(count.next().value, 1); + assert.equal(count.next().value, 2); + assert.equal(count.next().value, 3); + assert.equal(count.next().value, 4); + assert.equal(count.next().value, 5); + }); + + it("should start at the provided number", () => { + const count = wu.count(5); + assert.equal(count.next().value, 5); + assert.equal(count.next().value, 6); + assert.equal(count.next().value, 7); + }); + + it("should increment by the provided step", () => { + const count = wu.count(0, 2); + assert.equal(count.next().value, 0); + assert.equal(count.next().value, 2); + assert.equal(count.next().value, 4); + }); +}); +describe("wu.curryable", () => { + it("should wait until its given enough arguments", () => { + var f = wu.curryable((a, b) => a + b); + + var f0 = f()()()()(); + assert.equal(typeof f0, "function"); + + var f1 = f(1); + assert.equal(typeof f1, "function"); + assert.equal(f1(2), 3); + }); + + it("should just call the function when given enough arguments", () => { + var f = wu.curryable((a, b) => a + b); + assert.equal(f(1, 2), 3); + }); + + it("should expect the number of arguments we tell it to", () => { + var f = wu.curryable((...args) => 5, 5); + assert.equal(typeof f(1, 2, 3, 4), "function"); + assert.equal(f(1, 2, 3, 4, 5), 5); + }); +}); +describe("wu.cycle", () => { + it("should keep yielding items from the original iterable", () => { + let i = 0; + const arr = [1, 2, 3]; + for (let x of wu.cycle(arr)) { + assert.equal(x, arr[i % 3]); + if (i++ > 9) { + break; + } + } + }); +}); +describe("wu.drop", () => { + it("should drop the number of items specified", () => { + const count = wu.count().drop(5); + assert.equal(count.next().value, 5); + }); +}); +describe("wu.dropWhile", () => { + it("should drop items while the predicate is true", () => { + const count = wu.dropWhile(x => x < 5, wu.count()); + assert.equal(count.next().value, 5); + }); +}); +describe("wu.entries", () => { + it("should iterate over entries", () => { + const expected = new Map([["foo", 1], ["bar", 2], ["baz", 3]]); + for (let [k, v] of wu.entries({ foo: 1, bar: 2, baz: 3 })) { + assert.equal(expected.get(k), v); + } + }); +}); +describe("wu.enumerate", () => { + it("should yield items with their index", () => { + assert.eqArray([["a", 0], ["b", 1], ["c", 2]], + wu.enumerate("abc")); + }); +}); +describe("wu.every", () => { + it("should return true when the predicate succeeds for all items", () => { + assert.equal(true, wu.every(x => typeof x === "number", [1, 2, 3])); + }); + + it("should return false when the predicate fails for any item", () => { + assert.equal(false, wu.every(x => typeof x === "number", [1, 2, "3"])); + }); +}); +describe("wu.filter", () => { + it("should filter based on the predicate", () => { + assert.eqArray(["a", "b", "c"], + wu.filter(x => typeof x === "string", + [1, "a", true, "b", {}, "c"])); + }); +}); +describe("wu.find", () => { + it("should return the first item that matches the predicate", () => { + assert.deepEqual({ name: "rza" }, + wu.find(x => !!x.name.match(/.za$/), + [{ name: "odb" }, + { name: "method man" }, + { name: "rza" }, + { name: "gza" }])); + }); + + it("should return undefined if no items match the predicate", () => { + assert.equal(undefined, + wu.find(x => (x) === "raekwon", + [{ name: "odb" }, + { name: "method man" }, + { name: "rza" }, + { name: "gza" }])); + }); +}); +describe("wu.flatten", () => { + it("should flatten iterables", () => { + assert.eqArray(["I", "like", "LISP"], + wu(["I", ["like", ["LISP"]]]).flatten()); + }); + + it("should shallowly flatten iterables", () => { + assert.eqArray([1, 2, 3, [[4]]], + wu.flatten(true, [1, [2], [3, [[4]]]])); + }); +}); +describe("wu.forEach", () => { + it("should iterate over every item", () => { + const items = []; + wu.forEach(x => items.push(x), [1,2,3]); + assert.eqArray([1,2,3], items); + }); +}); +describe("wu.has", () => { + it("should return true if the item is in the iterable", () => { + assert.ok(wu.has(3, [1,2,3])); + }); + + it("should return false if the item is not in the iterable", () => { + assert.ok(!wu.has("36 chambers", [1,2,3])); + }); +}); +describe("wu.invoke", () => { + it("should yield the method invokation on each item", () => { + function Greeter(name) { + this.name = name + } + Greeter.prototype.greet = function (tail) { + return "hello " + this.name + tail; + }; + assert.eqArray(["hello world!", "hello test!"], + wu.invoke("greet", "!", + [new Greeter("world"), new Greeter("test")])); + }); +}); +describe("wu.keys", () => { + it("should iterate over keys", () => { + assert.eqSet(new Set(["foo", "bar", "baz"]), + wu.keys({ foo: 1, bar: 2, baz: 3 })); + }); +}); +describe("wu.map", () => { + it("should map the function over the iterable", () => { + assert.eqArray([1, 4, 9], + wu.map(x => x * x, [1, 2, 3])); + }); +}); +describe("wu.pluck", () => { + it("should access the named property of each item in the iterable", () => { + assert.eqArray([1, 2, 3], + wu.pluck("i", [{ i: 1 }, { i: 2 }, { i: 3 }])); + }); +}); +describe("wu.reduce", () => { + it("should reduce the iterable with the function", () => { + assert.equal(6, wu([1,2,3]).reduce((x, y) => x + y)); + }); + + it("should accept an initial state for the reducer function", () => { + assert.equal(16, wu.reduce((x, y) => x + y, 10, [1,2,3])); + }); +}); +describe("wu.reductions", () => { + it("should yield the intermediate reductions of the iterable", () => { + assert.eqArray([1, 3, 6], + wu.reductions((x, y) => x + y, undefined, [1, 2, 3])); + }); +}); +describe("wu.reject", () => { + it("should yield items for which the predicate is false", () => { + assert.eqArray([1, true, {}], + wu.reject(x => typeof x === "string", + [1, "a", true, "b", {}, "c"])); + }); +}); +describe("wu.repeat", () => { + it("should keep yielding its item", () => { + const repeat = wu.repeat(3); + assert.equal(repeat.next().value, 3); + assert.equal(repeat.next().value, 3); + assert.equal(repeat.next().value, 3); + assert.equal(repeat.next().value, 3); + assert.equal(repeat.next().value, 3); + assert.equal(repeat.next().value, 3); + assert.equal(repeat.next().value, 3); + }); + + it("should repeat n times", () => { + const repeat = wu.repeat(3, 2); + assert.equal(repeat.next().value, 3); + assert.equal(repeat.next().value, 3); + assert.equal(repeat.next().value, undefined); + assert.equal(repeat.next().done, true); + }); +}); +describe("wu.slice", () => { + it("should slice the front of iterables", () => { + assert.eqArray([3, 4, 5], + wu.slice(3, undefined, [0, 1, 2, 3, 4, 5])); + }); + + it("should slice the end of iterables", () => { + assert.eqArray([0, 1, 2], + wu.slice(undefined, + 3, + [0, 1, 2, 3, 4, 5])); + }); +}); +describe("wu.some", () => { + it("should return true if any item matches the predicate", () => { + assert.ok(wu.some(x => x % 2 === 0, [1,2,3])); + }); + + it("should return false if no items match the predicate", () => { + assert.ok(!wu.some(x => x % 5 === 0, [1,2,3])); + }); +}); +describe("wu.spreadMap", () => { + it("should map the function over the iterable with spread arguments", () => { + assert.eqArray([32, 9, 1000], + wu.spreadMap(Math.pow, [[2, 5], [3, 2], [10, 3]])); + }); +}); +describe("wu.take", () => { + it("should yield as many items as requested", () => { + assert.eqArray([0, 1, 2, 3, 4], + wu.take(5, wu.count())); + }); +}); +describe("wu.takeWhile", () => { + it("should keep yielding items from the iterable until the predicate is false", () => { + assert.eqArray([0, 1, 2, 3, 4], + wu.takeWhile(x => x < 5, wu.count())); + }); +}); +describe("wu.tap", () => { + it("should perform side effects and yield the original item", () => { + let i = 0; + assert.eqArray([1, 2, 3], + wu.tap(x => i++, [1, 2, 3])); + assert.equal(i, 3); + }); +}); +describe("wu.tee", () => { + it("should clone iterables", () => { + const factorials = wu(wu.count(1)).reductions((a, b) => a * b); + const [i1, i2] = wu(factorials).tee(); + + assert.equal(i1.next().value, 1); + assert.equal(i1.next().value, 2); + assert.equal(i1.next().value, 6); + assert.equal(i1.next().value, 24); + + assert.equal(i2.next().value, 1); + assert.equal(i2.next().value, 2); + assert.equal(i2.next().value, 6); + assert.equal(i2.next().value, 24); + }); +}); +describe("wu.unique", () => { + it("should yield only the unique items from the iterable", () => { + assert.eqArray([1, 2, 3], + wu.unique([1,1,2,2,1,1,3,3])); + }); +}); +describe("wu.unzip", () => { + it("should create iterables from zipped items", () => { + const pairs = [ + ["one", 1], + ["two", 2], + ["three", 3] + ]; + const [i1, i2] = wu(pairs).unzip(); + assert.eqArray(["one", "two", "three"], [...i1]); + assert.eqArray([1, 2, 3], [...i2]); + }); +}); +describe("wu.values", () => { + it("should iterate over values", () => { + assert.eqSet(new Set([1, 2, 3]), + wu.values({ foo: 1, bar: 2, baz: 3 })); + }); +}); +describe("wu.zip", () => { + it("should zip two iterables together", () => { + assert.eqArray([["a", 1], ["b", 2], ["c", 3]], + wu.zip("abc", [1, 2, 3])); + }); + + it("should stop with the shorter iterable", () => { + assert.eqArray([["a", 1], ["b", 2], ["c", 3]], + wu.zip("abc", wu.count(1))); + }); +}); +describe("wu.zipLongest", () => { + it("should stop with the longer iterable", () => { + const arr1 = []; + arr1[1] = 2; + const arr2 = []; + arr2[1] = 3; + assert.eqArray([["a", 1], arr1, arr2], + wu.zipLongest("a", [1, 2, 3])); + }); +}); +describe("wu.zipWith", () => { + it("should spread map over the zipped iterables", () => { + const add3 = (a, b, c) => a + b + c; + assert.eqArray([12, 15, 18], + wu.zipWith(add3, + [1, 2, 3], + [4, 5, 6], + [7, 8, 9])); + }); +}); diff --git a/wu/wu-tests.ts.tscparams b/wu/wu-tests.ts.tscparams new file mode 100644 index 0000000000..14fce22a5c --- /dev/null +++ b/wu/wu-tests.ts.tscparams @@ -0,0 +1 @@ +--target ES6 diff --git a/wu/wu.d.ts b/wu/wu.d.ts new file mode 100644 index 0000000000..61a0e6e97c --- /dev/null +++ b/wu/wu.d.ts @@ -0,0 +1,117 @@ +// Type definitions for wu.js v2.1.0 +// Project: http://backbonejs.org/ +// Definitions by: phiresky +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Wu { + type Consumer = (t: T) => void; + type Filter = (t: T) => boolean; + + export interface WuStatic { + (iterable: Iterable): WuIterable; + // only static + chain(...iters: Iterable[]): WuIterable; + count(start?: number, step?: number): WuIterable; + curryable(fun: (...x: any[]) => T, expected?: number): any; + entries(obj: { [i: string]: T }): WuIterable<[string, T]>; + keys(obj: { [i: string]: T }): WuIterable; + values(obj: { [i: string]: T }): WuIterable; + repeat(obj: T, times?: number): WuIterable; + // also copied to WuInterface + asyncEach(fn: Consumer, maxBlock?: number, timeout?: number): void; + drop(n: number, iter: Iterable): WuIterable; + dropWhile(fn: Filter, iter: Iterable): WuIterable; + cycle(iter: Iterable): Iterable; + chunk(n: number, iter: Iterable): WuIterable; + concatMap(fn: (t: T) => Iterable, iter: Iterable): WuIterable; + dropWhile(fn: Filter, iter: Iterable): WuIterable; + enumerate(iter: Iterable): Iterable<[number, T]>; + every(fn: Filter, iter: Iterable): boolean; + filter(fn: Filter, iter: Iterable): WuIterable; + find(fn: Filter, iter: Iterable): T; + flatten(iter: Iterable): WuIterable; + flatten(shallow: boolean, iter: Iterable): WuIterable; + forEach(fn: Consumer, iter: Iterable): void; + has(t: T, iter: Iterable): boolean; + // invoke(name:string, ...t:T[], iter: Iterable<(t:T)=>U>): WuIterable; + invoke: any; + map(fn: (t: T) => U, iter: Iterable): WuIterable; + // pluck(attribute:string, iter: Iterable<{[attribute]: T}>): WuIterable; + pluck(attribute: string, iter: Iterable): WuIterable; + reduce(fn: (a: T, b: T) => T, iter: Iterable): T; + reduce(fn: (a: T, b: T) => T, initial: T, iter: Iterable): T; + reduce(fn: (a: U, b: T) => U, iter: Iterable): U; + reduce(fn: (a: U, b: T) => U, initial: U, iter: Iterable): U; + reductions(fn: (a: T, b: T) => T, iter: Iterable): WuIterable; + reductions(fn: (a: T, b: T) => T, initial: T, iter: Iterable): WuIterable; + reductions(fn: (a: U, b: T) => U, iter: Iterable): WuIterable; + reductions(fn: (a: U, b: T) => U, initial: U, iter: Iterable): WuIterable; + reject(fn: Filter, iter: Iterable): WuIterable; + slice(iter: Iterable): WuIterable; + slice(start: number, iter: Iterable): WuIterable; + slice(start: number, stop: number, iter: Iterable): WuIterable; + some(fn: Filter, iter: Iterable): WuIterable; + spreadMap(fn: (...x: any[]) => T, iter: Iterable): WuIterable; + take(n: number, iter: Iterable): WuIterable; + takeWhile(fn: Filter, iter: Iterable): WuIterable; + tap(fn: Consumer, iter: Iterable): WuIterable; + unique(iter: Iterable): WuIterable; + zip(iter2: Iterable, iter: Iterable): WuIterable<[T, U]>; + zipLongest(iter2: Iterable, iter: Iterable): WuIterable<[T, U]>; + zipWith: any; + unzip: any; + tee(iter: Iterable): WuIterable[]; + tee(n: number, iter: Iterable): WuIterable[]; + } + export interface WuIterable extends IterableIterator { + // generated from section "copied to WuIterable" above via + // sed -r 's/(, )?iter: Iterable<\w+>//' | + // sed -r 's/^(\s+\w+)/\1/' | + // sed -r 's/^(\s+\w+)(fn: Consumer, maxBlock?: number, timeout?: number): any; + drop(n: number): WuIterable; + dropWhile(fn: Filter): WuIterable; + cycle(): Iterable; + chunk(n: number): WuIterable; + concatMap(fn: (t: T) => Iterable): WuIterable; + dropWhile(fn: Filter): WuIterable; + enumerate(): Iterable<[number, T]>; + every(fn: Filter): boolean; + filter(fn: Filter): WuIterable; + find(fn: Filter): T; + flatten(): WuIterable; + flatten(shallow: boolean): WuIterable; + forEach(fn: Consumer): void; + has(t: T): boolean; + // invoke(name:string, ...t:T[], iter: Iterable<(t:T)=>U>): WuIterable; + invoke: any; + map(fn: (t: T) => U): WuIterable; + // pluck(attribute:string, iter: Iterable<{[attribute]: T}>): WuIterable; + pluck(attribute: string): WuIterable; + reduce(fn: (a: T, b: T) => T): T; + reduce(fn: (a: T, b: T) => T, initial: T): T; + reduce(fn: (a: U, b: T) => U): U; + reduce(fn: (a: U, b: T) => U, initial: U): U; + reductions(fn: (a: T, b: T) => T): WuIterable; + reductions(fn: (a: T, b: T) => T, initial: T): WuIterable; + reductions(fn: (a: U, b: T) => U): WuIterable; + reductions(fn: (a: U, b: T) => U, initial: U): WuIterable; + reject(fn: Filter): WuIterable; + slice(): WuIterable; + slice(start: number): WuIterable; + slice(start: number, stop: number): WuIterable; + some(fn: Filter): WuIterable; + spreadMap(fn: (...x: any[]) => T, iter: Iterable): WuIterable; + take(n: number): WuIterable; + takeWhile(fn: Filter): WuIterable; + tap(fn: Consumer): WuIterable; + unique(): WuIterable; + zip(iter2: Iterable): WuIterable<[T, U]>; + zipLongest(iter2: Iterable): WuIterable<[T, U]>; + zipWith: any; + unzip: any; + tee(): WuIterable[]; + tee(n: number): WuIterable[]; + } +} +declare var wu: Wu.WuStatic; diff --git a/wu/wu.d.ts.tscparams b/wu/wu.d.ts.tscparams new file mode 100644 index 0000000000..14fce22a5c --- /dev/null +++ b/wu/wu.d.ts.tscparams @@ -0,0 +1 @@ +--target ES6 From 9abd523d14733b66e641eba4ac94951cf98a554d Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 11 Dec 2015 08:40:27 +0100 Subject: [PATCH 23/66] polymer ts test file --- polymer-ts/polymer-ts-tests.ts | 38 ++++++++++++++++++++++++++++++++++ polymer-ts/polymer-ts.d.ts | 7 +------ 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 polymer-ts/polymer-ts-tests.ts diff --git a/polymer-ts/polymer-ts-tests.ts b/polymer-ts/polymer-ts-tests.ts new file mode 100644 index 0000000000..5e4e42df26 --- /dev/null +++ b/polymer-ts/polymer-ts-tests.ts @@ -0,0 +1,38 @@ +/// + +namespace Components { + + export class TestComponent extends polymer.Base { + + public field: string = 'foo'; + public is: string; + + constructor() { + super(); + this.is = 'test-test'; + } + + public ready(): void { + console.log('ready'); + this.async(() => { + console.log('delayed'); + }, 500); + } + } + + polymer.createElement(TestComponent); + + @component('test-annotated') + export class AnnotatedComponent extends polymer.Base { + + public field: string = 'xx'; + + constructor() { + super(); + } + + public ready(): void { + console.log('annotated ready'); + } + } +} diff --git a/polymer-ts/polymer-ts.d.ts b/polymer-ts/polymer-ts.d.ts index cd96dfe21a..c00c0ce1a0 100644 --- a/polymer-ts/polymer-ts.d.ts +++ b/polymer-ts/polymer-ts.d.ts @@ -1,8 +1,3 @@ -// Type definitions for PolymerTS 0.1.17 -// Project: https://github.com/nippur72/PolymerTS -// Definitions by: Louis Grignon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - declare module polymer { class PolymerBase extends HTMLElement { $: any; @@ -93,7 +88,7 @@ declare module polymer { type?: any; value?: any; reflectToAttribute?: boolean; - readonly?: boolean; + readOnly?: boolean; notify?: boolean; computed?: string; observer?: string; From 31ae86e54c72ad8e52e2c8f0abfed5f830672a80 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 11 Dec 2015 08:43:27 +0100 Subject: [PATCH 24/66] fixed def typed header --- polymer-ts/polymer-ts.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/polymer-ts/polymer-ts.d.ts b/polymer-ts/polymer-ts.d.ts index c00c0ce1a0..921b256656 100644 --- a/polymer-ts/polymer-ts.d.ts +++ b/polymer-ts/polymer-ts.d.ts @@ -1,3 +1,8 @@ +// Type definitions for PolymerTS 0.1.19 +// Project: https://github.com/nippur72/PolymerTS +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + declare module polymer { class PolymerBase extends HTMLElement { $: any; From 5b8db10eaa365f248d644a14dd44f755d190a651 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 11 Dec 2015 08:48:01 +0100 Subject: [PATCH 25/66] tests modified --- polymer-ts/polymer-ts-tests.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/polymer-ts/polymer-ts-tests.ts b/polymer-ts/polymer-ts-tests.ts index 5e4e42df26..1347b3bb71 100644 --- a/polymer-ts/polymer-ts-tests.ts +++ b/polymer-ts/polymer-ts-tests.ts @@ -21,18 +21,4 @@ namespace Components { } polymer.createElement(TestComponent); - - @component('test-annotated') - export class AnnotatedComponent extends polymer.Base { - - public field: string = 'xx'; - - constructor() { - super(); - } - - public ready(): void { - console.log('annotated ready'); - } - } } From 482c331129ac50e6bc680700a3405baae517a06a Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 11 Dec 2015 11:45:17 +0100 Subject: [PATCH 26/66] Update type definition to version 0.20.2 Newer version of Angulartics (0.20.2), brings a new feature that allows to exclude specific routes from pageview tracking. Version release on 17/11/2015. Project changes log: https://github.com/angulartics/angulartics/blob/master/CHANGELOG.md Original plugin pull request and description: https://github.com/angulartics/angulartics/pull/419 --- angulartics/angulartics.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/angulartics/angulartics.d.ts b/angulartics/angulartics.d.ts index edb9aefb3d..d586eee54a 100644 --- a/angulartics/angulartics.d.ts +++ b/angulartics/angulartics.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angulartics v0.19.2 +// Type definitions for Angulartics v0.20.2 // Project: http://luisfarzati.github.io/angulartics/ // Definitions by: Steven Fan // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -21,6 +21,7 @@ declare module angulartics { interface IAnalyticsServiceProvider extends angular.IServiceProvider { virtualPageviews(value: boolean): void; + excludeRoutes(value: string[]):void; firstPageview(value: boolean): void; withBase(value: boolean): void; withAutoBase(value: boolean): void; From 0eaa2e33f76641182d1713c2f865c1417c68a37c Mon Sep 17 00:00:00 2001 From: Nick Zamosenchuk Date: Fri, 11 Dec 2015 14:13:49 +0100 Subject: [PATCH 27/66] [ngNotify] create Type Definition for Angular JS ngNotify library ngNotify is a simple, lightweight and elegant notification service for AngularJS applications. This commit/pull request contains a type definition for the latest version of this library --- ng-notify/ng-notify-tests.ts | 11 ++++++ ng-notify/ng-notify.d.ts | 72 ++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 ng-notify/ng-notify-tests.ts create mode 100644 ng-notify/ng-notify.d.ts diff --git a/ng-notify/ng-notify-tests.ts b/ng-notify/ng-notify-tests.ts new file mode 100644 index 0000000000..4a03d62cec --- /dev/null +++ b/ng-notify/ng-notify-tests.ts @@ -0,0 +1,11 @@ +/// +/// + +class NgNotifyTestController { + + static $inject = ['$scope', 'ngNotify']; + + constructor($scope:ng.IScope, ngNotify:ngNotify.INotifyService) { + ngNotify.set('Your error message goes here!', 'error'); + } +}; \ No newline at end of file diff --git a/ng-notify/ng-notify.d.ts b/ng-notify/ng-notify.d.ts new file mode 100644 index 0000000000..f1092df625 --- /dev/null +++ b/ng-notify/ng-notify.d.ts @@ -0,0 +1,72 @@ +// Type definitions for ng-notify 0.7.1 +// Project: https://github.com/matowens/ng-notify +// Definitions by: Nick Zamosenchuk +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + +declare module ngNotify { + + /** + * Contains the options used to configure notification. + */ + interface IUserOptions{ + type?: string; + theme?: string; + position?: string; + duration?: number; + sticky?: boolean; + button?: boolean; + html?: boolean; + } + + /** + * Simply and lightweight notification service for AngularJS + */ + interface INotifyService { + + /** + * Allows to create a whole new set of styles for each notification type. + * @param themeName The name used when setting the theme in the config object. + * @param className The class used to target this theme in the stylesheet. + */ + addTheme(themeName:string, className:string):void; + + /** + * Allows to create a new type of notification to use in their app. + * @param typeName The name used to trigger this notification type in the set method. + * @param className The class used to target this type in the stylesheet. + */ + addType(typeName:string, className:string):void; + + /** + * Sets default settings for all notifications to take into account when displaying. + * @param userOptions Notification configuration object + */ + config(userOptions: IUserOptions):void; + + /** + * Manually dismisses any sticky notifications that may still be set. + */ + dismiss():void; + + /** + * Displays a notification message. + * @param message A message text to display. + */ + set(message: string):void; + + /** + * Displays a notification message and sets the type for this one notification. + * @param message A message text to display. + * @param type The type of the notification. + */ + set(message: string, type: string):void; + + /** + * displays a notification message and sets the formatting/behavioral options for this one notification. + * @param message A message text to display. + * @param userOptions Notification configuration object. + */ + set(message: string, userOptions: IUserOptions):void; + } +} From 5c9b77c2db4f324ab2431f27b35a0b9c44383dbe Mon Sep 17 00:00:00 2001 From: George Wu Date: Fri, 11 Dec 2015 21:49:53 +0800 Subject: [PATCH 28/66] Added type definitions for sql.js. --- sql.js/sql.js-tests.ts | 81 ++++++++++++++++++++++++++++++++++++++++++ sql.js/sql.js.d.ts | 71 ++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 sql.js/sql.js-tests.ts create mode 100644 sql.js/sql.js.d.ts diff --git a/sql.js/sql.js-tests.ts b/sql.js/sql.js-tests.ts new file mode 100644 index 0000000000..eeba3f0809 --- /dev/null +++ b/sql.js/sql.js-tests.ts @@ -0,0 +1,81 @@ +/// +/// + +import fs = require("fs"); +import SQL = require("sql.js"); + +var DB_PATH = "data.db"; + +function createFile(path: string): void { + var fd = fs.openSync(path, "a"); + fs.closeSync(fd); +} + +// Open the database file. If it does not exist, create a blank database in memory. +var databaseData: Buffer; +databaseData = fs.existsSync(DB_PATH) ? fs.readFileSync(DB_PATH) : null; +var db = new SQL.Database(databaseData); + +// Create a new table 'test_table' in the database in memory. +var createTableStatement = + "DROP TABLE IF EXISTS test_table;" + + "CREATE TABLE test_table (id INTEGER PRIMARY KEY, content TEXT);"; +db.run(createTableStatement); + +// Insert 2 records for testing. +var insertRecordStatement = + "INSERT INTO test_table (id, content) VALUES (@id, @content);"; +db.run(insertRecordStatement, { + "@id": 1, + "@content": "Content 1" +}); +db.run(insertRecordStatement, { + "@id": 2, + "@content": "Content 2" +}); + +try { + // This query will throw exception: primary key constraint failed. + db.run(insertRecordStatement, { + "@id": 1, + "@content": "Content 3" + }); +} catch (ex) { + console.warn(ex); +} + +// A simple SELECT query. +var selectRecordStatement = + "SELECT * FROM test_table WHERE id = @id;" +var selectStatementObject = db.prepare(selectRecordStatement); +var results = selectStatementObject.get({ + "@id": 1 +}); +console.log(results); +selectStatementObject.free(); + +// Access the results one by one, asynchronously. +var selectRecordsStatement = + "SELECT * FROM test_table;"; +db.each( + selectRecordsStatement, + (obj: SQL.SQLValueObject): void => { + console.log(obj); + }, + (): void => { + console.info("Iteration done."); + dbAccessDone(); + }); + + +function dbAccessDone(): void { + // Save the database into SQLite version 3 format. + if (!fs.existsSync(DB_PATH)) { + createFile(DB_PATH); + } + var exportedData = db.export(); + fs.writeFileSync(DB_PATH, exportedData); + + // Finally, close the database connection and release the resources in memory. + db.close(); +} diff --git a/sql.js/sql.js.d.ts b/sql.js/sql.js.d.ts new file mode 100644 index 0000000000..5f2ddd0691 --- /dev/null +++ b/sql.js/sql.js.d.ts @@ -0,0 +1,71 @@ + +// Type definitions for sql.js (Sep. 6 2015 snapshot) +// Project: https://github.com/kripken/sql.js +// Definitions by: George Wu +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "sql.js" { + + type SQLValue = number | string | Uint8Array; + type KeyValueObject = { [key: string]: SQLValue }; + type SQLValueObject = { [columnName: string]: SQLValue }; + type DataRow = SQLValue[]; + + class Database { + constructor(data: Buffer); + constructor(data: Uint8Array); + constructor(data: number[]); + + run(sql: string): Database; + run(sql: string, params: KeyValueObject): Database; + run(sql: string, params: SQLValue[]): Database; + + exec(sql: string): QueryResults[]; + + each(sql: string, callback: (obj: SQLValueObject) => void, done: () => void): void; + each(sql: string, params: KeyValueObject, callback: (obj: SQLValueObject) => void, done: () => void): void; + each(sql: string, params: SQLValue[], callback: (obj: SQLValueObject) => void, done: () => void): void; + + prepare(sql: string): Statement; + prepare(sql: string, params: KeyValueObject): Statement; + prepare(sql: string, params: SQLValue[]): Statement; + + export(): Uint8Array; + + close(): void; + } + + class Statement { + bind(): boolean; + bind(values: KeyValueObject): boolean; + bind(values: SQLValue[]): boolean; + + step(): boolean; + + get(): DataRow; + get(params: KeyValueObject): DataRow; + get(params: SQLValue[]): DataRow; + + getColumnNames(): string[]; + + getAsObject(): SQLValueObject; + getAsObject(params: KeyValueObject): SQLValueObject; + getAsObject(params: SQLValue[]): SQLValueObject; + + run(): void; + run(values: KeyValueObject): void; + run(values: SQLValue[]): void; + + reset(): void; + + freemem(): void; + + free(): boolean; + } + + interface QueryResults { + columns: string[]; + values: DataRow[]; + } + +} From 98339951b7a45fe9679a83777d61bad70a037976 Mon Sep 17 00:00:00 2001 From: George Wu Date: Fri, 11 Dec 2015 22:09:48 +0800 Subject: [PATCH 29/66] Renewed code to follow DefinitelyTyped's contribution guidelines. --- sql.js/sql.js-tests.ts | 2 +- sql.js/sql.js.d.ts | 46 +++++++++++++++++++----------------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/sql.js/sql.js-tests.ts b/sql.js/sql.js-tests.ts index eeba3f0809..40fceb8fbd 100644 --- a/sql.js/sql.js-tests.ts +++ b/sql.js/sql.js-tests.ts @@ -59,7 +59,7 @@ var selectRecordsStatement = "SELECT * FROM test_table;"; db.each( selectRecordsStatement, - (obj: SQL.SQLValueObject): void => { + (obj: { [columnName: string]: number | string | Uint8Array }): void => { console.log(obj); }, (): void => { diff --git a/sql.js/sql.js.d.ts b/sql.js/sql.js.d.ts index 5f2ddd0691..d3f22afc1f 100644 --- a/sql.js/sql.js.d.ts +++ b/sql.js/sql.js.d.ts @@ -1,15 +1,11 @@ - -// Type definitions for sql.js (Sep. 6 2015 snapshot) +// Type definitions for sql.js // Project: https://github.com/kripken/sql.js // Definitions by: George Wu // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module "sql.js" { +/// - type SQLValue = number | string | Uint8Array; - type KeyValueObject = { [key: string]: SQLValue }; - type SQLValueObject = { [columnName: string]: SQLValue }; - type DataRow = SQLValue[]; +declare module "sql.js" { class Database { constructor(data: Buffer); @@ -17,18 +13,18 @@ declare module "sql.js" { constructor(data: number[]); run(sql: string): Database; - run(sql: string, params: KeyValueObject): Database; - run(sql: string, params: SQLValue[]): Database; + run(sql: string, params: { [key: string]: number | string | Uint8Array }): Database; + run(sql: string, params: (number | string | Uint8Array)[]): Database; exec(sql: string): QueryResults[]; - each(sql: string, callback: (obj: SQLValueObject) => void, done: () => void): void; - each(sql: string, params: KeyValueObject, callback: (obj: SQLValueObject) => void, done: () => void): void; - each(sql: string, params: SQLValue[], callback: (obj: SQLValueObject) => void, done: () => void): void; + each(sql: string, callback: (obj: { [columnName: string]: number | string | Uint8Array }) => void, done: () => void): void; + each(sql: string, params: { [key: string]: number | string | Uint8Array }, callback: (obj: { [columnName: string]: number | string | Uint8Array }) => void, done: () => void): void; + each(sql: string, params: (number | string | Uint8Array)[], callback: (obj: { [columnName: string]: number | string | Uint8Array }) => void, done: () => void): void; prepare(sql: string): Statement; - prepare(sql: string, params: KeyValueObject): Statement; - prepare(sql: string, params: SQLValue[]): Statement; + prepare(sql: string, params: { [key: string]: number | string | Uint8Array }): Statement; + prepare(sql: string, params: (number | string | Uint8Array)[]): Statement; export(): Uint8Array; @@ -37,24 +33,24 @@ declare module "sql.js" { class Statement { bind(): boolean; - bind(values: KeyValueObject): boolean; - bind(values: SQLValue[]): boolean; + bind(values: { [key: string]: number | string | Uint8Array }): boolean; + bind(values: (number | string | Uint8Array)[]): boolean; step(): boolean; - get(): DataRow; - get(params: KeyValueObject): DataRow; - get(params: SQLValue[]): DataRow; + get(): (number | string | Uint8Array)[]; + get(params: { [key: string]: number | string | Uint8Array }): (number | string | Uint8Array)[]; + get(params: (number | string | Uint8Array)[]): (number | string | Uint8Array)[]; getColumnNames(): string[]; - getAsObject(): SQLValueObject; - getAsObject(params: KeyValueObject): SQLValueObject; - getAsObject(params: SQLValue[]): SQLValueObject; + getAsObject(): { [columnName: string]: number | string | Uint8Array }; + getAsObject(params: { [key: string]: number | string | Uint8Array }): { [columnName: string]: number | string | Uint8Array }; + getAsObject(params: (number | string | Uint8Array)[]): { [columnName: string]: number | string | Uint8Array }; run(): void; - run(values: KeyValueObject): void; - run(values: SQLValue[]): void; + run(values: { [key: string]: number | string | Uint8Array }): void; + run(values: (number | string | Uint8Array)[]): void; reset(): void; @@ -65,7 +61,7 @@ declare module "sql.js" { interface QueryResults { columns: string[]; - values: DataRow[]; + values: (number | string | Uint8Array)[][]; } } From bd1d3d2e0bf4a16d9d0aa3fee767b1d3658dc801 Mon Sep 17 00:00:00 2001 From: stephenjelfs Date: Fri, 11 Dec 2015 17:45:26 +0100 Subject: [PATCH 30/66] Initial definitions for react-datagrid. --- react-datagrid/react-datagrid-test.tsx | 82 +++++++ react-datagrid/react-datagrid.d.ts | 310 +++++++++++++++++++++++++ 2 files changed, 392 insertions(+) create mode 100644 react-datagrid/react-datagrid-test.tsx create mode 100644 react-datagrid/react-datagrid.d.ts diff --git a/react-datagrid/react-datagrid-test.tsx b/react-datagrid/react-datagrid-test.tsx new file mode 100644 index 0000000000..c0ca90a1a9 --- /dev/null +++ b/react-datagrid/react-datagrid-test.tsx @@ -0,0 +1,82 @@ +/// +/// +/// + +import * as React from "react"; +import ReactDataGrid = require("react-datagrid"); + +var data: any[] = []; + +var columns: ReactDataGrid.Column[] = [ + { name: 'index', title: '#', width: 50 }, + { name: 'firstName', style: { color: 'red' }, visible: true}, + { name: 'lastName', render: (v) => {return v + " Phd"}}, + { name: 'city', textAlign: 'right', defaultVisible: true}, + { name: 'email', defaultHidden: true } +]; +var selected = {}; +var sortInfo: ReactDataGrid.SortInfo[] = [ { name: 'country', dir: 'asc'}] + +export module X { +export class ExampleBasic extends React.Component<{},{}> { + render(): React.ReactElement { + return ( + + ); + } +} +} + +class ExampleFull extends React.Component<{},{}> { + + render(): React.ReactElement { + return ( + {}} + onPageSizeChange={(pageSize: number, props: ReactDataGrid.DataGridProps) => {}} + onColumnOrderChange={(index: number, dropIndex: number) => {}} + onColumnResize={(firstCol: ReactDataGrid.Column, firstSize: number, secondCol: ReactDataGrid.Column, secondSize: number) => {}} + onSelectionChange={(newSelectedId: string, data: any) => {}} + onSortChange={(sortInfo: ReactDataGrid.SortInfo[]) => {}} + onFilter={(column: ReactDataGrid.Column, value: any, allFilterValues: any[]) => {} } + /> + ); + } +} diff --git a/react-datagrid/react-datagrid.d.ts b/react-datagrid/react-datagrid.d.ts new file mode 100644 index 0000000000..aca7d355e1 --- /dev/null +++ b/react-datagrid/react-datagrid.d.ts @@ -0,0 +1,310 @@ +// Type definitions for react-datagrid 1.2.15 +// Project: https://github.com/zippyui/react-datagrid.git +// Definitions by: Stephen Jelfs +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "react-datagrid" { + import DataGrid = ReactDataGrid.DataGrid; + export = DataGrid; +} + +declare namespace ReactDataGrid { + import React = __React; + + interface DataGridProps extends React.Props { + /** + * Array/String/Function/Promise - for local data, an array of object + * to render in the grid. For remote data, a string url, or a function + * that returns a promise. + */ + dataSource: any[] | string | ((query: {pageSize: number, skip: number}) => Promise); + + dataSourceCount?: number; + + /** + * String - the name of the property where the id is found for each + * object in the data array. + */ + idProperty: string; + + /** + * Array - an array of columns that are going to be rendered in the + * grid. + */ + columns: Column[]; + + /** + * Sorting the data array is not done by the grid. You can however + * pass in sort info so the grid renders with sorting icons as needed. + */ + onSortChange?: (sortInfo: SortInfo[]) => void; + + /** + * Array - an array with sorting information. + */ + sortInfo?: SortInfo[]; + + style?: __React.CSSProperties; + + /** + * Object/Function - you can specify either a style object to be + * applied to all rows, or a function. The function is called with + * (data, props) (so you have access to props.index for example) and + * is expected to return a style object. + */ + rowStyle?: __React.CSSProperties | ((data: any, props: RowProps) => React.CSSProperties); + + /** + * Boolean - show a column menu to show/hide columns. + */ + withColumnMenu?: boolean; + + /** + * If you want to enable column reordering, just specify the + * onColumnOrderChange prop on the grid: + */ + onColumnOrderChange?: (index: number, dropIndex: number) => void; + + /** + * If you want to enable column resized, just specify the + * onColumnResize prop on the grid: + */ + onColumnResize?: (firstCol: Column, firstSize: number, + secondCol: Column, secondSize: number) => void; + + /** + * If you want to enable selection, just specify the + * onSelectionChange prop on the grid: + */ + onSelectionChange?: (newSelected: {}, data: any) => void; + + /** + * When a column is shown/hidden, you can be notified using the + * onColumnVisibilityChange callback prop. + */ + onColumnVisibilityChange?: (column: Column, visibility: boolean) => void; + + /** + * The current selection. + */ + selected?: {}; + + /** + * Group rows by matching values. + */ + groupBy?: any[]; + + /** + * If you want to enable filter, just specify the + * onFilter prop on the grid: + */ + onFilter?: (column: Column, value: any, allFilterValues: any[]) => void; + + /** + * To apply the filter while typing. + */ + liveFilter?: boolean; + + /** + * Empty text for no records. + */ + emptyText?: string; + + /** + * Loading grid. + */ + loading?: boolean; + + /** + * If you dont want loadMask over header, specify + */ + loadMaskOverHeader?: boolean; + + /** + * Show cell borders. Other valid values: 'horizontal', 'vertical'. + */ + showCellBorders?: boolean | string; + + /** + * Custom row height. + */ + rowHeight?: number; + + /** + * When you have remote data, pagination is setup by default. If you + * want to disable pagination, specify the pagination prop with a false + * value. + */ + pagination?: boolean; + defaultPageSize?: number; + defaultPage?: number; + + /** + * Number - controlled alternative for defaultPageSize. When pageSize + * changes, onPageSizeChange(pageSize) is called. + */ + pageSize?: number; + + /** + * Number - controlled alternative for defaultPage. When page changes, + * onPageChange(page) is called. + */ + page?: number; + + /** + * Customize the pagination toolbar. + */ + paginationToolbarProps?: PaginationToolbarProps; + + /** + * handle page changes. + */ + onPageChange?: (page: number) => void; + + /** + * handle page size changes. + */ + onPageSizeChange?: (pageSize: number, props: DataGridProps) => void; + } + + interface SortInfo { + name: string; + dir: string; + } + + interface Column { + /** + * String - each column should have a name property. + */ + name: string; + + /** + * String/ReactElement - a title to show in the header. If not + * specified, a humanized version of name will be used. Can be a string + * or anything that React can render, so you can customize it as you + * please. + */ + title?: string | React.ReactElement; + + /** + * Function - if you want custom rendering, specify this property. + * + * The column.render function is called with 3 args: + * value - the default value to be rendered (equals to data[column.name]) + * data - the corresponding data object for the current row + cellProps - an object with props for the current cell + */ + render?: (value: any, data: any, cellProps: CellProps) => any; + + /** + * Object - if you want cells in this column to be have a custom + * style. + */ + style?: __React.CSSProperties; + + /** + * String - one of 'left', 'right', 'center'. + */ + textAlign?: string; + + /** + * String - a className to be applied to all cells in this column + */ + className?: string; + + width?: number; + + minWidth?: number; + + /** + * Columns are flexible via flexbox. Specify a flex property for this. + * Unless a column specifies a flex or a width property, it is assumed + * to have flex: 1. + */ + flex?: number; + + /** + * Specify a column as visible/hidden. + */ + defaultVisible?: boolean; + defaultHidden?: boolean; + + /** + * Boolean - controlled (which means you have to manually set column + * visibility when it changes, by using onColumnVisibilityChange). + */ + visible?: boolean; + } + + interface CellProps { + /** + * the index of the row + */ + rowIndex: number; + + /** + * the index of the column + */ + index: number; + + /** + * a style for the cell + */ + style: React.CSSProperties; + + /** + * a class name for the cell + */ + className: string; + } + + interface RowProps { + /** + * the index of the row + */ + index: number; + + /** + * a class name for the row when the mouse is over it + */ + overClassName: string; + + /** + * a class name for the row when selected + */ + selectedClassName: string; + + /** + * a class name for the row + */ + className: string; + } + + interface PaginationToolbarProps { + /** + * Available page sizes. + */ + pageSizes: number[]; + + /** + * Hide/show page sizes. + */ + showPageSize: boolean; + + /** + * Customize icons. + */ + showRefreshIcon: boolean; + iconSize: number; + iconProps: { + style: React.SVGAttributes, + overStyle: React.SVGAttributes, + disabledStyle: React.SVGAttributes + } + } + + export class DataGrid extends __React.Component { + } +} From d065f93bab68ae7be4625c3b2847e601b2311505 Mon Sep 17 00:00:00 2001 From: stephenjelfs Date: Fri, 11 Dec 2015 17:58:28 +0100 Subject: [PATCH 31/66] Added missing promises --- react-datagrid/react-datagrid.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/react-datagrid/react-datagrid.d.ts b/react-datagrid/react-datagrid.d.ts index aca7d355e1..1dc5d83616 100644 --- a/react-datagrid/react-datagrid.d.ts +++ b/react-datagrid/react-datagrid.d.ts @@ -4,6 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// declare module "react-datagrid" { import DataGrid = ReactDataGrid.DataGrid; From 55f9ccc901fbb3c42c8afd2d2bcc2ca864054062 Mon Sep 17 00:00:00 2001 From: stephenjelfs Date: Fri, 11 Dec 2015 18:07:34 +0100 Subject: [PATCH 32/66] Renamed tests file. --- .../{react-datagrid-test.tsx => react-datagrid-tests.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename react-datagrid/{react-datagrid-test.tsx => react-datagrid-tests.tsx} (100%) diff --git a/react-datagrid/react-datagrid-test.tsx b/react-datagrid/react-datagrid-tests.tsx similarity index 100% rename from react-datagrid/react-datagrid-test.tsx rename to react-datagrid/react-datagrid-tests.tsx From fc18b2dfd426eaf96ce4ca0f003d23656b952da6 Mon Sep 17 00:00:00 2001 From: Stefan Geneshky Date: Fri, 11 Dec 2015 10:14:44 -0800 Subject: [PATCH 33/66] Update Mithril definitions --- mithril/mithril.d.ts | 250 +++++++++++++++++++++++++++++-------------- 1 file changed, 167 insertions(+), 83 deletions(-) diff --git a/mithril/mithril.d.ts b/mithril/mithril.d.ts index 3cd0e21e49..c2304e7ece 100644 --- a/mithril/mithril.d.ts +++ b/mithril/mithril.d.ts @@ -5,90 +5,174 @@ //Mithril type definitions for Typescript -interface MithrilStatic { - (selector: string, attributes: Object, children?: any): MithrilVirtualElement; - (selector: string, children?: any): MithrilVirtualElement; - prop(value?: T): (value?: T) => T; - prop(promise: MithrilPromise): MithrilPromiseProperty; - withAttr(property: string, callback: (value: any) => void): (e: Event) => any; - module(rootElement: Node, module: MithrilModule): void; - trust(html: string): String; - render(rootElement: Element, children?: any): void; - render(rootElement: HTMLDocument, children?: any): void; - redraw: MithrilRedraw; - route: MithrilRoute; - request(options: MithrilXHROptions): MithrilPromise; - deferred(): MithrilDeferred; - sync(promises: MithrilPromise[]): MithrilPromise; - startComputation(): void; - endComputation(): void; +declare module _mithril { + interface MithrilStatic { + + (selector: string, attributes: MithrilAttributes, ...children: Array>): MithrilVirtualElement; + (selector: string, ...children: Array>): MithrilVirtualElement; + + prop(promise: MithrilPromise) : MithrilPromiseProperty; + prop(value: T): MithrilProperty; + prop(): MithrilProperty; // might be that this should be Property + + withAttr(property: string, callback: (value: any) => void): (e: MithrilEvent) => any; + + module(rootElement: Node, component: MithrilComponent): T; + module(rootElement: Node): T; + mount(rootElement: Node, component: MithrilComponent): T; + mount(rootElement: Node): T; + + component(component: MithrilComponent, ...args: Array): MithrilComponent + + trust(html: string): string; + + render(rootElement: Element|HTMLDocument): void; + render(rootElement: Element|HTMLDocument, children: MithrilVirtualElement, forceRecreation?: boolean): void; + render(rootElement: Element|HTMLDocument, children: MithrilVirtualElement[], forceRecreation?: boolean): void; + + redraw: { + (force?: boolean): void; + strategy: MithrilProperty; + } + + route: { + (rootElement: HTMLDocument, defaultRoute: string, routes: MithrilRoutes): void; + (rootElement: Element, defaultRoute: string, routes: MithrilRoutes): void; + + (element: Element, isInitialized: boolean, context: Object, vdom: Object): void; + (path: string, params?: any, shouldReplaceHistory?: boolean): void; + (): string; + + param(key: string): string; + mode: string; + buildQueryString(data: Object): String + parseQueryString(data: String): Object + } + + request(options: MithrilXHROptions): MithrilPromise; + + deferred: { + onerror(e: Error): void; + (): MithrilDeferred; + } + + sync(promises: MithrilPromise[]): MithrilPromise; + + startComputation(): void; + endComputation(): void; + + // For test suite + deps: { + (mockWindow: Window): Window; + factory: Object; + } + + } + + export interface MithrilVirtualElement { + key?: number; + tag?: string; + attrs?: MithrilAttributes; + children?: any[]; + } + + // Configuration function for an element + interface MithrilElementConfig { + (element: Element, isInitialized: boolean, context?: any, vdom?: MithrilVirtualElement): void; + } + + // Attributes on a virtual element + interface MithrilAttributes { + title?: string; + className?: string; + class?: string; + config?: MithrilElementConfig; + } + + // Defines the subset of Event that Mithril needs + interface MithrilEvent { + currentTarget: Element; + } + + interface MithrilController { + onunload?(evt: Event): any; + } + + interface MithrilControllerFunction extends MithrilController { + (): any; + } + + interface MithrilView { + (ctrl: T): string|MithrilVirtualElement; + } + + interface MithrilComponent { + controller: MithrilControllerFunction|{ new(): T }; + view: MithrilView; + } + + interface MithrilProperty { + (): T; + (value: T): T; + toJSON(): T; + } + + interface MithrilPromiseProperty extends MithrilPromise { + (): T; + (value: T): T; + toJSON(): T; + } + + interface MithrilRoutes { + [key: string]: MithrilComponent; + } + + + interface MithrilDeferred { + resolve(value?: T): void; + reject(value?: any): void; + promise: MithrilPromise; + } + + interface MithrilSuccessCallback { + (value: T): U; + (value: T): MithrilPromise; + } + + interface MithrilErrorCallback { + (value: Error): U; + (value: string): U; + } + + interface MithrilPromise { + (): T; + (value: T): T; + then(success: (value: T) => U): MithrilPromise; + then(success: (value: T) => MithrilPromise): MithrilPromise; + then(success: (value: T) => U, error: (value: Error) => V): MithrilPromise|MithrilPromise; + then(success: (value: T) => MithrilPromise, error: (value: Error) => V): MithrilPromise|MithrilPromise; + } + interface MithrilXHROptions { + method?: string; + url: string; + user?: string; + password?: string; + data?: any; + background?: boolean; + unwrapSuccess?(data: any): any; + unwrapError?(data: any): any; + serialize?(dataToSerialize: any): string; + deserialize?(dataToDeserialize: string): any; + extract?(xhr: XMLHttpRequest, options: MithrilXHROptions): string; + type?(data: Object): void; + config?(xhr: XMLHttpRequest, options: MithrilXHROptions): XMLHttpRequest; + dataType?: string; + } } -interface MithrilRoute { - (rootElement: Element, defaultRoute: string, routes: { [key: string]: MithrilModule }): void; - (rootElement: HTMLDocument, defaultRoute: string, routes: { [key: string]: MithrilModule }): void; - (path: string, params?: any, shouldReplaceHistory?: boolean): void; - (element: Element, isInitialized: boolean): void; - (): string; - mode: string; - param: MithrilParam; - buildQueryString(data: Object): string; - parseQueryString(queryString: string): Object; -} +declare var Mithril: _mithril.MithrilStatic; +declare var m: _mithril.MithrilStatic; -interface MithrilParam { - (param: string): string; +declare module "mithril" { + export = m; } - -interface MithrilRedraw { - (): void; - strategy: (value?: string) => string; -} - -interface MithrilVirtualElement { - tag: string; - attrs: Object; - children: any; -} - -interface MithrilModule { - controller: Function; - view: (controller?: any) => MithrilVirtualElement; -} - -interface MithrilDeferred { - resolve(value?: T): void; - reject(value?: any): void; - promise: MithrilPromise; -} - -interface MithrilPromise { - (value?: T): T; - then(successCallback?: (value: T) => R, errorCallback?: (value: any) => any): MithrilPromise; - then(successCallback?: (value: T) => MithrilPromise, errorCallback?: (value: any) => any): MithrilPromise; -} - -interface MithrilPromiseProperty extends MithrilPromise { - (): T; - (value: T): T; - toJSON(): T; -} - -interface MithrilXHROptions { - method: string; - url: string; - user?: string; - password?: string; - data?: any; - background?: boolean; - unwrapSuccess?(data: any): any; - unwrapError?(data: any): any; - serialize?(dataToSerialize: any): string; - deserialize?(dataToDeserialize: string): any; - extract?(xhr: XMLHttpRequest, options: MithrilXHROptions): string; - type?(data: Object): void; - config?(xhr: XMLHttpRequest, options: MithrilXHROptions): XMLHttpRequest; -} - -declare var Mithril: MithrilStatic; -declare var m: MithrilStatic; From 208be8144e834ae82881ab9414c57c6fcd5ef11c Mon Sep 17 00:00:00 2001 From: Dan Marshall Date: Fri, 11 Dec 2015 10:23:13 -0800 Subject: [PATCH 34/66] added optional rendering type --- fullCalendar/fullCalendar.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/fullCalendar/fullCalendar.d.ts b/fullCalendar/fullCalendar.d.ts index 6400dba7e0..7415bdd73c 100644 --- a/fullCalendar/fullCalendar.d.ts +++ b/fullCalendar/fullCalendar.d.ts @@ -247,6 +247,7 @@ declare module FullCalendar { backgroundColor?: string; borderColor?: string; textColor?: string; + rendering?: string; } export interface ViewObject extends Timespan { From f3eeb32d711a1985cec596acb9424bcd827fe2a0 Mon Sep 17 00:00:00 2001 From: Mark Nadig Date: Fri, 11 Dec 2015 10:55:03 -0700 Subject: [PATCH 35/66] ng-dialog add IDialogOptions.disableAnimation, IDialogOpenOptions.data and upadated test --- ng-dialog/ng-dialog-tests.ts | 2 ++ ng-dialog/ng-dialog.d.ts | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/ng-dialog/ng-dialog-tests.ts b/ng-dialog/ng-dialog-tests.ts index 6d68111a6d..27f50f89c9 100644 --- a/ng-dialog/ng-dialog-tests.ts +++ b/ng-dialog/ng-dialog-tests.ts @@ -20,6 +20,8 @@ class DialogTestController { template: "login.html", className: "default flat-ui", closeByEscape: false, + data: "string", + disableAnimation: false, name: "login-popup" }); diff --git a/ng-dialog/ng-dialog.d.ts b/ng-dialog/ng-dialog.d.ts index 3ad5c4d09a..95f02af632 100644 --- a/ng-dialog/ng-dialog.d.ts +++ b/ng-dialog/ng-dialog.d.ts @@ -61,6 +61,12 @@ declare module angular.dialog { * It will be appended with the "ngdialog" class e.g. className is "default-theme flat-ui" it will be class="ngdialog default-theme flat-ui". */ className?: string; + + /** + * If true then animation for the dialog will be disabled, default false. + */ + disableAnimation?: boolean; + /** * If false it allows to hide overlay div behind the modals, default true. */ @@ -106,5 +112,9 @@ declare module angular.dialog { * Scope object that will be passed to dialog. If you use controller with separate $scope service this object will be passed to $scope.$parent param. */ scope?: ng.IScope; + /** + * Any serializable data that you want to be stored in the controller's dialog scope. + */ + data?: string|Object|any[]; } } From c3dce5b44d8ee3ac1cdc6e074626acc5fb8ce79c Mon Sep 17 00:00:00 2001 From: Kaur Kuut Date: Sat, 12 Dec 2015 15:51:42 +0200 Subject: [PATCH 36/66] Restored jsSHA browser global definition & test. --- jssha/jssha-tests.ts | 7 +++++++ jssha/jssha.d.ts | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/jssha/jssha-tests.ts b/jssha/jssha-tests.ts index f6e0f96b48..e5a83b14a8 100644 --- a/jssha/jssha-tests.ts +++ b/jssha/jssha-tests.ts @@ -46,4 +46,11 @@ let hmac5:string = shaObj1.getHMAC("HEX", { outputUpper: true, b64Pad: '=' }); shaObj.setHMACKey("abc", "TEXT"); shaObj.update("This is a test"); let hmac = shaObj.getHMAC("HEX"); +} + +// Browser global test +{ + var shaObj = new jsSHA("SHA-512", "TEXT"); + shaObj.update("This is a test"); + var hash = shaObj.getHash("HEX"); } \ No newline at end of file diff --git a/jssha/jssha.d.ts b/jssha/jssha.d.ts index 6dc4f65d3e..f695a66700 100644 --- a/jssha/jssha.d.ts +++ b/jssha/jssha.d.ts @@ -79,7 +79,7 @@ declare module jsSHA { } } +declare var jsSHA: jsSHA.jsSHA; declare module 'jssha' { - var jsSHA: jsSHA.jsSHA; export = jsSHA; -} \ No newline at end of file +} From 5b5bfbec4c121532ac5754e742797ed3eb9fe6da Mon Sep 17 00:00:00 2001 From: abraaoalves Date: Sat, 12 Dec 2015 10:54:06 -0300 Subject: [PATCH 37/66] definitions to steps and hooks --- cucumber/cucumber-tests.ts | 40 ++++++++++++++++++++++++++ cucumber/cucumber.d.ts | 57 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 cucumber/cucumber-tests.ts create mode 100644 cucumber/cucumber.d.ts diff --git a/cucumber/cucumber-tests.ts b/cucumber/cucumber-tests.ts new file mode 100644 index 0000000000..ba7ff1f72e --- /dev/null +++ b/cucumber/cucumber-tests.ts @@ -0,0 +1,40 @@ +/// + +function StepSample() { + type Callback = cucumber.CallbackStepDefinition; + var step = this; + var hook = this; + + hook.Before(function(scenario, callback){ + scenario.isFailed() && callback.pending(); + }) + + hook.Around(function(scenario, runScenario) { + scenario.isFailed() && runScenario(null, function(){ + console.log('finish tasks'); + }); + }); + + hook.registerHandler('AfterFeatures', function (event, callback) { + callback(); + }); + + step.Given(/^I am on the Cucumber.js GitHub repository$/, function(callback) { + this.visit('https://github.com/cucumber/cucumber-js', callback); + }); + + step.When(/^I go to the README file$/, function(title:string, callback:Callback) { + callback.pending(); + }); + + step.Then(/^I should see "(.*)" as the page title$/, { timeout:60*1000}, function(title:string, callback) { + var pageTitle = this.browser.text('title'); + + if (title === pageTitle) { + callback(); + } else { + callback(new Error("Expected to be on page with title " + title)); + } + }); +} + diff --git a/cucumber/cucumber.d.ts b/cucumber/cucumber.d.ts new file mode 100644 index 0000000000..b70fbb6b46 --- /dev/null +++ b/cucumber/cucumber.d.ts @@ -0,0 +1,57 @@ +// Type definitions for cucumber-js +// Project: https://github.com/cucumber/cucumber-js +// Definitions by: Abraão Alves +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module cucumber { + + export interface CallbackStepDefinition{ + pending : () => Thenable; + (errror?:any):void; + } + + interface StepDefinitionCode { + (...stepArgs: Array): Thenable | any | void; + } + + interface StepDefinitionOptions{ + timeout?: number; + } + + export interface StepDefinitions { + Given(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; + Given(pattern: RegExp | string, code: StepDefinitionCode): void; + When(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; + When(pattern: RegExp | string, code: StepDefinitionCode): void; + Then(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void; + Then(pattern: RegExp | string, code: StepDefinitionCode): void; + setDefaultTimeout(time:number): void; + } + + interface HookScenario{ + attach(text: string, mimeType?: string, callback?: (err?) => void): void; + isFailed() : boolean; + } + + interface HookCode { + (scenario: HookScenario, callback?: CallbackStepDefinition): void; + } + + interface AroundCode{ + (scenario: HookScenario, runScenario?: (error:string, callback?:Function)=>void): void; + } + + export interface Hooks { + Before(code: HookCode): void; + After(code: HookCode): void; + Around(code: AroundCode):void; + setDefaultTimeout(time:number): void; + registerHandler(handlerOption:string, code:(event, callback:CallbackStepDefinition) =>void): void; + } +} + +declare module 'cucumber'{ + export = cucumber; +} \ No newline at end of file From 0bcb4658eca981568d5cce48fd4b370c8778cbd6 Mon Sep 17 00:00:00 2001 From: abraaoalves Date: Sat, 12 Dec 2015 11:24:19 -0300 Subject: [PATCH 38/66] fix noimplicitAny errors --- cucumber/cucumber-tests.ts | 6 +++--- cucumber/cucumber.d.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cucumber/cucumber-tests.ts b/cucumber/cucumber-tests.ts index ba7ff1f72e..f8b5606070 100644 --- a/cucumber/cucumber-tests.ts +++ b/cucumber/cucumber-tests.ts @@ -1,4 +1,4 @@ -/// +/// function StepSample() { type Callback = cucumber.CallbackStepDefinition; @@ -19,7 +19,7 @@ function StepSample() { callback(); }); - step.Given(/^I am on the Cucumber.js GitHub repository$/, function(callback) { + step.Given(/^I am on the Cucumber.js GitHub repository$/, function(callback:Callback) { this.visit('https://github.com/cucumber/cucumber-js', callback); }); @@ -27,7 +27,7 @@ function StepSample() { callback.pending(); }); - step.Then(/^I should see "(.*)" as the page title$/, { timeout:60*1000}, function(title:string, callback) { + step.Then(/^I should see "(.*)" as the page title$/, { timeout:60*1000}, function(title:string, callback:Callback) { var pageTitle = this.browser.text('title'); if (title === pageTitle) { diff --git a/cucumber/cucumber.d.ts b/cucumber/cucumber.d.ts index b70fbb6b46..75faeff7a5 100644 --- a/cucumber/cucumber.d.ts +++ b/cucumber/cucumber.d.ts @@ -31,7 +31,7 @@ declare module cucumber { } interface HookScenario{ - attach(text: string, mimeType?: string, callback?: (err?) => void): void; + attach(text: string, mimeType?: string, callback?: (err?:any) => void): void; isFailed() : boolean; } @@ -48,7 +48,7 @@ declare module cucumber { After(code: HookCode): void; Around(code: AroundCode):void; setDefaultTimeout(time:number): void; - registerHandler(handlerOption:string, code:(event, callback:CallbackStepDefinition) =>void): void; + registerHandler(handlerOption:string, code:(event:any, callback:CallbackStepDefinition) =>void): void; } } From 0bb3a46b8baea5eb91e50560fc5cfd4b5895e1ba Mon Sep 17 00:00:00 2001 From: phiresky Date: Sat, 12 Dec 2015 15:58:14 +0100 Subject: [PATCH 39/66] wu: fix project link --- wu/wu.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wu/wu.d.ts b/wu/wu.d.ts index 61a0e6e97c..cb794ff300 100644 --- a/wu/wu.d.ts +++ b/wu/wu.d.ts @@ -1,5 +1,5 @@ // Type definitions for wu.js v2.1.0 -// Project: http://backbonejs.org/ +// Project: https://fitzgen.github.io/wu.js/ // Definitions by: phiresky // Definitions: https://github.com/borisyankov/DefinitelyTyped From e2309e6ed913f2733eb8f6af1d56d22a93d0a6e3 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sat, 12 Dec 2015 22:32:14 +0500 Subject: [PATCH 40/66] lodash: signatures of _.isFunction have been changed --- lodash/lodash-tests.ts | 39 ++++++++++++++++++++++++++++----------- lodash/lodash.d.ts | 10 +++++++++- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2d244b16e5..9cf772cab4 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5532,17 +5532,34 @@ result = _([]).isFinite(); result = _({}).isFinite(); // _.isFunction -result = _.isFunction(any); -result = _(1).isFunction(); -result = _([]).isFunction(); -result = _({}).isFunction(); -{ - let value: Function|string = "foo"; - if (_.isFunction(value)) { - value(); - } else { - let result: string = value; - } +module TestIsFunction { + { + let value: number|Function; + + if (_.isFunction(value)) { + let result: Function = value; + } + else { + let result: number = value; + } + } + + { + let result: boolean; + + result = _.isFunction(any); + result = _(1).isFunction(); + result = _([]).isFunction(); + result = _({}).isFunction(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().isFunction(); + result = _([]).chain().isFunction(); + result = _({}).chain().isFunction(); + } } // _.isMatch diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 8425f1d823..81d78b1bcf 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9434,9 +9434,10 @@ declare module _ { interface LoDashStatic { /** * Checks if value is classified as a Function object. + * * @param value The value to check. * @return Returns true if value is correctly classified, else false. - **/ + */ isFunction(value?: any): value is Function; } @@ -9447,6 +9448,13 @@ declare module _ { isFunction(): boolean; } + interface LoDashExplicitWrapperBase { + /** + * @see _.isFunction + */ + isFunction(): LoDashExplicitWrapper; + } + //_.isMatch interface isMatchCustomizer { (value: any, other: any, indexOrKey?: number|string): boolean; From bba4c44ba25d6feb40fa100525bc76db9d3d33c0 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Sat, 12 Dec 2015 20:08:50 +0100 Subject: [PATCH 41/66] deleted definitions to split PR --- gulp-jade/gulp-jade-tests.ts | 25 ------------------------- gulp-jade/gulp-jade.d.ts | 24 ------------------------ 2 files changed, 49 deletions(-) delete mode 100644 gulp-jade/gulp-jade-tests.ts delete mode 100644 gulp-jade/gulp-jade.d.ts diff --git a/gulp-jade/gulp-jade-tests.ts b/gulp-jade/gulp-jade-tests.ts deleted file mode 100644 index 7334afc838..0000000000 --- a/gulp-jade/gulp-jade-tests.ts +++ /dev/null @@ -1,25 +0,0 @@ -/// -/// -/// - -import gulp = require("gulp"); -import jade = require("gulp-jade"); - - -gulp.task('check1', function() { - gulp.src('lib/*.jade') - .pipe(jade({ - locals: {}, - client: false - })); -}); - -import jadeLib = require('jade'); - -gulp.task('check2', function() { - gulp.src('lib/*.jade') - .pipe(jade({ - jade: jadeLib, - pretty: true - })); -}); \ No newline at end of file diff --git a/gulp-jade/gulp-jade.d.ts b/gulp-jade/gulp-jade.d.ts deleted file mode 100644 index 2f31889c22..0000000000 --- a/gulp-jade/gulp-jade.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Type definitions for gulp-jade -// Project: https://github.com/phated/gulp-jade -// Definitions by: Louis Grignon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module "gulp-jade" { - function GulpJade(options?: GulpJadeOptions): NodeJS.ReadWriteStream; - - interface GulpJadeOptions { - client?: boolean; - - locals?: Object; - - jade?: any; - - pretty?: boolean; - } - - namespace GulpJade { - } - export = GulpJade; -} From e3b69d13c85ebf92f9a721073376f87c6af74e46 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Sat, 12 Dec 2015 20:16:50 +0100 Subject: [PATCH 42/66] deleted files to split PR --- .../backbone.localstorage.d.ts | 51 -------- gulp-jshint/gulp-jshint-tests.ts | 16 --- gulp-jshint/gulp-jshint.d.ts | 29 ----- gulp-notify/gulp-notify-tests.ts | 41 ------- gulp-notify/gulp-notify.d.ts | 113 ------------------ .../typescript-require-tests.ts | 7 -- typescript-require/typescript-require.d.ts | 31 ----- 7 files changed, 288 deletions(-) delete mode 100644 backbone.localstorage/backbone.localstorage.d.ts delete mode 100644 gulp-jshint/gulp-jshint-tests.ts delete mode 100644 gulp-jshint/gulp-jshint.d.ts delete mode 100644 gulp-notify/gulp-notify-tests.ts delete mode 100644 gulp-notify/gulp-notify.d.ts delete mode 100644 typescript-require/typescript-require-tests.ts delete mode 100644 typescript-require/typescript-require.d.ts diff --git a/backbone.localstorage/backbone.localstorage.d.ts b/backbone.localstorage/backbone.localstorage.d.ts deleted file mode 100644 index 122c475876..0000000000 --- a/backbone.localstorage/backbone.localstorage.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -// Type definitions for backbone.localStorage 1.0.0 -// Project: https://github.com/jeromegn/Backbone.localStorage -// Definitions by: Louis Grignon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module Backbone { - interface Serializer { - serialize(item: any): any; - deserialize(data: any): any; - } - - class LocalStorage { - name: string; - serializer: Serializer; - records: string[]; - - constructor(name: string, serializer?: Serializer); - - save(): void; - - // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already - // have an id of it's own. - create(model: any): any; - - // Update a model by replacing its copy in `this.data`. - update(model: any): any; - - // Retrieve a model from `this.data` by id. - find(model: any): any; - - // Return the array of all models currently in storage. - findAll(): any; - - // Delete a model from `this.data`, returning it. - destroy(model: T): T; - - localStorage(): any; - - // Clear localStorage for specific collection. - _clear(): void; - - _storageSize(): number; - - _itemName(id: any): string; - } -} - -import Store = Backbone.LocalStorage; - diff --git a/gulp-jshint/gulp-jshint-tests.ts b/gulp-jshint/gulp-jshint-tests.ts deleted file mode 100644 index fe4d930418..0000000000 --- a/gulp-jshint/gulp-jshint-tests.ts +++ /dev/null @@ -1,16 +0,0 @@ -/// -/// -import gulp = require("gulp"); -import jshint = require("gulp-jshint"); - - -gulp.task('check1', function() { - gulp.src('lib/*.ts') - .pipe(jshint()) - .pipe(jshint.reporter('default')); -}); - -gulp.task('check2', function() { - gulp.src('lib/*.ts') - .pipe(jshint({ linter: 'jshint', lookup: true })); -}); \ No newline at end of file diff --git a/gulp-jshint/gulp-jshint.d.ts b/gulp-jshint/gulp-jshint.d.ts deleted file mode 100644 index 20db40a62a..0000000000 --- a/gulp-jshint/gulp-jshint.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Type definitions for gulp-jshint -// Project: https://github.com/spalger/gulp-jshint -// Definitions by: Louis Grignon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module "gulp-jshint" { - function GulpJSHint(options?: IGulpJSHintOptions): NodeJS.ReadWriteStream; - - interface IGulpJSHintOptions { - /** - * When false do not lookup .jshintrc files. See the JSHint docs for more info. - * Default true. - */ - lookup?: boolean; - - /** - * Either the name of a module to use for linting the code or a linting function itself. This enables using an alternate (but jshint compatible) linter like "jsxhint". - * Default is "jshint" - */ - linter?: string; - } - - namespace GulpJSHint { - function reporter(kind: (string | Object)): NodeJS.ReadWriteStream; - } - export = GulpJSHint; -} diff --git a/gulp-notify/gulp-notify-tests.ts b/gulp-notify/gulp-notify-tests.ts deleted file mode 100644 index 4175d08628..0000000000 --- a/gulp-notify/gulp-notify-tests.ts +++ /dev/null @@ -1,41 +0,0 @@ -/// -/// -import gulp = require("gulp"); -import notify = require("gulp-notify"); - -var custom = notify.withReporter(function(options, callback) { - console.log("Title:", options.title); - console.log("Message:", options.message); - callback(); -}); - -notify.on('click', (options) => { - console.log('I clicked something!', options); -}); - -notify.on('timeout', (options) => { - console.log('The notification timed out', options); -}); - -gulp.task('notify1', function() { - gulp.src("./src/test.ext") - .pipe(notify("Hello Gulp! From file: <%= file.relative %>")); -}); - -gulp.task('notify2', function() { - gulp.src("./src/test.ext") - .pipe(notify({ - message: "Generated file: <%= file.relative %> @ <%= options.date %>", - templateOptions: { - date: new Date() - } - })); -}); - -gulp.task('notify3', function() { - gulp.src("./src/test.ext") - .pipe(custom("This is a message.")) - .on("error", notify.onError((error: Error) => { - return "Message to the notifier: " + error.message; - })); -}); \ No newline at end of file diff --git a/gulp-notify/gulp-notify.d.ts b/gulp-notify/gulp-notify.d.ts deleted file mode 100644 index 4658616447..0000000000 --- a/gulp-notify/gulp-notify.d.ts +++ /dev/null @@ -1,113 +0,0 @@ -// Type definitions for gulp-jshint -// Project: https://github.com/mikaelbr/gulp-notify -// Definitions by: Louis Grignon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module "gulp-notify" { - function GulpNotify(param: string | Function | GulpNotifyOptions): NodeJS.ReadWriteStream; - - interface GulpNotifyOptions { - /** - * Type: Boolean Default: false - * If the notification should only happen on the last file of the stream. Per default a notification is triggered on each file. - */ - onLast?: boolean; - - /** - * Type: Boolean Default: false - * If the returned stream should emit an error or not. If emitError is true, you have to handle .on('error') manually in case the notifier (gulp-notify) fails. If the default false is set, the error will not be emitted but simply printed to the console. - * This means you can run the notifier on a CI system without opting it out but simply letting it fail gracefully. - */ - emitError?: boolean; - - /** - * Type: String Default: File path in stream - * - * The message you wish to attach to file. The string can be a lodash template as it is passed through gulp-util.template. - * - * Example: Created <%= file.relative %>. - * as function - * - * Type: Function(vinylFile) - * - * See notify(Function). - */ - message?: string | Function; - - /** - * Type: String Default: "Gulp Notification" - * - * The title of the notification. The string can be a lodash template as it is passed through gulp-util.template. - * - * Example: Created <%= file.relative %>. - * as function - * - * Type: Function(vinylFile) - * - * See notify(Function). - */ - title?: string | Function; - - /** - * Object passed to the lodash template, for additional properties passed to the template. - */ - templateOptions?: Object; - - /** - * Type: Function(options, callback) Default: node-notifier module - * - * Swap out the notifier by passing in an function. The function expects two arguments: options and callback. - * - * The callback must be called when the notification is finished. Options will contain both title and message. - * - * See notify.withReporter for syntactic sugar. - */ - notifier?: (options: GulpNotifyOptions, callback: () => void) => void; - - /** - * If the wait option is set to true, the notifier will tigger events click or timeout, whether the user clicks the notification or it times out. You listen to these events on the main notify object, not the produces stream. - */ - wait?: boolean; - } - - namespace GulpNotify { - - /** - * If the wait option is set to true, the notifier will tigger events click or timeout, whether the user clicks the notification or it times out. You listen to these events on the main notify object, not the produces stream. - */ - function on(event: string, callback: (notificationOptions?: GulpNotifyOptions) => void): void; - - /** - * Wraps options.notifier to return a new notify-function only using the passed in reporter. - */ - function withReporter(reporter: (options: GulpNotifyOptions, callback: () => void) => void): (message: string | Function) => NodeJS.ReadWriteStream; - - - /** - * The exact same API as using notify(), but where a vinyl File is passed, the error object is passed instead. - */ - function onError(param: string | { (error: Error): string } | GulpNotifyOptions): Function; - - /** - * Type: Integer Default: 2 - * - * Set if logger should be used or not. If log level is set to 0, no logging will be used. If no new log level is passed, the current log level is returned. - * - * 0: No logging - * 1: Log on error - * 2: Log both on error and regular notification. - * - * If logging is set to > 0, the title and message passed to gulp-notify will be logged like so: - * ➜ gulp-notify git:(master) ✗ gulp --gulpfile examples/gulpfile.js one - * [gulp] Using file /Users/example/gulp-notify/examples/gulpfile.js - * [gulp] Working directory changed to /Users/example/repos/gulp-notify/examples - * [gulp] Running 'one'... - * [gulp] Finished 'one' in 4.08 ms - * [gulp] gulp-notify: [Gulp notification] /Users/example/gulp-notify/test/fixtures/1.txt - */ - function logLevel(level: number): void; - } - export = GulpNotify; -} diff --git a/typescript-require/typescript-require-tests.ts b/typescript-require/typescript-require-tests.ts deleted file mode 100644 index 6269a4b9d3..0000000000 --- a/typescript-require/typescript-require-tests.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// - -require('typescript-require')({ - nodeLib: false, - targetES5: true, - exitOnError: true -}); diff --git a/typescript-require/typescript-require.d.ts b/typescript-require/typescript-require.d.ts deleted file mode 100644 index 68b24ca274..0000000000 --- a/typescript-require/typescript-require.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Type definitions for typescript-require -// Project: https://github.com/theblacksmith/typescript-require -// Definitions by: Louis Grignon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module "typescript-require" { - function TypeScriptRequire(options?: TypeScriptRequireOptions): void; - - interface TypeScriptRequireOptions { - /** - * If true node.d.ts definitions file is loaded before custom ts files. This is disabled by default and you should use. - * Default false. - */ - nodeLib?: boolean; - - /** - * Target ES5 / ES3 output mode. - * Default true. - */ - targetES5?: boolean; - - /** - * Wether execution should stop on compile error. - */ - exitOnError?: boolean; - } - - export = TypeScriptRequire; -} From 448bcc6e964f0f1c1ac87a6fb3ee0a4f186ec3b9 Mon Sep 17 00:00:00 2001 From: Howard Pinsley Date: Sat, 12 Dec 2015 16:25:16 -0500 Subject: [PATCH 43/66] Add optional startup property to TransitionAnimation --- google.visualization/google.visualization.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/google.visualization/google.visualization.d.ts b/google.visualization/google.visualization.d.ts index 222faec1d1..f1ef8278c3 100644 --- a/google.visualization/google.visualization.d.ts +++ b/google.visualization/google.visualization.d.ts @@ -365,6 +365,7 @@ declare module google { export interface TransitionAnimation { duration?: number; easing?: string; // linear, in, out, inAndOut + startup?: boolean; } export interface ChartAxis { From 3a4f3278d7061041c9ad6c8c1bd69a1b6799c703 Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Sat, 12 Dec 2015 15:48:55 -0600 Subject: [PATCH 44/66] Add ImapMessageBodyInfo and ImapMessageAttributes interfaces; correct some of the occurrences; fix Folder interface --- imap/imap.d.ts | 105 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 34 deletions(-) diff --git a/imap/imap.d.ts b/imap/imap.d.ts index ce9fd72233..105e64c85d 100644 --- a/imap/imap.d.ts +++ b/imap/imap.d.ts @@ -83,34 +83,68 @@ declare module IMAP { }; } + export interface ImapMessageBodyInfo { + /** The specifier for this body (e.g. 'TEXT', 'HEADER.FIELDS (TO FROM SUBJECT)', etc). */ + which: string; + /** The size of this body in bytes. */ + size: number; + } + + export interface ImapMessageAttributes { + /** A 32-bit ID that uniquely identifies this message within its mailbox. */ + uid: number; + /** A list of flags currently set on this message. */ + flags: string[]; + /** The internal server date for the message. */ + date: Date; + /** The message's body structure (only set if requested with fetch()). */ + struct?: any[]; + /** The RFC822 message size (only set if requested with fetch()). */ + size?: number; + } /** Given in a 'message' event from ImapFetch */ - export interface ImapMessage extends NodeJS.EventEmitter { } + export interface ImapMessage extends NodeJS.EventEmitter { + on(event: string, listener: Function): this; + on(event: 'body', listener: (stream: NodeJS.ReadableStream, info: ImapMessageBodyInfo) => void): this; + on(event: 'attributes', listener: (attrs: ImapMessageAttributes) => void): this; + on(event: 'end', listener: () => void): this; + } export interface FetchOptions { /** Mark message(s) as read when fetched. Default: false */ - markSeen?: boolean; + markSeen?: boolean; /** Fetch the message structure. Default: false */ - struct?: boolean; + struct?: boolean; /** Fetch the message envelope. Default: false */ - envelope?: boolean; + envelope?: boolean; /** Fetch the RFC822 size. Default: false */ - size?: boolean; + size?: boolean; /** Fetch modifiers defined by IMAP extensions. Default: (none) */ - modifiers?: Object; + modifiers?: Object; /** A string or Array of strings containing the body part section to fetch. Default: (none) Example sections: */ - bodies?: any; /* string|string[] */ + bodies?: string | string[]; } /** Returned from fetch() */ - export interface ImapFetch extends NodeJS.EventEmitter { } + export interface ImapFetch extends NodeJS.EventEmitter { + on(event: string, listener: Function): this; + on(event: 'message', listener: (message: ImapMessage, seqno: number) => void): this; + on(event: 'error', listener: (error: Error) => void): this; + once(event: string, listener: Function): this; + once(event: 'error', listener: (error: Error) => void): this; + } export interface Folder { + /** mailbox attributes. An attribute of 'NOSELECT' indicates the mailbox cannot be opened */ attribs: string[]; + /** hierarchy delimiter for accessing this mailbox's direct children. */ delimiter: string; - children: Folder[]; + /** an object containing another structure similar in format to this top level, otherwise null if no children */ + children: MailBoxes; + /** pointer to parent mailbox, null if at the top level */ parent: Folder; } @@ -129,10 +163,11 @@ declare module IMAP { date?: Date; } + export interface MessageFunctions { + /** Searches the currently open mailbox for messages using given criteria. criteria is a list describing what you want to find. For criteria types that require arguments, use an array instead of just the string criteria type name (e.g. ['FROM', 'foo@bar.com']). Prefix criteria types with an "!" to negate. + + The following message flags are valid types that do not have arguments: - // search() criteria - /** - // The following message flags are valid types that do not have arguments: ALL: void; // All messages. ANSWERED: void; // Messages with the Answered flag set. DELETED: void; // Messages with the Deleted flag set. @@ -148,7 +183,7 @@ declare module IMAP { UNFLAGGED: void; // Messages that do not have the Flagged flag set. UNSEEN: void; // Messages that do not have the Seen flag set. - // The following are valid types that require string value(s): + The following are valid types that require string value(s): BCC: any; // Messages that contain the specified string in the BCC field. CC: any; // Messages that contain the specified string in the CC field. @@ -159,25 +194,27 @@ declare module IMAP { TEXT: any; // Messages that contain the specified string in the header OR the message body. KEYWORD: any; // Messages with the specified keyword set. HEADER: any; // Requires two string values, with the first being the header name and the second being the value to search for. If this second string is empty, all messages that contain the given header name will be returned. - // The following are valid types that require a string parseable by JavaScripts Date object OR a Date instance: + + The following are valid types that require a string parseable by JavaScripts Date object OR a Date instance: + BEFORE: any; // Messages whose internal date (disregarding time and timezone) is earlier than the specified date. ON: any; // Messages whose internal date (disregarding time and timezone) is within the specified date. SINCE: any; // Messages whose internal date (disregarding time and timezone) is within or later than the specified date. SENTBEFORE: any; // Messages whose Date header (disregarding time and timezone) is earlier than the specified date. SENTON: any; // Messages whose Date header (disregarding time and timezone) is within the specified date. SENTSINCE: any; // Messages whose Date header (disregarding time and timezone) is within or later than the specified date. - //The following are valid types that require one Integer value: + + The following are valid types that require one Integer value: + LARGER: number; // Messages with a size larger than the specified number of bytes. SMALLER: number; // Messages with a size smaller than the specified number of bytes. - // The following are valid criterion that require one or more Integer values: + + The following are valid criterion that require one or more Integer values: + UID: any; // Messages with UIDs corresponding to the specified UID set. Ranges are permitted (e.g. '2504:2507' or '*' or '2504:*'). - */ - - - export interface MessageFunctions { - /** Searches the currently open mailbox for messages using given criteria. criteria is a list describing what you want to find. For criteria types that require arguments, use an array instead of just the string criteria type name (e.g. ['FROM', 'foo@bar.com']). Prefix criteria types with an "!" to negate. */ - search(criteria: any[], callback: (error: Error, uids: string[]) => void): void; - /** Fetches message(s) in the currently open mailbox. */ + */ + search(criteria: any[], callback: (error: Error, uids: number[]) => void): void; + /** Fetches message(s) in the currently open mailbox; source can be a single message identifier, a message identifier range (e.g. '2504:2507' or '*' or '2504:*'), an array of message identifiers, or an array of message identifier ranges. */ fetch(source: any /* MessageSource */, options: FetchOptions): ImapFetch; /** Copies message(s) in the currently open mailbox to another mailbox. */ copy(source: any /* MessageSource */, mailboxName: string, callback: (error: Error) => void): void; @@ -199,26 +236,23 @@ declare module IMAP { serverSupports(capability: string): boolean; } - - - export class Connection implements NodeJS.EventEmitter, MessageFunctions { /** @constructor */ constructor(config: Config); // from NodeJS.EventEmitter - addListener(event: string, listener: Function): NodeJS.EventEmitter; - on(event: string, listener: Function): NodeJS.EventEmitter; - once(event: string, listener: Function): NodeJS.EventEmitter; - removeListener(event: string, listener: Function): NodeJS.EventEmitter; - removeAllListeners(event?: string): NodeJS.EventEmitter; + addListener(event: string, listener: Function): this; + on(event: string, listener: Function): this; + once(event: string, listener: Function): this; + removeListener(event: string, listener: Function): this; + removeAllListeners(event?: string): this; setMaxListeners(n: number): void; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; // from MessageFunctions /** Searches the currently open mailbox for messages using given criteria. criteria is a list describing what you want to find. For criteria types that require arguments, use an array instead of just the string criteria type name (e.g. ['FROM', 'foo@bar.com']). Prefix criteria types with an "!" to negate. */ - search(criteria: any[], callback: (error: Error, uids: string[]) => void): void; + search(criteria: any[], callback: (error: Error, uids: number[]) => void): void; /** Fetches message(s) in the currently open mailbox. */ fetch(source: any /* MessageSource */, options: FetchOptions): ImapFetch; /** Copies message(s) in the currently open mailbox to another mailbox. */ @@ -241,7 +275,7 @@ declare module IMAP { serverSupports(capability: string): boolean; /** Parses a raw header and returns an object keyed on header fields and the values are Arrays of header field values. Set disableAutoDecode to true to disable automatic decoding of MIME encoded-words that may exist in header field values. */ - static parseHeader(rawHeader: string, disableAutoDecode?: boolean): any; + static parseHeader(rawHeader: string, disableAutoDecode?: boolean): {[index: string]: string[]}; /** The current state of the connection (e.g. 'disconnected', 'connected', 'authenticated'). */ state: string; @@ -256,6 +290,9 @@ declare module IMAP { /** Mailboxes that are accessible by any logged in user. */ shared: any[]; }; + /** + seq exposes the search() ... serverSupports() set of commands, but returns sequence number(s) instead of UIDs. + */ seq: MessageFunctions; /** Attempts to connect and authenticate with the IMAP server. */ connect(): void; @@ -273,7 +310,7 @@ declare module IMAP { /** Creates a new mailbox on the server. mailboxName should include any necessary prefix/path. */ addBox(mailboxName: string, callback: (error: Error) => void): void; /** Removes a specific mailbox that exists on the server. mailboxName should including any necessary prefix/path. */ - delBox(mailboxName: string, callback: (error: Error, uids: string[]) => void): void; + delBox(mailboxName: string, callback: (error: Error) => void): void; /** Renames a specific mailbox that exists on the server. Both oldMailboxName and newMailboxName should include any necessary prefix/path. Note: Renaming the 'INBOX' mailbox will instead cause all messages in 'INBOX' to be moved to the new mailbox. */ renameBox(oldMailboxName: string, newMailboxName: string, callback: (error: Error, mailbox: Box) => void): void; /** Subscribes to a specific mailbox that exists on the server. mailboxName should include any necessary prefix/path. */ From 7bd7a4233e446a3b8212c8f35233c5ba6f223791 Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Sat, 12 Dec 2015 15:49:58 -0600 Subject: [PATCH 45/66] Fix tests to reflect what imap returns --- imap/imap-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imap/imap-tests.ts b/imap/imap-tests.ts index 23f5f8f17e..8d9ce6cce8 100644 --- a/imap/imap-tests.ts +++ b/imap/imap-tests.ts @@ -124,7 +124,7 @@ var fs = require('fs'); openInbox(function(err : Error, box : IMAP.Box) { if (err) throw err; - imap.search([ 'UNSEEN', ['SINCE', 'May 20, 2010'] ], function(err : Error, results : string[]) { + imap.search([ 'UNSEEN', ['SINCE', 'May 20, 2010'] ], function(err : Error, results : number[]) { if (err) throw err; var f = imap.fetch(results, { bodies: '' }); f.on('message', function(msg : IMAP.ImapMessage, seqno : number) { From de5a50a5f319931dcc8c43b215945eabe17189dc Mon Sep 17 00:00:00 2001 From: Eric Winkelmann Date: Sat, 12 Dec 2015 19:26:28 -0800 Subject: [PATCH 46/66] Fix PDFPageProxy property getter types in pdf.d.ts `pageNumber`, `rotate`, `ref`, and `view` are property getters, not functions. Resolves #6726 --- pdf/pdf.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pdf/pdf.d.ts b/pdf/pdf.d.ts index 8cac3a81c1..107031cade 100644 --- a/pdf/pdf.d.ts +++ b/pdf/pdf.d.ts @@ -221,22 +221,22 @@ interface PDFPageProxy { /** * Page number of the page. First page is 1. **/ - pageNumber(): number; + pageNumber: number; /** * The number of degrees the page is rotated clockwise. **/ - rotate(): number; + rotate: number; /** * The reference that points to this page. **/ - ref(): PDFRef; + ref: PDFRef; /** * @return An array of the visible portion of the PDF page in the user space units - [x1, y1, x2, y2]. **/ - view(): number[]; + view: number[]; /** * @param scale The desired scale of the viewport. From 33a79667e06b2b65336b79178a807ce751a9654c Mon Sep 17 00:00:00 2001 From: Eric Winkelmann Date: Sat, 12 Dec 2015 21:25:13 -0800 Subject: [PATCH 47/66] Make IObservable.off() args optional in fabricjs.d.ts As specified in the [fabric.js documentation](http://fabricjs.com/docs/fabric.Observable.html#off), `IObservable.off()` accepts two optional arguments. --- fabricjs/fabricjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabricjs/fabricjs.d.ts b/fabricjs/fabricjs.d.ts index d4ac5ad75b..248ee29f2c 100644 --- a/fabricjs/fabricjs.d.ts +++ b/fabricjs/fabricjs.d.ts @@ -345,7 +345,7 @@ declare module fabric { * @param eventName Event name (eg. 'after:render') or object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler}) * @param handler Function to be deleted from EventListeners */ - off(eventName: string|any, handler: (e: IEvent) => any): T; + off(eventName?: string|any, handler?: (e: IEvent) => any): T; } // animation mixin From f791d1f4763660a84d6f02117d5a70a80c5f3e49 Mon Sep 17 00:00:00 2001 From: Leon Yu Date: Sun, 13 Dec 2015 03:18:32 -0500 Subject: [PATCH 48/66] Modernizr 3.2.0 --- modernizr/modernizr-tests.ts | 102 +++++- modernizr/modernizr-tests.ts.tscparams | 1 - modernizr/modernizr.d.ts | 485 +++++++++++++++++++------ 3 files changed, 470 insertions(+), 118 deletions(-) delete mode 100644 modernizr/modernizr-tests.ts.tscparams diff --git a/modernizr/modernizr-tests.ts b/modernizr/modernizr-tests.ts index 86355a3100..f5308dd9e7 100644 --- a/modernizr/modernizr-tests.ts +++ b/modernizr/modernizr-tests.ts @@ -19,9 +19,9 @@ $(function () { document.getElementById('#notice').innerHTML = msg; } - Modernizr.prefixed('boxSizing'); + Modernizr.prefixed('boxSizing'); Modernizr.prefixed('requestAnimationFrame', window); - var ms = Modernizr.prefixed("matchesSelector", HTMLElement.prototype, document.body); + var ms = Modernizr.prefixed("matchesSelector", HTMLElement.prototype, true); Modernizr.prefixed('requestAnimationFrame', window, false); Modernizr.mq('only all and (max-width: 400px)'); @@ -30,7 +30,7 @@ $(function () { Modernizr.addTest('track', () => { var video = document.createElement('video'); - // return typeof video.addTextTrack === 'function' + return typeof video.addTextTrack === 'function' }); Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', (elem, rule) => { @@ -45,10 +45,100 @@ $(function () { Modernizr.testAllProps('boxSizing'); - var elem; + var elem: Element; Modernizr.hasEvent('gesturestart', elem); - - if (!Modernizr.autofocus) { + + if (!Modernizr.input.autofocus) { $("[autofocus]").focus(); } }); + + +Modernizr.on('flash', function( result ) { + if (result) { + // the browser has flash + } else { + // the browser does not have flash + } +}); + +Modernizr.addTest('itsTuesday', function() { + var d = new Date(); + return d.getDay() === 2; +}); + +Modernizr.addTest('hasJquery', 'jQuery' in window); + +var detects = { + 'hasjquery': 'jQuery' in window, + 'itstuesday': function() { + var d = new Date(); + return d.getDay() === 2; + } +} +Modernizr.addTest(detects); + +var keyframes = Modernizr.atRule('@keyframes'); +if (keyframes) { + // keyframes are supported + // could be `@-webkit-keyframes` or `@keyframes` +} else { + // keyframes === `false` +} + +Modernizr._domPrefixes === [ "Moz", "O", "ms", "Webkit" ]; + +Modernizr.hasEvent('blur') // true; + +Modernizr.hasEvent('devicelight', window) // true; + +var query = Modernizr.mq('(min-width: 900px)'); +if (query) { + // the browser window is larger than 900px +} + +Modernizr.prefixed('boxSizing') + +var raf = Modernizr.prefixed('requestAnimationFrame', window); +raf(function() { +}); + +var rAFProp = Modernizr.prefixed('requestAnimationFrame', window, false); +rAFProp === 'WebkitRequestAnimationFrame' // in older webkit + +Modernizr.prefixedCSS('transition') // '-moz-transition' in old Firefox + +Modernizr.prefixedCSSValue('background', 'linear-gradient(left, red, red)') + +var rule = Modernizr._prefixes.join('transform: rotate(20deg); '); +rule === 'transform: rotate(20deg); webkit-transform: rotate(20deg); moz-transform: rotate(20deg); o-transform: rotate(20deg); ms-transform: rotate(20deg);' + +rule = 'display:' + Modernizr._prefixes.join('flex; display:') + 'flex'; +rule === 'display:flex; display:-webkit-flex; display:-moz-flex; display:-o-flex; display:-ms-flex; display:flex' + +Modernizr.testAllProps('boxSizing') // true +Modernizr.testAllProps('display', 'block') // true +Modernizr.testAllProps('display', 'penguin') // false +Modernizr.testAllProps('shapeOutside', 'content-box', true); + +Modernizr.testProp('pointerEvents') // true +Modernizr.testProp('pointerEvents', 'none') // true +Modernizr.testProp('pointerEvents', 'penguin') // false + +Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', function(elem, rule) { + // elem is the first DOM node in the page (by default #modernizr) + // rule is the first argument you supplied - the CSS rule in string form + Modernizr.addTest('widthworks', elem.style.width === '9px') +}); + +Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', function(elem) { + document.getElementById('modernizr').style.width === '1px'; // true + document.getElementById('modernizr2').style.width === '2px'; // true + elem.firstChild === document.getElementById('modernizr2'); // true +}, 1); + +Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', function(elem) { + document.getElementById('modernizr').style.width === '1px'; // true + document.getElementById('modernizr2').style.width === '2px'; // true + elem.firstChild === document.getElementById('modernizr2'); // true +}, 1); diff --git a/modernizr/modernizr-tests.ts.tscparams b/modernizr/modernizr-tests.ts.tscparams deleted file mode 100644 index d3f5a12faa..0000000000 --- a/modernizr/modernizr-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modernizr/modernizr.d.ts b/modernizr/modernizr.d.ts index a9104fd226..fa976c217e 100644 --- a/modernizr/modernizr.d.ts +++ b/modernizr/modernizr.d.ts @@ -1,116 +1,379 @@ -// Type definitions for Modernizr 2.6.2 +// Type definitions for Modernizr 3.2.0 // Project: http://modernizr.com/ -// Definitions by: Boris Yankov , Theodore Brown -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions by: Boris Yankov , Theodore Brown , Leon Yu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare namespace __Modernizr { + interface AudioBoolean { + ogg: boolean; + mp3: boolean; + wav: boolean; + m4a: boolean; + } -interface Audioboolean { - ogg: boolean; - mp3: boolean; - wav: boolean; - m4a: boolean; + interface VideoBoolean { + ogg: boolean; + h264: boolean; + webm: boolean; + } + + interface InputBoolean { + autocomplete: boolean; + autofocus: boolean; + list: boolean; + placeholder: boolean; + max: boolean; + min: boolean; + multiple: boolean; + pattern: boolean; + required: boolean; + step: boolean; + } + + interface InputTypesBoolean { + color: boolean; + date: boolean; + datetime: boolean; + "datetime-local": boolean; + email: boolean; + month: boolean; + number: boolean; + range: boolean; + search: boolean; + tel: boolean; + time: boolean; + url: boolean; + week: boolean; + } + + interface FeatureDetects { + // Documented + + ambientlight: boolean; + applicationcache: boolean; + audio: AudioBoolean; + batteryapi: boolean; + blobconstructor: boolean; + canvas: boolean; + canvastext: boolean; + contenteditable: boolean; + contextmenu: boolean; + cookies: boolean; + cors: boolean; + cryptography: boolean; + customprotocolhandler: boolean; + customevent: boolean; + dart: boolean; + dataview: boolean; + emoji: boolean; + eventlistener: boolean; + exiforientation: boolean; + flash: boolean; + forcetouch: boolean; + fullscreen: boolean; + gamepads: boolean; + geolocation: boolean; + hashchange: boolean; + hiddenscroll: boolean; + history: boolean; + htmlimports: boolean; + ie8compat: boolean; + indexeddb: boolean; + indexeddbblob: boolean; + input: InputBoolean; + search: boolean; + inputtypes: InputTypesBoolean; + intl: boolean; + json: boolean; + ligatures: boolean; + olreversed: boolean; + mathml: boolean; + notification: boolean; + pagevisibility: boolean; + performance: boolean; + pointerevents: boolean; + pointerlock: boolean; + postmessage: boolean; + proximity: boolean; + queryselector: boolean; + quotamanagement: boolean; + requestanimationframe: boolean; + serviceworker: boolean; + svg: boolean; + templatestrings: boolean; + touchevents: boolean; + typedarrays: boolean; + unicoderange: boolean; + unicode: boolean; + userdata: boolean; + vibrate: boolean; + video: VideoBoolean; + vml: boolean; + webintents: boolean; + animation: boolean; + webgl: boolean; + websockets: boolean; + xdomainrequest: boolean; + adownload: boolean; + audioloop: boolean; + audiopreload: boolean; + webaudio: boolean; + lowbattery: boolean; + canvasblending: boolean; + todataurljpeg: boolean; + todataurlpng: boolean; + todataurlwebp: boolean; + canvaswinding: boolean; + getrandomvalues: boolean; + cssall: boolean; + cssanimations: boolean; + appearance: boolean; + backdropfilter: boolean; + backgroundblendmode: boolean; + backgroundcliptext: boolean; + bgpositionshorthand: boolean; + bgpositionxy: boolean; + bgrepeatspace: boolean; + bgrepeatround: boolean; + backgroundsize: boolean; + bgsizecover: boolean; + borderimage: boolean; + borderradius: boolean; + boxshadow: boolean; + boxsizing: boolean; + csscalc: boolean; + checked: boolean; + csschunit: boolean; + csscolumns: boolean; + cubicbezierrange: boolean; + "display-runin": boolean; + displaytable: boolean; + ellipsis: boolean; + cssescape: boolean; + cssexunit: boolean; + cssfilters: boolean; + flexbox: boolean; + flexboxlegacy: boolean; + flexboxtweener: boolean; + flexwrap: boolean; + fontface: boolean; + generatedcontent: boolean; + cssgradients: boolean; + csshairline: boolean; + hsla: boolean; + csshyphens: boolean; + softhyphens: boolean; + softhyphensfind: boolean; + cssinvalid: boolean; + lastchild: boolean; + cssmask: boolean; + mediaqueries: boolean; + multiplebgs: boolean; + nthchild: boolean; + objectfit: boolean; + opacity: boolean; + overflowscrolling: boolean; + csspointerevents: boolean; + csspositionsticky: boolean; + csspseudoanimations: boolean; + csspseudotransitions: boolean; + cssreflections: boolean; + regions: boolean; + cssremunit: boolean; + cssresize: boolean; + rgba: boolean; + cssscrollbar: boolean; + scrollsnappoints: boolean; + shapes: boolean; + siblinggeneral: boolean; + subpixelfont: boolean; + supports: boolean; + target: boolean; + textalignlast: boolean; + textshadow: boolean; + csstransforms: boolean; + csstransforms3d: boolean; + preserve3d: boolean; + csstransitions: boolean; + userselect: boolean; + cssvalid: boolean; + cssvhunit: boolean; + cssvmaxunit: boolean; + cssvminunit: boolean; + cssvwunit: boolean; + willchange: boolean; + wrapflow: boolean; + classlist: boolean; + createelementattrs: boolean; + "createelement-attrs": boolean; + dataset: boolean; + documentfragment: boolean; + hidden: boolean; + microdata: boolean; + mutationobserver: boolean; + bdi: boolean; + datalistelem: boolean; + details: boolean; + outputelem: boolean; + picture: boolean; + progressbar: boolean; + meter: boolean; + ruby: boolean; + template: boolean; + time: boolean; + texttrackapi: boolean; + track: boolean; + unknownelements: boolean; + es5array: boolean; + es5date: boolean; + es5function: boolean; + es5object: boolean; + es5: boolean; + strictmode: boolean; + es5string: boolean; + es5syntax: boolean; + es5undefined: boolean; + es6array: boolean; + es6collections: boolean; + contains: boolean; + generators: boolean; + es6math: boolean; + es6number: boolean; + es6object: boolean; + promises: boolean; + es6string: boolean; + devicemotion: boolean; + deviceorientation: boolean; + oninput: boolean; + filereader: boolean; + filesystem: boolean; + capture: boolean; + fileinput: boolean; + directory: boolean; + formattribute: boolean; + localizednumber: boolean; + placeholder: boolean; + requestautocomplete: boolean; + formvalidation: boolean; + sandbox: boolean; + seamless: boolean; + srcdoc: boolean; + apng: boolean; + imgcrossorigin: boolean; + jpeg2000: boolean; + jpegxr: boolean; + sizes: boolean; + srcset: boolean; + webpalpha: boolean; + webpanimation: boolean; + webplossless: boolean; + "webp-lossless": boolean; + webp: boolean; + inputformaction: boolean; + inputformenctype: boolean; + inputformmethod: boolean; + inputformtarget: boolean; + beacon: boolean; + lowbandwidth: boolean; + eventsource: boolean; + fetch: boolean; + xhrresponsetypearraybuffer: boolean; + xhrresponsetypeblob: boolean; + xhrresponsetypedocument: boolean; + xhrresponsetypejson: boolean; + xhrresponsetypetext: boolean; + xhrresponsetype: boolean; + xhr2: boolean; + scriptasync: boolean; + scriptdefer: boolean; + speechrecognition: boolean; + speechsynthesis: boolean; + localstorage: boolean; + sessionstorage: boolean; + websqldatabase: boolean; + stylescoped: boolean; + svgasimg: boolean; + svgclippaths: boolean; + svgfilters: boolean; + svgforeignobject: boolean; + inlinesvg: boolean; + smil: boolean; + textareamaxlength: boolean; + bloburls: boolean; + datauri: boolean; + urlparser: boolean; + videoautoplay: boolean; + videoloop: boolean; + videopreload: boolean; + webglextensions: boolean; + datachannel: boolean; + getusermedia: boolean; + peerconnection: boolean; + websocketsbinary: boolean; + atobbtoa: boolean; + framed: boolean; + matchmedia: boolean; + blobworkers: boolean; + dataworkers: boolean; + sharedworkers: boolean; + transferables: boolean; + webworkers: boolean; + + // Undocumented - usually aliases or new features + + "atob-btoa": boolean; + "battery-api": boolean; + "blob-constructor": boolean; + "display-table": boolean; + "input-formaction": boolean; + "input-formenctype": boolean; + "input-formtarget": boolean; + "object-fit": boolean; + crypto: boolean; + displayrunin: boolean; + fileinputdirectory: boolean; + hairline: boolean; + inputsearchevent: boolean; + raf: boolean; + webanimations: boolean; + } + + interface Dictionary { + [key: string]: T; + } + + interface ModernizrAPI { + on(feature: string, cb: (result: boolean) => any): void; + + addTest(feature: string, test: () => boolean): void; + addTest(feature: string, test: boolean): void; + addTest(feature: Dictionary): void; + + atRule(prop: string): boolean; + + _domPrefixes: string[]; + + hasEvent(eventName: string, element?: EventTarget): boolean; + + mq(mq: string): boolean; + + prefixed(prop: string): string; + prefixed(prop: string, obj: EventTarget, element?: boolean): any; + + prefixedCSS(prop: string): string; + + prefixedCSSValue(prop: string, value: string): string; + + _prefixes: string[]; + + testAllProps(prop: string, value?: string, skipValueTest?: boolean): boolean; + + testProp(prop: string, value?: string, useValue?: boolean): boolean; + + testStyles(rule: string, callback: (elem: HTMLDivElement, rule: string) => void, nodes?: number, testnames?: string[]): boolean; + } + + export interface ModernizrStatic extends ModernizrAPI, FeatureDetects { } } -interface Videoboolean { - ogg: boolean; - h264: boolean; - webm: boolean; -} - -interface Inputboolean { - autocomplete: boolean; - autofocus: boolean; - list: boolean; - placeholder: boolean; - max: boolean; - min: boolean; - multiple: boolean; - pattern: boolean; - required: boolean; - step: boolean; -} - -interface InputTypesboolean { - search: boolean; - tel: boolean; - url: boolean; - email: boolean; - datetime: boolean; - date: boolean; - month: boolean; - week: boolean; - time: boolean; - datetimelocal: boolean; - number: boolean; - range: boolean; - color: boolean; -} - -interface ModernizrStatic { - autofocus: boolean; - fontface: boolean; - backgroundsize: boolean; - borderimage: boolean; - borderradius: boolean; - boxshadow: boolean; - flexbox: boolean; - hsla: boolean; - multiplebgs: boolean; - opacity: boolean; - rgba: boolean; - textshadow: boolean; - cssanimations: boolean; - csscolumns: boolean; - generatedcontent: boolean; - cssgradients: boolean; - cssreflections: boolean; - csstransforms: boolean; - csstransforms3d: boolean; - csstransitions: boolean; - applicationcache: boolean; - canvas: boolean; - canvastext: boolean; - draganddrop: boolean; - hashchange: boolean; - history: boolean; - audio: Audioboolean; - video: Videoboolean; - indexeddb: boolean; - input: Inputboolean; - inputtypes: InputTypesboolean; - localstorage: boolean; - postmessage: boolean; - sessionstorage: boolean; - websockets: boolean; - websqldatabase: boolean; - webworkers: boolean; - geolocation: boolean; - inlinesvg: boolean; - smil: boolean; - svg: boolean; - svgclippaths: boolean; - touch: boolean; - webgl: boolean; - - load(resources: any[]): void; - load(resourceObject: any): void; - load(resourceString: string): void; - - prefixed(property: string): any; - prefixed(property: string, obj: any, element?: any): any; - - mq(mediaQuery: string): boolean; - - addTest(feature: string, test: () => any): void; - addTest(feature: string, test: boolean): void; - addTest(feature: any): void; - - testStyles(rule: string, callback: (element: HTMLDivElement, rule: string) => void, nodes?: number, testnames?: string[]): boolean; - testProp(property: string): boolean; - testAllProps(property: string, prefix?: string): boolean; - testAllProps(property: string, obj: any, element: any): boolean; - - hasEvent(eventName: string, element?: any): boolean; -} - -declare var Modernizr: ModernizrStatic; +declare var Modernizr: __Modernizr.ModernizrStatic; From 2f970d1bddc31accd9a164b41cfe81fdc255c7e7 Mon Sep 17 00:00:00 2001 From: Alex Dresko Date: Sun, 13 Dec 2015 10:58:47 -0500 Subject: [PATCH 49/66] Added parameter to sendResposne --- chrome/chrome.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index 77d2898fd2..febf50a628 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -2646,13 +2646,13 @@ declare module chrome.extension { * Parameter request: The request sent by the calling script. * Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. If you have more than one onRequest listener in the same document, then only one may send a response. */ - addListener(callback: (request: any, sender: runtime.MessageSender, sendResponse: () => void) => void): void; + addListener(callback: (request: any, sender: runtime.MessageSender, sendResponse: (response: any) => void) => void): void; /** * @param callback The callback parameter should be a function that looks like this: * function(runtime.MessageSender sender, function sendResponse) {...}; * Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. If you have more than one onRequest listener in the same document, then only one may send a response. */ - addListener(callback: (sender: runtime.MessageSender, sendResponse: () => void) => void): void; + addListener(callback: (sender: runtime.MessageSender, sendResponse: (response: any) => void) => void): void; } /** @@ -5553,7 +5553,7 @@ declare module chrome.runtime { * Optional parameter message: The message sent by the calling script. * Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one onMessage listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until sendResponse is called). */ - addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; + addListener(callback: (message: any, sender: MessageSender, sendResponse: (response: any) => void) => void): void; } interface ExtensionConnectEvent extends chrome.events.Event { From b444f6ad9e1853c7a420b7e76d8672b737ba0716 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sun, 13 Dec 2015 21:48:02 +0500 Subject: [PATCH 50/66] lodash: signatures of _.isDate have been changed --- lodash/lodash-tests.ts | 39 ++++++++++++++++++++++++++++----------- lodash/lodash.d.ts | 10 +++++++++- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2d244b16e5..8ccf58aa22 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5444,17 +5444,34 @@ module TestIsBoolean { } // _.isDate -result = _.isDate(any); -result = _(42).isDate(); -result = _([]).isDate(); -result = _({}).isDate(); -{ - let value: Date|string = "foo"; - if (_.isDate(value)) { - value.toTimeString(); - } else { - value.charAt(0); - } +module TestIsBoolean { + { + let value: number|Date; + + if (_.isDate(value)) { + let result: Date = value; + } + else { + let result: number = value; + } + } + + { + let result: boolean; + + result = _.isDate(any); + result = _(42).isDate(); + result = _([]).isDate(); + result = _({}).isDate(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(42).chain().isDate(); + result = _([]).chain().isDate(); + result = _({}).chain().isDate(); + } } // _.isElement diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 8425f1d823..dea870c2d6 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9285,8 +9285,9 @@ declare module _ { /** * Checks if value is classified as a Date object. * @param value The value to check. + * * @return Returns true if value is correctly classified, else false. - **/ + */ isDate(value?: any): value is Date; } @@ -9297,6 +9298,13 @@ declare module _ { isDate(): boolean; } + interface LoDashExplicitWrapperBase { + /** + * @see _.isDate + */ + isDate(): LoDashExplicitWrapper; + } + //_.isElement interface LoDashStatic { /** From e081e6899a61bbcf340c48e975bced76621d829a Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 13 Dec 2015 18:28:12 +0100 Subject: [PATCH 51/66] fix formatting Adding a space before void to align changes to the original file formatting. --- angulartics/angulartics.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angulartics/angulartics.d.ts b/angulartics/angulartics.d.ts index d586eee54a..fdcb409ca2 100644 --- a/angulartics/angulartics.d.ts +++ b/angulartics/angulartics.d.ts @@ -21,7 +21,7 @@ declare module angulartics { interface IAnalyticsServiceProvider extends angular.IServiceProvider { virtualPageviews(value: boolean): void; - excludeRoutes(value: string[]):void; + excludeRoutes(value: string[]): void; firstPageview(value: boolean): void; withBase(value: boolean): void; withAutoBase(value: boolean): void; From 0d7e1be8b40682520c56c63aef9b9b7e11fa992e Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Sun, 13 Dec 2015 18:58:34 +0100 Subject: [PATCH 52/66] Remove trailing spaces Trailing spaces make it hard to contribute --- bookshelf/bookshelf-tests.ts | 1 - bookshelf/bookshelf.d.ts | 66 ++++++++--------- knex/knex.d.ts | 140 +++++++++++++++++------------------ 3 files changed, 103 insertions(+), 104 deletions(-) diff --git a/bookshelf/bookshelf-tests.ts b/bookshelf/bookshelf-tests.ts index 67580dae5f..42faf0909e 100644 --- a/bookshelf/bookshelf-tests.ts +++ b/bookshelf/bookshelf-tests.ts @@ -97,4 +97,3 @@ class Photo extends bookshelf.Model { return this.morphTo('imageable', Site, Post); } } - diff --git a/bookshelf/bookshelf.d.ts b/bookshelf/bookshelf.d.ts index 0da1ce2d68..e0278df261 100644 --- a/bookshelf/bookshelf.d.ts +++ b/bookshelf/bookshelf.d.ts @@ -11,7 +11,7 @@ declare module 'bookshelf' { import knex = require('knex'); import Promise = require('bluebird'); import Lodash = require('lodash'); - + interface Bookshelf extends Bookshelf.Events { VERSION : string; knex : knex; @@ -20,9 +20,9 @@ declare module 'bookshelf' { transaction(callback : (transaction : knex.Transaction) => T) : Promise; } - + function Bookshelf(knex : knex) : Bookshelf; - + namespace Bookshelf { abstract class Events { on(event? : string, callback? : EventFunction, context? : any) : void; @@ -31,20 +31,20 @@ declare module 'bookshelf' { triggerThen(name : string, ...args : any[]) : Promise; once(event : string, callback : EventFunction, context? : any) : void; } - + interface IModelBase { /** Should be declared as a getter instead of a plain property. */ hasTimestamps? : boolean|string[]; /** Should be declared as a getter instead of a plain property. Should be required, but cannot have abstract properties yet. */ tableName? : string; } - + abstract class ModelBase> extends Events> implements IModelBase { /** If overriding, must use a getter instead of a plain property. */ idAttribute : string; - + constructor(attributes? : any, options? : ModelOptions); - + clear() : T; clone() : T; escape(attribute : string) : string; @@ -63,7 +63,7 @@ declare module 'bookshelf' { timestamp(options? : TimestampOptions) : any; toJSON(options? : SerializeOptions) : any; unset(attribute : string) : T; - + // lodash methods invert() : R; keys() : string[]; @@ -74,7 +74,7 @@ declare module 'bookshelf' { pick(...attributes : string[]) : R; values() : any[]; } - + class Model> extends ModelBase { static collection>(models? : T[], options? : CollectionOptions) : Collection; static count(column? : string, options? : SyncOptions) : Promise; @@ -83,7 +83,7 @@ declare module 'bookshelf' { static fetchAll>() : Promise>; /** @deprecated should use `new` objects instead. */ static forge(attributes? : any, options? : ModelOptions) : T; - + belongsTo>(target : {new(...args : any[]) : R}, foreignKey? : string) : R; belongsToMany>(target : {new(...args : any[]) : R}, table? : string, foreignKey? : string, otherKey? : string) : Collection; count(column? : string, options? : SyncOptions) : Promise; @@ -109,7 +109,7 @@ declare module 'bookshelf' { where(properties : {[key : string] : any}) : T; where(key : string, operatorOrValue : string|number|boolean, valueIfOperator? : string|number|boolean) : T; } - + abstract class CollectionBase> extends Events { add(models : T[]|{[key : string] : any}[], options? : CollectionAddOptions) : Collection; at(index : number) : T; @@ -133,7 +133,7 @@ declare module 'bookshelf' { toJSON(options? : SerializeOptions) : any; unshift(model : any, options? : CollectionAddOptions) : void; where(match : {[key : string] : any}, firstOnly : boolean) : T|Collection; - + // lodash methods all(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : boolean; all(predicate? : R) : boolean; @@ -200,13 +200,13 @@ declare module 'bookshelf' { toArray() : T[]; without(...values : any[]) : T[]; } - + class Collection> extends CollectionBase { /** @deprecated use Typescript classes */ static extend(prototypeProperties? : any, classProperties? : any) : Function; /** @deprecated should use `new` objects instead. */ static forge(attributes? : any, options? : ModelOptions) : T; - + attach(ids : any[], options? : SyncOptions) : Promise>; count(column? : string, options? : SyncOptions) : Promise; create(model : {[key : string] : any}, options? : CollectionCreateOptions) : Promise; @@ -222,92 +222,92 @@ declare module 'bookshelf' { updatePivot(attributes : any, options? : PivotOptions) : Promise; withPivot(columns : string[]) : Collection; } - + interface ModelOptions { tableName? : string; hasTimestamps? : boolean; parse? : boolean; } - + interface LoadOptions extends SyncOptions { withRelated: string|any|any[]; } - + interface FetchOptions extends SyncOptions { require? : boolean; columns? : string|string[]; withRelated? : string|any|any[]; } - + interface FetchAllOptions extends SyncOptions { require? : boolean; } - + interface SaveOptions extends SyncOptions { method? : string; defaults? : string; patch? : boolean; require? : boolean; } - + interface SerializeOptions { shallow? : boolean; omitPivot? : boolean; } - + interface SetOptions { unset? : boolean; } - + interface TimestampOptions { method? : string; } - + interface SyncOptions { transacting? : knex.Transaction; debug? : boolean; } - + interface CollectionOptions { comparator? : boolean|string|((a : T, b : T) => number); } - + interface CollectionAddOptions extends EventOptions { at? : number; merge? : boolean; } - + interface CollectionFetchOptions { require? : boolean; withRelated? : string|string[]; } - + interface CollectionFetchOneOptions { require? : boolean; columns? : string|string[]; } - + interface CollectionSetOptions extends EventOptions { add? : boolean; remove? : boolean; merge?: boolean; } - + interface PivotOptions { query? : Function|any; require? : boolean; } - + interface EventOptions { silent? : boolean; } - + interface EventFunction { (model: T, attrs: any, options: any) : Promise|void; } - + interface CollectionCreateOptions extends ModelOptions, SyncOptions, CollectionAddOptions, SaveOptions {} } - + export = Bookshelf; } diff --git a/knex/knex.d.ts b/knex/knex.d.ts index d2afc4aa82..49fb30ae02 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -39,7 +39,7 @@ declare module "knex" { // // QueryInterface // - + interface QueryInterface { select: Select; as: As; @@ -49,7 +49,7 @@ declare module "knex" { into: Table; table: Table; distinct: Distinct; - + // Joins join: Join; joinRaw: JoinRaw; @@ -61,7 +61,7 @@ declare module "knex" { outerJoin: Join; fullOuterJoin: Join; crossJoin: Join; - + // Wheres where: Where; andWhere: Where; @@ -86,29 +86,29 @@ declare module "knex" { whereNotBetween: WhereBetween; orWhereBetween: WhereBetween; orWhereNotBetween: WhereBetween; - + // Group by groupBy: GroupBy; groupByRaw: RawQueryBuilder; - + // Order by orderBy: OrderBy; orderByRaw: RawQueryBuilder; - + // Union union: Union; unionAll(callback: Function): QueryBuilder; - + // Having having: Having; havingRaw: RawQueryBuilder; orHaving: Having; orHavingRaw: RawQueryBuilder; - + // Paging offset(offset: number): QueryBuilder; limit(limit: number): QueryBuilder; - + // Aggregation count(columnName?: string): QueryBuilder; min(columnName: string): QueryBuilder; @@ -117,43 +117,43 @@ declare module "knex" { avg(columnName: string): QueryBuilder; increment(columnName: string, amount?: number): QueryBuilder; decrement(columnName: string, amount?: number): QueryBuilder; - + // Others first(...columns: string[]): QueryBuilder; - + debug(enabled?: boolean): QueryBuilder; pluck(column: string): QueryBuilder; - + insert(data: any, returning?: string | string[]): QueryBuilder; update(data: any, returning?: string | string[]): QueryBuilder; update(columnName: string, value: Value, returning?: string | string[]): QueryBuilder; returning(column: string): QueryBuilder; - + del(returning?: string | string[]): QueryBuilder; delete(returning?: string | string[]): QueryBuilder; truncate(): QueryBuilder; - + transacting(trx: Transaction): QueryBuilder; connection(connection: any): QueryBuilder; clone(): QueryBuilder; } - + interface As { (columnName: string): QueryBuilder; } - + interface Select extends ColumnNameQueryBuilder { } - + interface Table { (tableName: string): QueryBuilder; (callback: Function): QueryBuilder; } - + interface Distinct extends ColumnNameQueryBuilder { } - + interface Join { (raw: Raw): QueryBuilder; (tableName: string, callback: Function): QueryBuilder; @@ -161,126 +161,126 @@ declare module "knex" { (tableName: string, column1: string, raw: Raw): QueryBuilder; (tableName: string, column1: string, operator: string, column2: string): QueryBuilder; } - + interface JoinRaw { (tableName: string, binding?: Value): QueryBuilder; } - + interface Where extends WhereRaw, WhereWrapped, WhereNull { (object: Object): QueryBuilder; (columnName: string, value: Value): QueryBuilder; (columnName: string, operator: string, value: Value): QueryBuilder; (columnName: string, operator: string, query: QueryBuilder): QueryBuilder; } - + interface WhereRaw extends RawQueryBuilder { (condition: boolean): QueryBuilder; } - + interface WhereWrapped { (callback: Function): QueryBuilder; } - + interface WhereNull { (columnName: string): QueryBuilder; } - + interface WhereIn { (columnName: string, values: Value[]): QueryBuilder; (columnName: string, callback: Function): QueryBuilder; (columnName: string, query: QueryBuilder): QueryBuilder; } - + interface WhereBetween { (columnName: string, range: [Value, Value]): QueryBuilder; } - + interface WhereExists { (callback: Function): QueryBuilder; (query: QueryBuilder): QueryBuilder; } - + interface WhereNull { (columnName: string): QueryBuilder; } - + interface WhereIn { (columnName: string, values: Value[]): QueryBuilder; } - + interface GroupBy extends RawQueryBuilder, ColumnNameQueryBuilder { } - + interface OrderBy { (columnName: string, direction?: string): QueryBuilder; } - + interface Union { (callback: Function, wrap?: boolean): QueryBuilder; (callbacks: Function[], wrap?: boolean): QueryBuilder; (...callbacks: Function[]): QueryBuilder; // (...callbacks: Function[], wrap?: boolean): QueryInterface; } - + interface Having extends RawQueryBuilder, WhereWrapped { (tableName: string, column1: string, operator: string, column2: string): QueryBuilder; } - + // commons - + interface ColumnNameQueryBuilder { (...columnNames: ColumnName[]): QueryBuilder; (columnNames: ColumnName[]): QueryBuilder; } - + interface RawQueryBuilder { (sql: string, ...bindings: Value[]): QueryBuilder; (sql: string, bindings: Value[]): QueryBuilder; (raw: Raw): QueryBuilder; } - + // Raw - + interface Raw extends events.EventEmitter, ChainableInterface { wrap(before: string, after: string): Raw; } - + interface RawBuilder { (value: Value): Raw; (sql: string, ...bindings: Value[]): Raw; (sql: string, bindings: Value[]): Raw; } - + // // QueryBuilder // - + interface QueryBuilder extends QueryInterface, ChainableInterface { or: QueryBuilder; and: QueryBuilder; - + //TODO: Promise? columnInfo(column?: string): Promise; - + forUpdate(): QueryBuilder; forShare(): QueryBuilder; - + toSQL(): Sql; - + on(event: string, callback: Function): QueryBuilder; } - + interface Sql { method: string; options: any; bindings: Value[]; sql: string; } - + // // Chainable interface // - + interface ChainableInterface extends Promise { toQuery(): string; options(options: any): QueryBuilder; @@ -289,16 +289,16 @@ declare module "knex" { pipe(writable: any): QueryBuilder; exec(callback: Function): QueryBuilder; } - + interface Transaction extends QueryBuilder { commit: any; rollback: any; } - + // // Schema builder // - + interface SchemaBuilder { createTable(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): Promise; renameTable(oldTableName: string, newTableName: string): Promise; @@ -309,7 +309,7 @@ declare module "knex" { dropTableIfExists(tableName: string): Promise; raw(statement: string): SchemaBuilder; } - + interface TableBuilder { increments(columnName?: string): ColumnBuilder; dropColumn(columnName: string): TableBuilder; @@ -336,24 +336,24 @@ declare module "knex" { specificType(columnName: string, type: string): ColumnBuilder; primary(columnNames: string[]) : TableBuilder; index(columnNames: string[], indexName?: string, indexType?: string) : TableBuilder; - unique(columnNames: string[], indexName?: string) : TableBuilder; + unique(columnNames: string[], indexName?: string) : TableBuilder; } - + interface CreateTableBuilder extends TableBuilder { } - + interface MySqlTableBuilder extends CreateTableBuilder { engine(val: string): CreateTableBuilder; charset(val: string): CreateTableBuilder; collate(val: string): CreateTableBuilder; } - + interface AlterTableBuilder extends TableBuilder { } - + interface MySqlAlterTableBuilder extends AlterTableBuilder { } - + interface ColumnBuilder { index(indexName?: string): ColumnBuilder; primary(): ColumnBuilder; @@ -367,34 +367,34 @@ declare module "knex" { nullable(): ColumnBuilder; comment(value: string): ColumnBuilder; } - + interface PostgreSqlColumnBuilder extends ColumnBuilder { index(indexName?: string, indexType?: string): ColumnBuilder; } - + interface ReferencingColumnBuilder { inTable(tableName: string): ColumnBuilder; } - + interface AlterColumnBuilder extends ColumnBuilder { } - + interface MySqlAlterColumnBuilder extends AlterColumnBuilder { first(): AlterColumnBuilder; after(columnName: string): AlterColumnBuilder; } - + // // Configurations // - + interface ColumnInfo { defaultValue: Value; type: string; maxLength: number; nullable: boolean; } - + interface Config { debug?: boolean; client?: string; @@ -404,7 +404,7 @@ declare module "knex" { pool?: PoolConfig; migrations?: MigrationConfig; } - + interface ConnectionConfig { host: string; user: string; @@ -412,13 +412,13 @@ declare module "knex" { database: string; debug?: boolean; } - + /** Used with SQLite3 adapter */ interface Sqlite3ConnectionConfig { filename: string; debug?: boolean; } - + interface SocketConnectionConfig { socketPath: string; user: string; @@ -426,7 +426,7 @@ declare module "knex" { database: string; debug?: boolean; } - + interface PoolConfig { name?: string; create?: Function; @@ -443,7 +443,7 @@ declare module "knex" { validate?: Function; log?: boolean; } - + interface MigrationConfig { database?: string; directory?: string; From 1cd9ab5ab036525229281f58309221885cbe419d Mon Sep 17 00:00:00 2001 From: paarth Date: Sun, 13 Dec 2015 16:50:08 -0500 Subject: [PATCH 53/66] Made all entries in WebPreferences interface optional, reflecting documentation --- github-electron/github-electron.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 7c5fa8b4d6..12d53dcc6b 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -450,14 +450,14 @@ declare module GitHubElectron { interface WebPreferences { nodeIntegration?: boolean; preload?: string; - partition: string; - zoomFactor: number; - javascript: boolean; - webSecurity: boolean; - allowDisplayingInsecureContent: boolean; - allowRunningInsecureContent: boolean; - images: boolean; - textAreasAreResizable: boolean; + partition?: string; + zoomFactor?: number; + javascript?: boolean; + webSecurity?: boolean; + allowDisplayingInsecureContent?: boolean; + allowRunningInsecureContent?: boolean; + images?: boolean; + textAreasAreResizable?: boolean; webgl?: boolean; webaudio?: boolean; plugins?: boolean; From 05e67b229d29cc921dd8fd3c42991c897445f547 Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Sat, 12 Dec 2015 23:52:03 +0200 Subject: [PATCH 54/66] Add type definitions for cradle. --- cradle/cradle-tests.ts | 185 +++++++++++++++++++++++++++++++++++++++++ cradle/cradle.d.ts | 122 +++++++++++++++++++++++++++ 2 files changed, 307 insertions(+) create mode 100644 cradle/cradle-tests.ts create mode 100644 cradle/cradle.d.ts diff --git a/cradle/cradle-tests.ts b/cradle/cradle-tests.ts new file mode 100644 index 0000000000..655e92a87b --- /dev/null +++ b/cradle/cradle-tests.ts @@ -0,0 +1,185 @@ +/// + +import cradle = require("cradle"); + +cradle.setup({ + host: 'living-room.couch', + cache: true, + raw: false, + forceSave: true +}); + +const connection = new cradle.Connection(); +const connection2 = new(cradle.Connection); +const connection3 = new(cradle.Connection)('173.45.66.92'); + +connection.databases(function(error, response) {}); +connection.config(function(error, response) {}); +connection.databases(function(error, response) {}); +connection.info(function(error, response) {}); +connection.stats(function(error, response) {}); +connection.activeTasks(function(error, response) {}); +connection.uuids(function(error, response) {}); +connection.uuids(10, function(error, response) {}); +connection.replicate({ + source: "database", + target: "targetDatabase" +}, function(error, response) {}); + +const db = connection.database('starwars'); + +db.exists(function (error, exists) { + if (error) { + console.log('error', error); + } else if (exists) { + console.log('the force is with you.'); + } else { + console.log('database does not exists.'); + db.create(function(error){ + /* do something if there's an erroror */ + /* populate design documents */ + }); + } +}); + +db.get<{ + name: string; +}>('vader', function (error, doc) { + doc.name; // 'Darth Vader' +}); + +db.get('luke', function (error, doc) { + doc.prop; +}); + + db.get(['luke', 'vader'], function (error, doc) { + // + }); + +db.save('skywalker', { + force: 'light', + name: 'Luke Skywalker' +}, function (error, res) { + if (error) { + // Handle erroror + } else { + // Handle success + } +}); + +db.save({ + force: 'dark', name: 'Darth' + }, function (err, res) { + // Handle response + }); + +db.save('luke', '1-94B6F82', { + force: 'dark', name: 'Luke' +}, function (err, res) { + // Handle response +}); + +db.save([ + { name: 'Yoda' }, + { name: 'Han Solo' }, + { name: 'Leia' } +], function (err, res) { + // Handle response +}); + +db.merge('luke', {jedi: true}, function (err, res) { + // Luke is now a jedi, + // but remains on the dark side of the force. +}); + +db.view('characters/all', function (err, res) { + res.forEach(function (row: any) { + console.log("%s is on the %s side of the force.", row.name, row.force); + }); +}); + +db.view('characters/all', {group: true, reduce: true} , function (err, res) { + res.forEach(function (row: any) { + console.log("%s is on the %s side of the force.", row.name, row.force); + }); + }); + + db.temporaryView({ + map: function (doc: any) { + // + } + }, function (err, res) { + if (err) console.log(err); + console.log(res); + }); + +db.remove('luke', '1-94B6F82', function (err, res) { + // Handle response +}); + +db.update('my_designdoc/update_handler_name', 'luke', undefined, { my_param: false }, function (err, res) { + // Handle the response, specified by the update handler +}); + +db.changes(function (err, list) { + list.forEach(function (change) { console.log(change) }); +}); + +db.changes({ since: 42 }, function (err, list) { + // +}); + +const feed = db.changes({ since: 42 }); + +feed.on('change', function (change: any) { + console.log(change); +}); + +const idAndRevData = { + id: 'luke', + rev: 'my-rev' +}; + +const attachmentData = { + name: 'fooAttachment.txt', + 'Content-Type': 'text/plain', + body: 'Foo document text' +}; + +db.saveAttachment(idAndRevData, attachmentData, function (err, reply) { + if (err) { + console.dir(err) + return + } + console.dir(reply) +}); + + +db.getAttachment('luke', 'foo.txt', function (err, reply) { + if (err) { + console.dir(err); + return; + } + console.dir(reply); +}); + +db.removeAttachment('luke', 'foo.txt', function (err, reply) { + if (err) { + console.dir(err); + return; + } + console.dir(reply); +}); + +db.info(function(error, response) {}); +db.all(function(error, response) {}); +db.all({ + body: { + keys: ['key1', 'key2'] + } +}, function(error, response) {}); +db.compact(function(error, response) {}); +db.compact('design', function(error, response) {}); +db.viewCleanup(function(error, response) {}); +db.replicate('database', function(error, response) {}); +db.replicate('database', {}, function(error, response) {}); diff --git a/cradle/cradle.d.ts b/cradle/cradle.d.ts new file mode 100644 index 0000000000..6434af26c5 --- /dev/null +++ b/cradle/cradle.d.ts @@ -0,0 +1,122 @@ +// Type definitions for cradle +// Project: https://github.com/flatiron/cradle +// Definitions by: Panu Horsmalahti +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "cradle" { + interface Options { + host?: string; + hostname?: string; + cache?: boolean; + raw?: boolean; + forceSave?: boolean; + auth?: string | { + username: string; + password: string; + } + ca?: string; + secure?: boolean; + retries?: number; + retryTimeout?: number; + maxSockets?: number; + } + + interface Callback { + (error: any, response: any): void; + } + + interface ErrorCallback { + (error: any): void; + } + + export class Connection { + constructor(uri?: string, port?: number, options?: Options); + database(name: string): Database; + databases(Callback: Callback): void; + config(callback: Callback): void; + info(callback: Callback): void; + stats(callback: Callback): void; + activeTasks(callback: Callback): void; + uuids(callback: Callback): void; + uuids(count: number, callback: Callback): void; + replicate(options: { + source: string | { + url: string; + }; + target: string | { + url: string; + }; + cancel?: boolean; + continuous?: boolean; + create_target?: boolean; + doc_ids?: string[]; + filter?: string; + proxy?: string; + query_params?: any; + }, callback: Callback): void; + } + + export interface ChangesOptions { + since: number; + } + + export class Database { + name: string; + get(id: string, callback: (error: any, document: any) => void): void; + get(id: string, callback: (error: any, document: T) => void): void; + get(id: string, rev: string, callback: (error: any, document: any) => void): void; + get(id: string, rev: string, callback: (error: any, document: T) => void): void; + get(ids: string[], callback: Callback): void; + save(document: any, callback: Callback): void; + save(id: string, document: any, callback: Callback): void; + save(id: string, revision: string, document: any, + callback: Callback): void; + save(document: T, callback: Callback): void; + save(id: string, document: T, callback: Callback): void; + save(id: string, revision: string, document: T, + callback: Callback): void; + save(documents: any[], callback: Callback): void; + merge(id: string, document: any, callback: Callback): void; + merge(id: string, document: T, callback: Callback): void; + remove(id: string, revision: string, callback: Callback): void; + update(name: string, id: string, queryObject: any, documentBody: any, + callback: Callback): void; + view(name: string, callback: Callback): void; + view(name: string, options: { + group?: boolean; + reduce?: boolean; + key?: string; + startkey?: any; + endkey?: any; + include_docs?: boolean; + limit?: number; + descending?: boolean; + }, callback: Callback): void; + temporaryView(view: any, callback: Callback): void; + create(callback: ErrorCallback): void; + exists(callback: (error: any, exists: boolean) => void): void; + destroy(callback: ErrorCallback): void; + changes(options: ChangesOptions): any; + changes(callback: (error: any, list: any[]) => void): void; + changes(options: ChangesOptions, callback: (error: any, + list: any[]) => void): void; + saveAttachment(idAndRevData: { + id: string; + rev: string; + }, attachmentData: any, callback: Callback): void; + getAttachment(id: string, attachmentName: string, + callback: Callback): void; + removeAttachment(id: string, attachmentName: string, + callback: Callback): void; + info(callback: Callback): void; + all(callback: Callback): void; + all(options: any, callback: Callback): void; + compact(callback: Callback): void; + compact(design: string, callback: Callback): void; + viewCleanup(callback: Callback): void; + replicate(target: string, callback: Callback): void; + replicate(target: string, options: any, callback: Callback): void; + } + + export function setup(options: Options): void; +} From 6b0270532cfa5f83a309ff2b490a5f83ae3df9c4 Mon Sep 17 00:00:00 2001 From: Max Shmelev Date: Mon, 14 Dec 2015 10:32:03 -0500 Subject: [PATCH 55/66] Add 'opts' function definition --- restify/restify-tests.ts | 2 ++ restify/restify.d.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/restify/restify-tests.ts b/restify/restify-tests.ts index 3e0697c1d4..ca3c5000ef 100644 --- a/restify/restify-tests.ts +++ b/restify/restify-tests.ts @@ -92,12 +92,14 @@ server.put( '/hello', send); server.del( '/hello', send); server.get( '/hello', send); server.head('/hello', send); +server.opts('/hello', send); server.post(/(.*)/, send); server.put( /(.*)/, send); server.del( /(.*)/, send); server.get( /(.*)/, send); server.head(/(.*)/, send); +server.opts(/(.*)/, send); new restify.BadRequestError(); diff --git a/restify/restify.d.ts b/restify/restify.d.ts index d3e5e35f83..c523810eec 100644 --- a/restify/restify.d.ts +++ b/restify/restify.d.ts @@ -87,6 +87,11 @@ declare module "restify" { head(route: any, routeCallBack: RequestHandler, ...routeCallBacks: RequestHandler[][]): any; head(route: any, routeCallBack: RequestHandler[], ...routeCallBacks: RequestHandler[][]): any; + opts(route: any, routeCallBack: RequestHandler, ...routeCallBacks: RequestHandler[]): any; + opts(route: any, routeCallBack: RequestHandler[], ...routeCallBacks: RequestHandler[]): any; + opts(route: any, routeCallBack: RequestHandler, ...routeCallBacks: RequestHandler[][]): any; + opts(route: any, routeCallBack: RequestHandler[], ...routeCallBacks: RequestHandler[][]): any; + name: string; version: string; log: Object; From 4c528224a3028e1206c68b5ac3eb067570292fb8 Mon Sep 17 00:00:00 2001 From: John Grimsey Date: Mon, 14 Dec 2015 17:21:56 +0000 Subject: [PATCH 56/66] Adds email-addresses definitions --- email-addresses/email-addresses.d.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 email-addresses/email-addresses.d.ts diff --git a/email-addresses/email-addresses.d.ts b/email-addresses/email-addresses.d.ts new file mode 100644 index 0000000000..2d734add09 --- /dev/null +++ b/email-addresses/email-addresses.d.ts @@ -0,0 +1,4 @@ +declare module "email-addresses" { + function parseOneAddress(opts: any): Object; + function parseAddressList(opts: any): Object; +} From 6eb5b9091e10bd8b1bb2b22fa3c7c09dfe6fb0e5 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 14 Dec 2015 22:36:44 +0500 Subject: [PATCH 57/66] lodash: signatures of _.isRegExp have been changed --- lodash/lodash-tests.ts | 40 ++++++++++++++++++++++++++++------------ lodash/lodash.d.ts | 8 ++++++++ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2d244b16e5..f493b42607 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5635,18 +5635,34 @@ result = _([]).isPlainObject(); result = _({}).isPlainObject(); // _.isRegExp -result = _.isRegExp(any); -result = _(1).isRegExp(); -result = _([]).isRegExp(); -result = _({}).isRegExp(); -{ - let value: RegExp|string = /^foo$/g; - if (_.isRegExp(value)) { - let regex: RegExp = value; - let index: number = value.exec("foo").index; - } else { - let result: string = value; - } +module TestIsRegExp { + { + let value: number|RegExp; + + if (_.isRegExp(value)) { + let result: RegExp = value; + } + else { + let result: number = value; + } + } + + { + let result: boolean; + + result = _.isRegExp(any); + result = _(1).isRegExp(); + result = _([]).isRegExp(); + result = _({}).isRegExp(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().isRegExp(); + result = _([]).chain().isRegExp(); + result = _({}).chain().isRegExp(); + } } // _.isString diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 8425f1d823..350757ded5 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9605,6 +9605,7 @@ declare module _ { /** * Checks if value is classified as a RegExp object. * @param value The value to check. + * * @return Returns true if value is correctly classified, else false. */ isRegExp(value?: any): value is RegExp; @@ -9617,6 +9618,13 @@ declare module _ { isRegExp(): boolean; } + interface LoDashExplicitWrapperBase { + /** + * see _.isRegExp + */ + isRegExp(): LoDashExplicitWrapper; + } + //_.isString interface LoDashStatic { /** From 0402bee151f6524974557d3fe5ea990402e03e29 Mon Sep 17 00:00:00 2001 From: John Grimsey Date: Mon, 14 Dec 2015 17:21:56 +0000 Subject: [PATCH 58/66] - Adds email-addresses definitions - Adds tests and header --- email-addresses/email-addresses-tests.ts | 8 ++++++++ email-addresses/email-addresses.d.ts | 9 +++++++++ 2 files changed, 17 insertions(+) create mode 100644 email-addresses/email-addresses-tests.ts create mode 100644 email-addresses/email-addresses.d.ts diff --git a/email-addresses/email-addresses-tests.ts b/email-addresses/email-addresses-tests.ts new file mode 100644 index 0000000000..b43289d86c --- /dev/null +++ b/email-addresses/email-addresses-tests.ts @@ -0,0 +1,8 @@ +/// + +import addrs = require('email-addresses'); + +var result: Object; + +result = addrs.parseOneAddress('Jack Bowman '); +result = addrs.parseAddressList(['foo@bar.com', 'Foo Bar ']); diff --git a/email-addresses/email-addresses.d.ts b/email-addresses/email-addresses.d.ts new file mode 100644 index 0000000000..ccd0495303 --- /dev/null +++ b/email-addresses/email-addresses.d.ts @@ -0,0 +1,9 @@ +// Type definitions for email-addresses 2.0.1 +// Project: https://github.com/jackbowman/email-addresses +// Definitions by: John Grimsey +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "email-addresses" { + export function parseOneAddress(opts: any): Object; + export function parseAddressList(opts: any): Object; +} From dabf57f42e7854c15f239ef0b2e81166c0f0e553 Mon Sep 17 00:00:00 2001 From: Ben Joffe Date: Tue, 15 Dec 2015 21:21:41 +1100 Subject: [PATCH 59/66] Fixed THREEJS CubeTextureLoader.load and TextureLoader.load --- threejs/three.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index fb890afe6a..45bc1b4abd 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -1959,7 +1959,7 @@ declare module THREE { constructor(manager?: LoadingManager); manager: LoadingManager; - load(url: string, onLoad: (texture: CubeTexture) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void; + load(urls: Array, onLoad?: (texture: CubeTexture) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void; setCrossOrigin(crossOrigin: string): void; } @@ -2076,7 +2076,7 @@ declare module THREE { * * @param url */ - load(url: string, onLoad: (texture: Texture) => void): Texture; + load(url: string, onLoad?: (texture: Texture) => void): Texture; setCrossOrigin(crossOrigin: string): void; } From a7054eca4ee3bba7f7924fedc92b1b467bb7467e Mon Sep 17 00:00:00 2001 From: sodatea Date: Wed, 16 Dec 2015 12:23:18 +0800 Subject: [PATCH 60/66] Add definitions for blue-tape 0.1.11 --- blue-tape/blue-tape-tests.ts | 170 +++++++++++++++++++++++++++++++++++ blue-tape/blue-tape.d.ts | 12 +++ 2 files changed, 182 insertions(+) create mode 100644 blue-tape/blue-tape-tests.ts create mode 100644 blue-tape/blue-tape.d.ts diff --git a/blue-tape/blue-tape-tests.ts b/blue-tape/blue-tape-tests.ts new file mode 100644 index 0000000000..a01675a1c5 --- /dev/null +++ b/blue-tape/blue-tape-tests.ts @@ -0,0 +1,170 @@ +/// +/// +/// + +import tape = require('blue-tape'); +import P = require('bluebird'); + +var name: string; +var cb: tape.TestCase; +var opts: tape.TestOptions; +var t: tape.Test; + +tape(cb); +tape(name, cb); +tape(opts, cb); +tape(name, opts, cb); + +tape(name, (test: tape.Test) => { + t = test; +}); + +tape.skip(name, cb); +tape.only(name, cb); + + +var sopts: tape.StreamOptions; +var rs: NodeJS.ReadableStream; +rs = tape.createStream(); +rs = tape.createStream(sopts); + + +var htest: typeof tape; +htest = tape.createHarness(); + + +tape(name, (test: tape.Test) => { + var num: number; + var ms: number; + var value: any; + var actual: any; + var expected: any; + var err: any; + var fn = function() {}; + var msg: string; + + var exceptionExpected: RegExp | (() => void); + + test.plan(num); + test.end(); + test.end(err); + + test.fail(msg); + test.pass(msg); + test.timeoutAfter(ms); + test.skip(msg); + + test.ok(value); + test.ok(value, msg); + test.true(value); + test.true(value, msg); + test.assert(value); + test.assert(value, msg); + + test.notOk(value); + test.notOk(value, msg); + test.false(value); + test.false(value, msg); + test.notok(value); + test.notok(value, msg); + + test.error(err, msg); + test.ifError(err, msg); + test.ifErr(err, msg); + test.iferror(err, msg); + + test.equal(actual, expected); + test.equal(actual, expected, msg); + test.equals(actual, expected); + test.equals(actual, expected, msg); + test.isEqual(actual, expected); + test.isEqual(actual, expected, msg); + test.is(actual, expected); + test.is(actual, expected, msg); + test.strictEqual(actual, expected); + test.strictEqual(actual, expected, msg); + test.strictEquals(actual, expected); + test.strictEquals(actual, expected, msg); + + test.notEqual(actual, expected); + test.notEqual(actual, expected, msg); + test.notEquals(actual, expected); + test.notEquals(actual, expected, msg); + test.notStrictEqual(actual, expected); + test.notStrictEqual(actual, expected, msg); + test.notStrictEquals(actual, expected); + test.notStrictEquals(actual, expected, msg); + test.isNotEqual(actual, expected); + test.isNotEqual(actual, expected, msg); + test.isNot(actual, expected); + test.isNot(actual, expected, msg); + test.not(actual, expected); + test.not(actual, expected, msg); + test.doesNotEqual(actual, expected); + test.doesNotEqual(actual, expected, msg); + test.isInequal(actual, expected); + test.isInequal(actual, expected, msg); + + test.deepEqual(actual, expected); + test.deepEqual(actual, expected, msg); + test.deepEquals(actual, expected); + test.deepEquals(actual, expected, msg); + test.isEquivalent(actual, expected); + test.isEquivalent(actual, expected, msg); + test.same(actual, expected); + test.same(actual, expected, msg); + + test.notDeepEqual(actual, expected); + test.notDeepEqual(actual, expected, msg); + test.notEquivalent(actual, expected); + test.notEquivalent(actual, expected, msg); + test.notDeeply(actual, expected); + test.notDeeply(actual, expected, msg); + test.notSame(actual, expected); + test.notSame(actual, expected, msg); + test.isNotDeepEqual(actual, expected); + test.isNotDeepEqual(actual, expected, msg); + test.isNotDeeply(actual, expected); + test.isNotDeeply(actual, expected, msg); + test.isNotEquivalent(actual, expected); + test.isNotEquivalent(actual, expected, msg); + test.isInequivalent(actual, expected); + test.isInequivalent(actual, expected, msg); + + test.deepLooseEqual(actual, expected); + test.deepLooseEqual(actual, expected, msg); + test.looseEqual(actual, expected); + test.looseEqual(actual, expected, msg); + test.looseEquals(actual, expected); + test.looseEquals(actual, expected, msg); + + test.notDeepLooseEqual(actual, expected); + test.notDeepLooseEqual(actual, expected, msg); + test.notLooseEqual(actual, expected); + test.notLooseEqual(actual, expected, msg); + test.notLooseEquals(actual, expected); + test.notLooseEquals(actual, expected, msg); + + test.throws(fn); + test.throws(fn, msg); + test.throws(fn, exceptionExpected); + test.throws(fn, exceptionExpected, msg); + + test.doesNotThrow(fn); + test.doesNotThrow(fn, msg); + test.doesNotThrow(fn, exceptionExpected); + test.doesNotThrow(fn, exceptionExpected, msg); + + test.test(name, (st) => { + t = st; + }); + + test.comment(msg); +}); + +tape('simple delay', (test) => P.delay(1)); + +tape('nested tests with promises', function(test) { + test.test('delay1', () => P.delay(1) ); + test.test('delay2', () => P.delay(1) ); +}); diff --git a/blue-tape/blue-tape.d.ts b/blue-tape/blue-tape.d.ts new file mode 100644 index 0000000000..50bf0aab8d --- /dev/null +++ b/blue-tape/blue-tape.d.ts @@ -0,0 +1,12 @@ +// Type definitions for blue-tape v0.1.11 +// Project: https://github.com/spion/blue-tape +// Definitions by: Haoqun Jiang +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module 'blue-tape' { + import tape = require('tape'); + export = tape; +} From e5f4e76f6b9cd219fa2b89d33e03fd2507c60461 Mon Sep 17 00:00:00 2001 From: Denis Sokolov Date: Wed, 16 Dec 2015 09:38:22 +0200 Subject: [PATCH 61/66] Properly name debounce test file --- debounce/{debounce.ts => debounce-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename debounce/{debounce.ts => debounce-tests.ts} (100%) diff --git a/debounce/debounce.ts b/debounce/debounce-tests.ts similarity index 100% rename from debounce/debounce.ts rename to debounce/debounce-tests.ts From 4af65b04e8293bfefccab7218dc5f3c1df8233a4 Mon Sep 17 00:00:00 2001 From: Denis Sokolov Date: Wed, 16 Dec 2015 09:54:46 +0200 Subject: [PATCH 62/66] Fix debounce test syntax --- debounce/debounce-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debounce/debounce-tests.ts b/debounce/debounce-tests.ts index fb0e52b467..947fbcdae5 100644 --- a/debounce/debounce-tests.ts +++ b/debounce/debounce-tests.ts @@ -1,6 +1,6 @@ /// -import debounce = require("debounce"); +import debounce from "debounce"; const doThings = () => 1; From 336361b4e23da3f5e8b2181f9fc715213685d159 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Dec 2015 18:09:23 -0800 Subject: [PATCH 63/66] Added 'temp'. --- temp/temp-tests.ts | 67 ++++++++++++++++++++++++++++++++++++++++++++++ temp/temp.d.ts | 43 +++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 temp/temp-tests.ts create mode 100644 temp/temp.d.ts diff --git a/temp/temp-tests.ts b/temp/temp-tests.ts new file mode 100644 index 0000000000..eddf870a4f --- /dev/null +++ b/temp/temp-tests.ts @@ -0,0 +1,67 @@ +// Author: Daniel Rosenwasser + +/// + +import * as temp from "temp"; + +function testCleanup() { + temp.cleanup(result => { + if (typeof result === "boolean") { + const x = result === true; + } + else { + const { files, dirs } = result; + } + }); +} + +function testCleanupSync() { + const cleanupResult = temp.cleanupSync() + if (typeof cleanupResult === "boolean") { + const x = cleanupResult === true; + } + else { + const { dirs, files } = cleanupResult + } +} + +function testOpen() { + temp.open({ dir: "tempDir", prefix: "pref", suffix: "suff" }, (err, result) => { + const { path, fd } = result; + }); + + temp.open("strPrefix", (err, result) => { + const { path, fd } = result; + }); +} + +function testOpenSync() { + const { fd: openFd1, path: openPath1 } = temp.openSync({ dir: "tempDir", prefix: "pref", suffix: "suff" }); + const { fd: openFd2, path: openPath2 } = temp.openSync("str"); +} + +function testCreateWriteStream() { + const stream = temp.createWriteStream("HelloStreamAffix"); + stream.write("data"); +} + +function testMkDir() { + temp.mkDir("prefix", (err, dirPath) => { + dirPath.length; + }); +} + +function testMkDirSync() { + const result = temp.mkDirSync("prefix"); + result.length; +} + +function testPath() { + temp.path({ suffix: "justSuffix" }, "defaultPrefix"); +} + +function testTrack() { + const tempChained = temp.track(true).track(false); + tempChained.dir; + tempChained.cleanupSync(); +} \ No newline at end of file diff --git a/temp/temp.d.ts b/temp/temp.d.ts new file mode 100644 index 0000000000..ea8f33d9d1 --- /dev/null +++ b/temp/temp.d.ts @@ -0,0 +1,43 @@ +// Type definitions for temp 0.8.3 +// Project: https://www.npmjs.com/package/temp, https://github.com/bruce/node-temp +// Definitions by: Daniel Rosenwasser +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "temp" { + import * as temp from "temp"; + import * as fs from "fs"; + + export interface AffixOptions { + prefix?: string; + suffix?: string; + dir?: string; + } + + export var dir: string; + + export function track(value: boolean): typeof temp; + + export function mkDir(affixes: string, callback?: (err: any, dirPath: string) => void); + export function mkDir(affixes: AffixOptions, callback?: (err: any, dirPath: string) => void); + + export function mkDirSync(affixes: string): string; + export function mkDirSync(affixes: AffixOptions): string; + + export function open(affixes: string, callback?: (err: any, result: {path: string, fd: number}) => void); + export function open(affixes: AffixOptions, callback?: (err: any, result: {path: string, fd: number}) => void); + + export function openSync(affixes: string): { path: string, fd: number }; + export function openSync(affixes: AffixOptions): { path: string, fd: number }; + + export function path(affixes: string, defaultPrefix: string); + export function path(affixes: AffixOptions, defaultPrefix: string); + + export function cleanup(callback?: (result: boolean | {files: number, dirs?: number}) => void); + + export function cleanupSync(): boolean | {files: number, dirs: number}; + + export function createWriteStream(affixes: string): fs.WriteStream; + export function createWriteStream(affixes: AffixOptions): fs.WriteStream; +} \ No newline at end of file From 230dcd425bd9e818df6cdc1ff9f29d5368123031 Mon Sep 17 00:00:00 2001 From: Joshua Filby Date: Wed, 16 Dec 2015 21:05:01 -0600 Subject: [PATCH 64/66] Add bcryptjs definitions and tests --- bcryptjs/bcryptjs-tests.ts | 54 +++++++++++++++++++++++++ bcryptjs/bcryptjs.d.ts | 82 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 bcryptjs/bcryptjs-tests.ts create mode 100644 bcryptjs/bcryptjs.d.ts diff --git a/bcryptjs/bcryptjs-tests.ts b/bcryptjs/bcryptjs-tests.ts new file mode 100644 index 0000000000..acfc48e439 --- /dev/null +++ b/bcryptjs/bcryptjs-tests.ts @@ -0,0 +1,54 @@ +/// + +import bcryptjs = require("bcryptjs"); + +let str: string; +let num: number; +let bool: boolean; + +str = bcryptjs.genSaltSync(); +str = bcryptjs.genSaltSync(10); + +bcryptjs.genSalt((err: Error, salt: string) => { + str = salt; +}); +bcryptjs.genSalt(10, (err: Error, salt: string) => { + str = salt; +}); + +str = bcryptjs.hashSync("string"); +str = bcryptjs.hashSync("string", 10); +str = bcryptjs.hashSync("string", "salt"); + +bcryptjs.hash("string", 10, (err: Error, hash: string) => { + str = hash; +}); +bcryptjs.hash("string", 10, (err: Error, hash: string) => { + str = hash; +}, (percent: number) => { + num = percent; +}); + +bcryptjs.hash("string", "salt", (err: Error, hash: string) => { + str = hash; +}); +bcryptjs.hash("string", "salt", (err: Error, hash: string) => { + str = hash; +}, (percent: number) => { + num = percent; +}); + +bool = bcryptjs.compareSync("string1", "string2"); + +bcryptjs.compare("string1", "string2", (err: Error, success: boolean) => { + bool = success; +}); +bcryptjs.compare("string1", "string2", (err: Error, success: boolean) => { + bool = success; +}, (percent: number) => { + num = percent; +}); + +num = bcryptjs.getRounds("string"); + +str = bcryptjs.getSalt("string"); diff --git a/bcryptjs/bcryptjs.d.ts b/bcryptjs/bcryptjs.d.ts new file mode 100644 index 0000000000..3d3128d022 --- /dev/null +++ b/bcryptjs/bcryptjs.d.ts @@ -0,0 +1,82 @@ +// Type definitions for bcryptjs v2.3.0 +// Project: https://github.com/dcodeIO/bcrypt.js +// Definitions by: Joshua Filby +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "bcryptjs" { + + /** + * Sets the pseudo random number generator to use as a fallback if neither node's crypto module nor the Web Crypto API is available. + * Please note: It is highly important that the PRNG used is cryptographically secure and that it is seeded properly! + * @param random Function taking the number of bytes to generate as its sole argument, returning the corresponding array of cryptographically secure random byte values. + */ + export function setRandomFallback(random: (random: number) => number[]): void; + + /** + * Synchronously generates a salt. + * @param rounds Number of rounds to use, defaults to 10 if omitted + * @return Resulting salt + */ + export function genSaltSync(rounds?: number): string; + + /** + * Asynchronously generates a salt. + * @param callback Callback receiving the error, if any, and the resulting salt + */ + export function genSalt(callback: (err: Error, salt: string) => void): void; + + /** + * Asynchronously generates a salt. + * @param rounds Number of rounds to use, defaults to 10 if omitted + * @param callback Callback receiving the error, if any, and the resulting salt + */ + export function genSalt(rounds: number, callback: (err: Error, salt: string) => void): void; + + /** + * Synchronously generates a hash for the given string. + * @param s String to hash + * @param salt Salt length to generate or salt to use, default to 10 + * @return Resulting hash + */ + export function hashSync(s: string, salt?: number | string): string; + + /** + * Asynchronously generates a hash for the given string. + * @param s String to hash + * @param salt Salt length to generate or salt to use + * @param callback Callback receiving the error, if any, and the resulting hash + * @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms. + */ + export function hash(s: string, salt: number | string, callback: (err: Error, hash: string) => void, progressCallback?: (percent: number) => void): void; + + /** + * Synchronously tests a string against a hash. + * @param s String to compare + * @param hash Hash to test against + * @return true if matching, otherwise false + */ + export function compareSync(s: string, hash: string): boolean; + + /** + * Asynchronously compares the given data against the given hash. + * @param s Data to compare + * @param hash Data to be compared to + * @param callback Callback receiving the error, if any, otherwise the result + * @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms. + */ + export function compare(s: string, hash: string, callback: (err: Error, success: boolean) => void, progressCallback?: (percent: number) => void): void; + + /** + * Gets the number of rounds used to encrypt the specified hash. + * @param hash Hash to extract the used number of rounds from + * @return Number of rounds used + */ + export function getRounds(hash: string): number; + + /** + * Gets the salt portion from a hash. Does not validate the hash. + * @param hash Hash to extract the salt from + * @return Extracted salt part + */ + export function getSalt(hash: string): string; +} From 8c0469357cd869d2766948d84a34561c5b8bd5c5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Dec 2015 23:42:23 -0800 Subject: [PATCH 65/66] Made non-synchronous functions return 'void'. --- temp/temp.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/temp/temp.d.ts b/temp/temp.d.ts index ea8f33d9d1..3d37bf0c5b 100644 --- a/temp/temp.d.ts +++ b/temp/temp.d.ts @@ -19,22 +19,22 @@ declare module "temp" { export function track(value: boolean): typeof temp; - export function mkDir(affixes: string, callback?: (err: any, dirPath: string) => void); - export function mkDir(affixes: AffixOptions, callback?: (err: any, dirPath: string) => void); + export function mkDir(affixes: string, callback?: (err: any, dirPath: string) => void): void; + export function mkDir(affixes: AffixOptions, callback?: (err: any, dirPath: string) => void): void; export function mkDirSync(affixes: string): string; export function mkDirSync(affixes: AffixOptions): string; - export function open(affixes: string, callback?: (err: any, result: {path: string, fd: number}) => void); - export function open(affixes: AffixOptions, callback?: (err: any, result: {path: string, fd: number}) => void); + export function open(affixes: string, callback?: (err: any, result: {path: string, fd: number}) => void): void; + export function open(affixes: AffixOptions, callback?: (err: any, result: {path: string, fd: number}) => void): void; export function openSync(affixes: string): { path: string, fd: number }; export function openSync(affixes: AffixOptions): { path: string, fd: number }; - export function path(affixes: string, defaultPrefix: string); - export function path(affixes: AffixOptions, defaultPrefix: string); + export function path(affixes: string, defaultPrefix: string): void; + export function path(affixes: AffixOptions, defaultPrefix: string): void; - export function cleanup(callback?: (result: boolean | {files: number, dirs?: number}) => void); + export function cleanup(callback?: (result: boolean | {files: number, dirs?: number}) => void): void; export function cleanupSync(): boolean | {files: number, dirs: number}; From f83d1a72867c72e1a1b38f11727fed41cb11222e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Dec 2015 10:25:55 -0800 Subject: [PATCH 66/66] Fix casing for 'mkdir', return type of 'path', optionality of 'track' parameter. --- temp/temp-tests.ts | 21 +++++++++++++++------ temp/temp.d.ts | 14 +++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/temp/temp-tests.ts b/temp/temp-tests.ts index eddf870a4f..be25d357bb 100644 --- a/temp/temp-tests.ts +++ b/temp/temp-tests.ts @@ -11,6 +11,8 @@ function testCleanup() { } else { const { files, dirs } = result; + files.toPrecision(4); + files.toPrecision(4); } }); } @@ -22,16 +24,22 @@ function testCleanupSync() { } else { const { dirs, files } = cleanupResult + dirs.toPrecision(4); + files.toPrecision(4); } } function testOpen() { temp.open({ dir: "tempDir", prefix: "pref", suffix: "suff" }, (err, result) => { const { path, fd } = result; + path.length; + fd.toPrecision(5); }); temp.open("strPrefix", (err, result) => { const { path, fd } = result; + path.length; + fd.toPrecision(5); }); } @@ -45,23 +53,24 @@ function testCreateWriteStream() { stream.write("data"); } -function testMkDir() { - temp.mkDir("prefix", (err, dirPath) => { +function testMkdir() { + temp.mkdir("prefix", (err, dirPath) => { dirPath.length; }); } -function testMkDirSync() { - const result = temp.mkDirSync("prefix"); +function testMkdirSync() { + const result = temp.mkdirSync("prefix"); result.length; } function testPath() { - temp.path({ suffix: "justSuffix" }, "defaultPrefix"); + const p = temp.path({ suffix: "justSuffix" }, "defaultPrefix"); + p.length; } function testTrack() { - const tempChained = temp.track(true).track(false); + const tempChained = temp.track().track(true).track(false); tempChained.dir; tempChained.cleanupSync(); } \ No newline at end of file diff --git a/temp/temp.d.ts b/temp/temp.d.ts index 3d37bf0c5b..7cd51d2be5 100644 --- a/temp/temp.d.ts +++ b/temp/temp.d.ts @@ -17,13 +17,13 @@ declare module "temp" { export var dir: string; - export function track(value: boolean): typeof temp; + export function track(value?: boolean): typeof temp; - export function mkDir(affixes: string, callback?: (err: any, dirPath: string) => void): void; - export function mkDir(affixes: AffixOptions, callback?: (err: any, dirPath: string) => void): void; + export function mkdir(affixes: string, callback?: (err: any, dirPath: string) => void): void; + export function mkdir(affixes: AffixOptions, callback?: (err: any, dirPath: string) => void): void; - export function mkDirSync(affixes: string): string; - export function mkDirSync(affixes: AffixOptions): string; + export function mkdirSync(affixes: string): string; + export function mkdirSync(affixes: AffixOptions): string; export function open(affixes: string, callback?: (err: any, result: {path: string, fd: number}) => void): void; export function open(affixes: AffixOptions, callback?: (err: any, result: {path: string, fd: number}) => void): void; @@ -31,8 +31,8 @@ declare module "temp" { export function openSync(affixes: string): { path: string, fd: number }; export function openSync(affixes: AffixOptions): { path: string, fd: number }; - export function path(affixes: string, defaultPrefix: string): void; - export function path(affixes: AffixOptions, defaultPrefix: string): void; + export function path(affixes: string, defaultPrefix: string): string; + export function path(affixes: AffixOptions, defaultPrefix: string): string; export function cleanup(callback?: (result: boolean | {files: number, dirs?: number}) => void): void;