From 88b29b7995a27a11dfc241cb236c926e151b0a3e Mon Sep 17 00:00:00 2001 From: Alexey Gorshkov Date: Mon, 11 May 2015 01:51:24 +0300 Subject: [PATCH 001/353] Added jsurl --- jsurl/jsurl-tests.ts | 67 ++++++++++++++++++++++++++++++++++++++++++++ jsurl/jsurl.d.ts | 18 ++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 jsurl/jsurl-tests.ts create mode 100644 jsurl/jsurl.d.ts diff --git a/jsurl/jsurl-tests.ts b/jsurl/jsurl-tests.ts new file mode 100644 index 000000000..f573feb49 --- /dev/null +++ b/jsurl/jsurl-tests.ts @@ -0,0 +1,67 @@ +/// + +var u = new Url; // curent document URL will be used +// or we can instantiate as +var u2 = new Url("http://example.com/some/path?a=b&c=d#someAnchor"); +// it should support relative URLs also +var u3 = new Url("/my/site/doc/path?foo=bar#baz"); + +// get the value of some query string parameter +alert(u2.query.a); +// or +alert(u3.query["foo"]); + +// Manupulating query string parameters +u.query.a = [1, 2, 3]; // adds/replaces in query string params a=1&a=2&a=3 +u.query.b = 'woohoo'; // adds/replaces in query string param b=woohoo + +if (u.query.a instanceof Array) { // the way to add a parameter + u.query.a.push(4); // now it's "a=1&a=2&a=3&a=4&b=woohoo" +} + +else { // if not an array but scalar value here is a way how to convert to array + u.query.a = [u.query.a]; + u.query.a.push(8) +} + + +// The way to remove the parameter: +delete u.query.a +// or: +delete u.query["a"] + +// If you need to remove all query string params: +u.query.clear(); +alert(u); + +// Lookup URL parts: +alert( + 'protocol = ' + u.protocol + '\n' + + 'user = ' + u.user + '\n' + + 'pass = ' + u.pass + '\n' + + 'host = ' + u.host + '\n' + + 'port = ' + u.port + '\n' + + 'path = ' + u.path + '\n' + + 'query = ' + u.query + '\n' + + 'hash = ' + u.hash + ); + +// Manipulating URL parts +u.path = '/some/new/path'; // the way to change URL path +u.protocol = 'https' // the way to force https protocol on the source URL + +// inject into string +var str = 'My Cool Link'; + +// or use in DOM context +var a = document.createElement('a'); +a.href = u; +a.innerHTML = 'test'; +document.body.appendChild(a); + +// Stringify +u += ''; +String(u); +u.toString(); +// NOTE, that usually it will be done automatically, so only in special +// cases direct stringify is required \ No newline at end of file diff --git a/jsurl/jsurl.d.ts b/jsurl/jsurl.d.ts new file mode 100644 index 000000000..a5f790257 --- /dev/null +++ b/jsurl/jsurl.d.ts @@ -0,0 +1,18 @@ +// Type definitions for jsurl 1.2.2 +// Project: https://github.com/Mikhus/jsurl +// Definitions by: Alexey Gorshkov +// Definitions: https://github.com/agorshkov23/DefinitelyTyped + +declare class Url { + constructor(url?: string); + query: any; + protocol: string; + user: string; + pass: string; + host: string; + port: string; + path: string; + hash: string; + href: string; + toString(): string; +} \ No newline at end of file From e4ff04e164e36ee9a9de52268be208f4a162c36e Mon Sep 17 00:00:00 2001 From: lgrignon Date: Mon, 14 Sep 2015 10:56:09 +0200 Subject: [PATCH 002/353] 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 000000000..4f44de6d2 --- /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 003/353] 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 000000000..b0a554828 --- /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 004/353] 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 b0a554828..e0af97e1d 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 005/353] 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 e0af97e1d..5696fa3d9 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 4f44de6d2..cd96dfe21 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 006/353] 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 5696fa3d9..122c47587 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 007/353] 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 122c47587..000000000 --- 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 008/353] 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 000000000..122c47587 --- /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 75e8c438092a15804594e46bc82973b86bed3e22 Mon Sep 17 00:00:00 2001 From: AllBogs Date: Wed, 4 Nov 2015 10:10:29 +0100 Subject: [PATCH 009/353] Update snapsvg.d.ts Seemed to be some confusion between the functions "Matrix()" (argument-less constructor function) and "matrix()" (utility function that takes arguments and returns a Matrix object). --- snapsvg/snapsvg.d.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/snapsvg/snapsvg.d.ts b/snapsvg/snapsvg.d.ts index aff964a6d..6543eaa90 100644 --- a/snapsvg/snapsvg.d.ts +++ b/snapsvg/snapsvg.d.ts @@ -15,7 +15,7 @@ declare module mina { } export interface AnimationDescriptor { - id: string; + id: string; start: number; end: number; b: number; @@ -35,7 +35,7 @@ declare module mina { pause(): void; resume(): void; update(): void; - } + } export function backin(n:number):number; export function backout(n:number):number; @@ -57,8 +57,9 @@ declare module Snap { export var filter:Filter; export var path:Path; - export function Matrix(a:number,b:number,c:number,d:number,e:number,f:number):Matrix; - export function Matrix(svgMatrix:SVGMatrix):Matrix; + export function Matrix():void; + export function matrix(a:number,b:number,c:number,d:number,e:number,f:number):Matrix; + export function matrix(svgMatrix:SVGMatrix):Matrix; export function ajax(url:string,postData:string,callback:Function,scope?:Object):XMLHttpRequest; export function ajax(url:string,postData:Object,callback:Function,scope?:Object):XMLHttpRequest; From 344ad0763e4fd64c431b2169bdc93ea045dfdb63 Mon Sep 17 00:00:00 2001 From: AllBogs Date: Wed, 4 Nov 2015 10:23:57 +0100 Subject: [PATCH 010/353] Update snapsvg.d.ts --- snapsvg/snapsvg.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snapsvg/snapsvg.d.ts b/snapsvg/snapsvg.d.ts index 6543eaa90..6a941f3d7 100644 --- a/snapsvg/snapsvg.d.ts +++ b/snapsvg/snapsvg.d.ts @@ -57,7 +57,7 @@ declare module Snap { export var filter:Filter; export var path:Path; - export function Matrix():void; + export function Matrix():void; export function matrix(a:number,b:number,c:number,d:number,e:number,f:number):Matrix; export function matrix(svgMatrix:SVGMatrix):Matrix; From 63e48f4210cf95d7a8ddc93480eaa1a10cbf02a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elis=C3=A9e?= Date: Tue, 10 Nov 2015 17:04:33 +0100 Subject: [PATCH 011/353] three: Update comment for WebGLRenderer.clear --- threejs/three.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index fd165f936..dd1521d84 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -4686,7 +4686,7 @@ declare module THREE { /** * Tells the renderer to clear its color, depth or stencil drawing buffer(s). - * If no parameters are passed, no buffer will be cleared. + * Arguments default to true */ clear(color?: boolean, depth?: boolean, stencil?: boolean): void; From 3c032bd7f68ace09840c363cdbd0fc8bc3106a1f Mon Sep 17 00:00:00 2001 From: emmanuel Date: Fri, 13 Nov 2015 12:28:49 +0100 Subject: [PATCH 012/353] First commit: add type definitions for slick 1.5.8 --- jquery.slick/slick-tests.ts | 232 ++++++++++++++++++++++ jquery.slick/slick.d.ts | 381 ++++++++++++++++++++++++++++++++++++ 2 files changed, 613 insertions(+) create mode 100644 jquery.slick/slick-tests.ts create mode 100644 jquery.slick/slick.d.ts diff --git a/jquery.slick/slick-tests.ts b/jquery.slick/slick-tests.ts new file mode 100644 index 000000000..499e6974c --- /dev/null +++ b/jquery.slick/slick-tests.ts @@ -0,0 +1,232 @@ +/// +/// + + +// -------------------------------------------------------- +// ------------------- WEBSITE EXAMPLE -------------------- +// ---------- http://kenwheeler.github.io/slick/ ---------- +// -------------------------------------------------------- + +$('.single-item').slick(); + +$('.multiple-items').slick({ + infinite: true, + slidesToShow: 3, + slidesToScroll: 3 +}); + +$('.responsive').slick({ + dots: true, + infinite: false, + speed: 300, + slidesToShow: 4, + slidesToScroll: 4, + responsive: [ + { + breakpoint: 1024, + settings: { + slidesToShow: 3, + slidesToScroll: 3, + infinite: true, + dots: true + } + }, + { + breakpoint: 600, + settings: { + slidesToShow: 2, + slidesToScroll: 2 + } + }, + { + breakpoint: 480, + settings: { + slidesToShow: 1, + slidesToScroll: 1 + } + } + // You can unslick at a given breakpoint now by adding: + // settings: "unslick" + // instead of a settings object + ] +}); + +$('.variable-width').slick({ + dots: true, + infinite: true, + speed: 300, + slidesToShow: 1, + centerMode: true, + variableWidth: true +}); + +$('.one-time').slick({ + dots: true, + infinite: true, + speed: 300, + slidesToShow: 1, + adaptiveHeight: true +}); + +$('.center').slick({ + centerMode: true, + centerPadding: '60px', + slidesToShow: 3, + responsive: [ + { + breakpoint: 768, + settings: { + arrows: false, + centerMode: true, + centerPadding: '40px', + slidesToShow: 3 + } + }, + { + breakpoint: 480, + settings: { + arrows: false, + centerMode: true, + centerPadding: '40px', + slidesToShow: 1 + } + } + ] +}); + +// To use lazy loading, set a data-lazy attribute +// on your img tags and leave off the src +// + +$('.lazy').slick({ + lazyLoad: 'ondemand', + slidesToShow: 3, + slidesToScroll: 1 +}); + +$('.autoplay').slick({ + slidesToShow: 3, + slidesToScroll: 1, + autoplay: true, + autoplaySpeed: 2000, +}); + +$('.fade').slick({ + dots: true, + infinite: true, + speed: 500, + fade: true, + cssEase: 'linear' +}); + +var slideIndex = 1; +$('.add-remove').slick({ + slidesToShow: 3, + slidesToScroll: 3 +}); +$('.js-add-slide').on('click', function() { + slideIndex++; + $('.add-remove').slick('slickAdd','

' + slideIndex + '

'); +}); + +$('.js-remove-slide').on('click', function() { + $('.add-remove').slick('slickRemove', slideIndex - 1); + if (slideIndex !== 0){ + slideIndex--; + } +}); + +$('.filtering').slick({ + slidesToShow: 4, + slidesToScroll: 4 +}); + +var filtered = false; + +$('.js-filter').on('click', function(){ + if (filtered === false) { + $('.filtering').slick('slickFilter',':even'); + $(this).text('Unfilter Slides'); + filtered = true; + } else { + $('.filtering').slick('slickUnfilter'); + $(this).text('Filter Slides'); + filtered = false; + } +}); + +$('.your-slider').slick('unslick'); + +$('.slider-for').slick({ + slidesToShow: 1, + slidesToScroll: 1, + arrows: false, + fade: true, + asNavFor: '.slider-nav' +}); +$('.slider-nav').slick({ + slidesToShow: 3, + slidesToScroll: 1, + asNavFor: '.slider-for', + dots: true, + centerMode: true, + focusOnSelect: true +}); + +$('.single-item-rtl').slick({ + rtl: true +}); + + + +// -------------------------------------------------------- +// ---------------- TEST DEFAULT OPTIONS ------------------ +// -------------------------------------------------------- + +$("#diaporama").slick({ + accessibility: true, + adaptiveHeight: false, + autoplay: false, + autoplaySpeed: 3000, + arrows: true, + asNavFor: "#slideshow", + appendArrows: "", + prevArrow: "", + nextArrow: "", + centerMode: false, + centerPadding: "50px", + cssEase: "ease", + customPaging: (slider, i: number) => { + console.log("customPaging slider", slider); + console.log("customPaging index", i); + }, + dots: false, + draggable: true, + fade: false, + focusOnSelect: false, + easing: "linear", + edgeFriction: 0.15, + infinite: true, + initialSlide: 0, + lazyLoad: "ondemand", + mobileFirst: false, + pauseOnHover: true, + pauseOnDotsHover: false, + respondTo: "window", + responsive: null, + rows: 1, + slide: "div", + slidesPerRow: 1, + slidesToShow: 1, + slidesToScroll: 1, + speed: 300, + swipe: true, + swipeToSlide: false, + touchMove: true, + touchThreshold: 5, + useCSS: true, + variableWidth: false, + vertical: false, + verticalSwiping: false, + rtl: false +}); diff --git a/jquery.slick/slick.d.ts b/jquery.slick/slick.d.ts new file mode 100644 index 000000000..cc9aa626b --- /dev/null +++ b/jquery.slick/slick.d.ts @@ -0,0 +1,381 @@ +// Type definitions for stick 1.5.8 +// Project: http://kenwheeler.github.io/slick/ +// Definitions by: John Gouigouix +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface JQuerySlickOptions { + + /** + * Enables tabbing and arrow key navigation + * Default: true + */ + accessibility?: boolean; + + /** + * Enables adaptive height for single slide horizontal carousels. + * Default: false + */ + adaptiveHeight?: boolean; + + /** + * Enables Autoplay + * Default: false + */ + autoplay?: boolean; + + /** + * Autoplay Speed in milliseconds + * Default: 3000 + */ + autoplaySpeed?: number; + + /** + * Prev/Next Arrows + * Default: true + */ + arrows?: boolean; + + /** + * Set the slider to be the navigation of other slider (Class or ID Name) + * Default: null + */ + asNavFor?: string; + + /** + * Change where the navigation arrows are attached (Selector, htmlString, Array, Element, jQuery object) + * Default: $(element) + */ + appendArrows?: any; + + /** + * Allows you to select a node or customize the HTML for the "Previous" arrow. + * Default: + */ + prevArrow?: string | Object; + + /** + * Allows you to select a node or customize the HTML for the "Next" arrow. + * Default: + */ + nextArrow?: string | Object; + + /** + * Enables centered view with partial prev/next slides. Use with odd numbered slidesToShow counts. + * Default: false + */ + centerMode?: boolean; + + /** + * Side padding when in center mode (px or %) + * Default: '50px' + */ + centerPadding?: string; + + /** + * CSS3 Animation Easing + * Default: 'ease' + */ + cssEase?: string; + + /** + * Custom paging templates. See source for use example. + * Default: n/a + */ + customPaging?: (slider, i: number) => string; + + /** + * Show dot indicators + * Default: false + */ + dots?: boolean; + + /** + * Enable mouse dragging + * Default: true + */ + draggable?: boolean; + + /** + * Enable fade + * Default: false + */ + fade?: boolean; + + /** + * Enable focus on selected element (click) + * Default: false + */ + focusOnSelect?: boolean; + + /** + * Add easing for jQuery animate. Use with easing libraries or default easing methods + * Default: 'linear' + */ + easing?: string; + + /** + * Resistance when swiping edges of non-infinite carousels + * Default: 0.15 + */ + edgeFriction?: number; + + /** + * Infinite loop sliding + * Default: true + */ + infinite?: boolean; + + /** + * Slide to start on + * Default: 0 + */ + initialSlide?: number; + + /** + * Set lazy loading technique. Accepts 'ondemand' or 'progressive'. + * Default: 'ondemand' + */ + lazyLoad?: string; + + /** + * Responsive settings use mobile first calculation + * Default: false + */ + mobileFirst?: boolean; + + /** + * Pause Autoplay On Hover + * Default: true + */ + pauseOnHover?: boolean; + + /** + * Pause Autoplay when a dot is hovered + * Default: false + */ + pauseOnDotsHover?: boolean; + + /** + * Width that responsive object responds to. Can be 'window', 'slider' or 'min' (the smaller of the two) + * Default: 'window' + */ + respondTo?: string; + + /** + * Object containing breakpoints and settings objects (see demo). + * Enables settings sets at given screen width. + * Set settings to "unslick" instead of an object to disable slick at a given breakpoint. + * Default: none + */ + responsive?: Object; + + /** + * Setting this to more than 1 initializes grid mode. Use slidesPerRow to set how many slides should be in each row. + * Default: 1 + */ + rows?: number; + + /** + * Element query to use as slide + * Default: 'div' + */ + slide?: string; + + /** + * With grid mode intialized via the rows option, this sets how many slides are in each grid row. + * Default: 1 + */ + slidesPerRow?: number; + + /** + * # of slides to show + * Default: 1 + */ + slidesToShow?: number; + + /** + * # of slides to scroll + * Default: 1 + */ + slidesToScroll?: number; + + /** + * Slide/Fade animation speed (ms) + * Default: 300 + */ + speed?: number; + + /** + * Enable swiping + * Default: true + */ + swipe?: boolean; + + /** + * Allow users to drag or swipe directly to a slide irrespective of slidesToScroll. + * Default: false + */ + swipeToSlide?: boolean; + + /** + * Enable slide motion with touch + * Default: true + */ + touchMove?: boolean; + + /** + * To advance slides, the user must swipe a length of (1/touchThreshold) * the width of the slider. + * Default: 5 + */ + touchThreshold?: number; + + /** + * Enable/Disable CSS Transitions + * Default: true + */ + useCSS?: boolean; + + /** + * Variable width slides. + * Default: false + */ + variableWidth?: boolean; + + /** + * Vertical slide mode + * Default: false + */ + vertical?: boolean; + + /** + * Vertical swipe mode + * Default: false + */ + verticalSwiping?: boolean; + + /** + * Change the slider's direction to become right-to-left + * Default: false + */ + rtl?: boolean; + +} + + +interface JQuery { + + /** + * Create slick component + */ + slick(): JQuery; + slick(options: JQuerySlickOptions): JQuery; + + /** + * Returns the current slide index + * @param methodName The name of the method + */ + slick(methodName: "slickCurrentSlide"): number; + + /** + * Navigates to a slide by index + * @param methodName The name of the method + * @param slide + * @param animate + */ + slick(methodName: "slickGoTo", slide: number, animate?: boolean): JQuery; + + /** + * Navigates to the next slide + * @param methodName The name of the method + */ + slick(methodName: "slickNext"): JQuery; + + /** + * Navigates to the previous slide + * @param methodName The name of the method + */ + slick(methodName: "slickPrev"): JQuery; + + /** + * Pauses autoplay + * @param methodName The name of the method + */ + slick(methodName: "slickPause"): JQuery; + + /** + * Starts autoplay + * @param methodName The name of the method + */ + slick(methodName: "slickPlay"): JQuery; + + /** + * Add a slide. If an index is provided, will add at that index, or before if addBefore is set. If no index is provided, + * add to the end or to the beginning if addBefore is set. Accepts HTML String || Object + * @param methodName The name of the method + * @param html + * @param index/div> + * @param addBefore + */ + slick(methodName: "slickAdd", html: string | Object, index?: number, addBefore?: number): JQuery; + + /** + * Remove slide by index. If removeBefore is set true, remove slide preceding index, or the first slide if no index is specified. + * If removeBefore is set to false, remove the slide following index, or the last slide if no index is set. + * @param methodName The name of the method + * @param index + * @param removeBefore + */ + slick(methodName: "slickRemove", index: number, removeBefore?: number): JQuery; + + /** + * Filters slides using jQuery .filter() + * @param methodName The name of the method + * @param selector + */ + slick(methodName : "slickFilter", selector: string): JQuery; + + /** + * Filters slides using jQuery .filter() + * @param methodName The name of the method + * @param func + */ + slick(methodName : "slickFilter", func: (index: number, element: Element) => any): JQuery; + + /** + * Removes applied filtering + * @param methodName The name of the method + * @param index + */ + slick(methodName: "slickUnfilter", index: number): JQuery; + + /** + * Sets an individual value live. Set refresh to true if it's a UI update. + * @param methodName The name of the method + * @param option The option name + */ + slick(methodName: "slickGetOption", option: any): JQuerySlickOptions; + + /** + * Sets an individual value live. Set refresh to true if it's a UI update. + * @param methodName The name of the method + * @param option The option name + * @param value depends on option + * @param refresh + */ + slick(methodName: "slickSetOption", option: string, value: JQuerySlickOptions, refresh?: boolean): JQuery; + + /** + * Deconstructs slick + * @param methodName The name of the method + */ + slick(methodName: "unslick"): JQuery; + + /** + * Get Slick Object + * @param methodName "getSlick" + */ + slick(methodName: "getSlick"): Object; + +} From 366488bc0c33117797b3725905d0ddae8dd1c708 Mon Sep 17 00:00:00 2001 From: emmanuel Date: Fri, 13 Nov 2015 14:16:45 +0100 Subject: [PATCH 013/353] Fixed error name --- jquery.slick/slick.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.slick/slick.d.ts b/jquery.slick/slick.d.ts index cc9aa626b..949f21736 100644 --- a/jquery.slick/slick.d.ts +++ b/jquery.slick/slick.d.ts @@ -374,7 +374,7 @@ interface JQuery { /** * Get Slick Object - * @param methodName "getSlick" + * @param methodName The name of the method */ slick(methodName: "getSlick"): Object; From 9545151e70db4d285c5f7bcfaf41b5fb879cebb8 Mon Sep 17 00:00:00 2001 From: emmanuel Date: Fri, 13 Nov 2015 16:25:13 +0100 Subject: [PATCH 014/353] First commit: add type definitions for mmenu 5.5.3 --- jquery.mmenu/jquery.mmenu-tests.ts | 85 +++++++++++ jquery.mmenu/jquery.mmenu.d.ts | 229 +++++++++++++++++++++++++++++ 2 files changed, 314 insertions(+) create mode 100644 jquery.mmenu/jquery.mmenu-tests.ts create mode 100644 jquery.mmenu/jquery.mmenu.d.ts diff --git a/jquery.mmenu/jquery.mmenu-tests.ts b/jquery.mmenu/jquery.mmenu-tests.ts new file mode 100644 index 000000000..9fbb9b776 --- /dev/null +++ b/jquery.mmenu/jquery.mmenu-tests.ts @@ -0,0 +1,85 @@ +/// +/// + + +// -------------------------------------------------------- +// ---------------- TEST DEFAULT OPTIONS ------------------ +// -------------------------------------------------------- + +var menu: JQuery = $("#my-menu"); +menu.mmenu( + // options + { + extensions: [], + navbar: { + add: true, + title: "Menu", + titleLink: "parent" + }, + onClick: { + close: true, + preventDefault: false, + setSelected: false + }, + slidingSubmenus: true + }, + // configurations + { + classNames: { + divider: "Divider", + inset: "Inset", + panel: "Panel", + selected: "Selected", + vertical: "vertical" + }, + clone: false, + openingInterval: 25, + panelNodetype: "div, ul, ol", + transitionDuration: 400 + } +); + + +// -------------------------------------------------------- +// ------------------- TEST MMENU API --------------------- +// -------------------------------------------------------- + +var api: JQueryMmenu.API = menu.data("mmenu"); +var myPanel: JQuery = $("#panel"); +var listItem: JQuery = $(".list-item"); + +api.closeAllPanels(); +api.bind("closeAllPanels", function() { + console.log("close all opened panels and go back to the first panel."); +}); + +api.closePanel(myPanel); +api.bind("closePanel", function(panel) { + console.log("close this ", panel); +}); + +api.getInstance(); +api.bind("getInstance", function() { + console.log("get the class instance for the menu."); +}); + +api.init(myPanel); +api.bind("init", function(panel) { + console.log("method to (re)initialize a newly added ", panel); +}); + +api.openPanel(myPanel); +api.bind("openPanel", function(panel) { + console.log("This panel is now opened ", panel); +}); + +api.setSelected(listItem, true); +api.bind("setSelected", function(listItem, selected) { + console.log("set or unset a list item as selected ", listItem); + console.log("has selected ", selected); +}); + +api.update(); +api.bind("update", function() { + console.log("update the appearance for the menu"); +}); diff --git a/jquery.mmenu/jquery.mmenu.d.ts b/jquery.mmenu/jquery.mmenu.d.ts new file mode 100644 index 000000000..97874f8f0 --- /dev/null +++ b/jquery.mmenu/jquery.mmenu.d.ts @@ -0,0 +1,229 @@ +// Type definitions for jQuery mmenu v5.5.3 +// Project: http://mmenu.frebsite.nl/ +// Definitions by: John Gouigouix +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module JQueryMmenu { + + interface NavbarOptions { + + /** + * Whether or not to add a navbar above the panels. + * Default: true + */ + add?: boolean; + + /** + * The title above the main panel. + * Default: "Menu" + */ + title?: string; + + /** + * The type of link to set for the title. + * Possible values: "parent", "anchor" or "none". + * Default: "parent" + */ + titleLink?: string; + + } + + interface OnclickOptions { + + /** + * Whether or not the menu should close after clicking a link inside it. + * The default value varies per link: true if the default behavior for + * the clicked link is prevented, false otherwise. + * Default: null + */ + close?: boolean | any; + + /** + * Whether or not to prevent the default behavior for the clicked link. + * The default value varies per link: true if its href is equal to + * or starts with a hash (#), false otherwise. + * Default: null + */ + preventDefault?: boolean | any; + + /** + * Whether or not the clicked link should be visibly "selected". + * Default: true + */ + setSelected?: boolean | any; + + } + + interface Options { + + /** + * A collection of extension names to enable for the menu. + * You'll need this option when using the extensions. + * Default: [] + */ + extensions?: Array; + + /** + * navbar options + */ + navbar?: NavbarOptions; + + /** + * onClick options + */ + onClick?: OnclickOptions; + + /** + * Whether or not submenus should come sliding in from the right. + * If false, submenus expand below their parent. + * To expand a single submenu below its parent item, add the class "Vertical" to it. + * Default: true + */ + slidingSubmenus?: boolean; + + } + + interface ClassnamesConfigurations { + + /** + * The classname on a LI that should be displayed as a divider. + * Default: "Divider" + */ + divider?: string; + + /** + * The classname on a submenu (a nested UL) that should be displayed as a default list. + * Default: "Inset" + */ + inset?: string; + + /** + * The classname on an element (for example a DIV) that should be considered to be a panel. + * Only applies if the "isMenu" option is set to false. + * Default: "Panel" + */ + panel?: string; + + /** + * The classname on the LI that should be displayed as selected. + * Default: "Selected" + */ + selected?: string; + + /** + * The classname on a submenu (a nested UL) that should expand below + * their parent instead of slide in from the right. + * Default: "vertical" + */ + vertical?: string; + + } + + interface Configurations { + + /** + * the CSS class names object + */ + classNames?: ClassnamesConfigurations; + + /** + * Whether or not the menu should be cloned (and the original menu kept intact). + * Default: false + */ + clone?: boolean; + + /** + * The number of milliseconds between opening/closing the menu and panels, + * needed to force CSS transitions. + * Default: 25 + */ + openingInterval?: number; + + /** + * jQuery selector containing the node-type of panels. + * Default: "div, ul, ol" + */ + panelNodetype?: string; + + /** + * The number of milliseconds used in the CSS transitions. + * Default: 400 (The value should match the associated CSS value.) + */ + transitionDuration?: number; + + } + + interface API { + + /** + * Trigger this method to close all opened panels and go back to the first panel. + */ + closeAllPanels(): JQuery; + /** @see closeAllPanels() */ + bind(methodName: "closeAllPanels", callback: () => void): JQuery; + + /** + * Trigger this method to close a panel + * (only available if the "slidingSubmenus" option is set to false). + * @param panel + */ + closePanel(panel: JQuery); + /** @see closePanel() */ + bind(methodName: "closePanel", callback: (panel: JQuery) => void); + + /** + * Trigger this method to get the class instance for the menu. + */ + getInstance(); + /** @see getInstance() */ + bind(methodName: "getInstance", callback: () => void); + + /** + * Trigger this method to (re)initialize a newly added panel. + * @param panel The panel to (re)initialize. + */ + init(panel: JQuery); + /** @see init() */ + bind(methodName: "init", callback: (panel: JQuery) => void); + + /** + * Trigger this method to open a panel. + * @param panel The panel to open. + */ + openPanel(panel: JQuery); + /** @see openPanel() */ + bind(methodName: "openPanel", callback: (panel: JQuery) => void); + + /** + * Trigger this method to set or unset a list item as "selected". + * @param li The list item to set or unset as "selected". + * @param selected Whether to set or unset the list item as "selected". Default: true + */ + setSelected(li: JQuery, selected?: boolean); + /** @see setSelected() */ + bind(methodName: "setSelected", callback: (li: JQuery, selected?: boolean) => void); + + /** + * Trigger this method to update the appearance for the menu. + */ + update(); + /** @see update() */ + bind(methodName: "update", callback: () => void); + + } + +} + + +interface JQuery { + + /** + * Create mmenu component + */ + mmenu(): JQuery; + mmenu(options: JQueryMmenu.Options): JQuery; + mmenu(options: JQueryMmenu.Options, configurations: JQueryMmenu.Configurations): JQuery; + +} From 709f97cb32513e322a3ad98b71af51a48788b3e8 Mon Sep 17 00:00:00 2001 From: Dan Marshall Date: Sat, 14 Nov 2015 12:47:05 -0800 Subject: [PATCH 015/353] 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 59a50e4fc..ae17a8fe9 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 69cd3dbb7..779af0534 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 47441e47c0e3ef775e27e9a73ebd4392f7951e96 Mon Sep 17 00:00:00 2001 From: emmanuel Date: Mon, 16 Nov 2015 11:29:52 +0100 Subject: [PATCH 016/353] Fix test error for mmenu 5.5.3 --- jquery.mmenu/jquery.mmenu-tests.ts | 4 ++-- jquery.mmenu/jquery.mmenu.d.ts | 37 ++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/jquery.mmenu/jquery.mmenu-tests.ts b/jquery.mmenu/jquery.mmenu-tests.ts index 9fbb9b776..ae52793d6 100644 --- a/jquery.mmenu/jquery.mmenu-tests.ts +++ b/jquery.mmenu/jquery.mmenu-tests.ts @@ -1,5 +1,5 @@ /// -/// +/// // -------------------------------------------------------- @@ -44,7 +44,7 @@ menu.mmenu( // ------------------- TEST MMENU API --------------------- // -------------------------------------------------------- -var api: JQueryMmenu.API = menu.data("mmenu"); +var api = menu.data("mmenu"); var myPanel: JQuery = $("#panel"); var listItem: JQuery = $(".list-item"); diff --git a/jquery.mmenu/jquery.mmenu.d.ts b/jquery.mmenu/jquery.mmenu.d.ts index 97874f8f0..a502c37cd 100644 --- a/jquery.mmenu/jquery.mmenu.d.ts +++ b/jquery.mmenu/jquery.mmenu.d.ts @@ -157,6 +157,13 @@ declare module JQueryMmenu { interface API { + /** + * Trigger non-specialized signature method + * @param methodName + * @param callback + */ + bind(methodName: string, callback: (...args: any[]) => void): any; + /** * Trigger this method to close all opened panels and go back to the first panel. */ @@ -169,48 +176,48 @@ declare module JQueryMmenu { * (only available if the "slidingSubmenus" option is set to false). * @param panel */ - closePanel(panel: JQuery); + closePanel(panel: JQuery): void; /** @see closePanel() */ - bind(methodName: "closePanel", callback: (panel: JQuery) => void); + bind(methodName: "closePanel", callback: (panel: JQuery) => void): void; /** * Trigger this method to get the class instance for the menu. */ - getInstance(); + getInstance(): void; /** @see getInstance() */ - bind(methodName: "getInstance", callback: () => void); + bind(methodName: "getInstance", callback: () => void): void; /** * Trigger this method to (re)initialize a newly added panel. * @param panel The panel to (re)initialize. */ - init(panel: JQuery); + init(panel: JQuery): void; /** @see init() */ - bind(methodName: "init", callback: (panel: JQuery) => void); + bind(methodName: "init", callback: (panel: JQuery) => void): void; /** * Trigger this method to open a panel. * @param panel The panel to open. */ - openPanel(panel: JQuery); + openPanel(panel: JQuery): void; /** @see openPanel() */ - bind(methodName: "openPanel", callback: (panel: JQuery) => void); + bind(methodName: "openPanel", callback: (panel: JQuery) => void): void; /** * Trigger this method to set or unset a list item as "selected". * @param li The list item to set or unset as "selected". * @param selected Whether to set or unset the list item as "selected". Default: true */ - setSelected(li: JQuery, selected?: boolean); + setSelected(li: JQuery, selected?: boolean): void; /** @see setSelected() */ - bind(methodName: "setSelected", callback: (li: JQuery, selected?: boolean) => void); + bind(methodName: "setSelected", callback: (li: JQuery, selected?: boolean) => void): void; /** * Trigger this method to update the appearance for the menu. */ - update(); + update(): void; /** @see update() */ - bind(methodName: "update", callback: () => void); + bind(methodName: "update", callback: () => void): void; } @@ -226,4 +233,10 @@ interface JQuery { mmenu(options: JQueryMmenu.Options): JQuery; mmenu(options: JQueryMmenu.Options, configurations: JQueryMmenu.Configurations): JQuery; + /** + * Return the mmenu object + * @param element + */ + data(element: "mmenu"): JQueryMmenu.API; + } From 38eb9eab293520f4902c5cec93528508777fd699 Mon Sep 17 00:00:00 2001 From: emmanuel Date: Mon, 16 Nov 2015 11:30:34 +0100 Subject: [PATCH 017/353] Fix test error for slick 1.5.8 --- jquery.slick/slick-tests.ts | 7 +++---- jquery.slick/slick.d.ts | 9 ++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/jquery.slick/slick-tests.ts b/jquery.slick/slick-tests.ts index 499e6974c..90f61ca67 100644 --- a/jquery.slick/slick-tests.ts +++ b/jquery.slick/slick-tests.ts @@ -1,5 +1,5 @@ /// -/// +/// // -------------------------------------------------------- @@ -196,9 +196,8 @@ $("#diaporama").slick({ centerMode: false, centerPadding: "50px", cssEase: "ease", - customPaging: (slider, i: number) => { - console.log("customPaging slider", slider); - console.log("customPaging index", i); + customPaging: (slider, i) => { + return "customPaging slider " + slider + " customPaging index " + i; }, dots: false, draggable: true, diff --git a/jquery.slick/slick.d.ts b/jquery.slick/slick.d.ts index 949f21736..d75090bb2 100644 --- a/jquery.slick/slick.d.ts +++ b/jquery.slick/slick.d.ts @@ -83,7 +83,7 @@ interface JQuerySlickOptions { * Custom paging templates. See source for use example. * Default: n/a */ - customPaging?: (slider, i: number) => string; + customPaging?: (slider: any, i: number) => string; /** * Show dot indicators @@ -272,6 +272,13 @@ interface JQuery { slick(): JQuery; slick(options: JQuerySlickOptions): JQuery; + /** + * Trigger non-specialized signature method + * @param methodName + * @param arg + */ + slick(methodName: string, ...arg: any[]): any; + /** * Returns the current slide index * @param methodName The name of the method From 05d34f0655717b326e8531423f8077b7f0088359 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Mon, 16 Nov 2015 20:46:48 +0100 Subject: [PATCH 018/353] Try to create a definition for karma-coverage --- karma-coverage/karma-coverage-tests.ts | 220 +++++++++++++++++++++++++ karma-coverage/karma-coverage.d.ts | 28 ++++ 2 files changed, 248 insertions(+) create mode 100644 karma-coverage/karma-coverage-tests.ts create mode 100644 karma-coverage/karma-coverage.d.ts diff --git a/karma-coverage/karma-coverage-tests.ts b/karma-coverage/karma-coverage-tests.ts new file mode 100644 index 000000000..f4bd45f77 --- /dev/null +++ b/karma-coverage/karma-coverage-tests.ts @@ -0,0 +1,220 @@ +/// + +import karma = require('karma'); + + +// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#basic +module.exports = function(config: karma.Config) { + config.set({ + files: [ + 'src/**/*.js', + 'test/**/*.js' + ], + + // coverage reporter generates the coverage + reporters: ['progress', 'coverage'], + + preprocessors: { + // source files, that you wanna generate coverage for + // do not include tests or libraries + // (these files will be instrumented by Istanbul) + 'src/**/*.js': ['coverage'] + }, + + // optionally, configure the reporter + coverageReporter: { + type : 'html', + dir : 'coverage/' + } + }); +}; + +// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#advanced-multiple-reporters +module.exports = function(config: karma.Config) { + config.set({ + files: [ + 'src/**/*.js', + 'test/**/*.js' + ], + reporters: ['progress', 'coverage'], + preprocessors: { + 'src/**/*.js': ['coverage'] + }, + coverageReporter: { + // specify a common output directory + dir: 'build/reports/coverage', + reporters: [ + // reporters not supporting the `file` property + { type: 'html', subdir: 'report-html' }, + { type: 'lcov', subdir: 'report-lcov' }, + // reporters supporting the `file` property, use `subdir` to directly + // output them in the `dir` directory + { type: 'cobertura', subdir: '.', file: 'cobertura.txt' }, + { type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt' }, + { type: 'teamcity', subdir: '.', file: 'teamcity.txt' }, + { type: 'text', subdir: '.', file: 'text.txt' }, + { type: 'text-summary', subdir: '.', file: 'text-summary.txt' }, + ] + } + }); +}; + +// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#dont-minify-instrumenter-output +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + instrumenterOptions: { + istanbul: { noCompact: true } + } + } + }); +}; + +// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#subdir +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + dir: 'coverage', + subdir: '.' + // Would output the results into: .'/coverage/' + } + }); +}; + +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + dir: 'coverage', + subdir: 'report' + // Would output the results into: .'/coverage/report/' + } + }); +}; + +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + dir: 'coverage', + subdir: function(browser) { + // normalization process to keep a consistent browser name accross different + // OS + return browser.toLowerCase().split(/[ /-]/)[0]; + } + // Would output the results into: './coverage/firefox/' + } + }); +}; + +// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#file +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + type : 'text', + dir : 'coverage/', + file : 'coverage.txt' + } + }); +}; + +// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#check +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + check: { + global: { + statements: 50, + branches: 50, + functions: 50, + lines: 50, + excludes: [ + 'foo/bar/**/*.js' + ] + }, + each: { + statements: 50, + branches: 50, + functions: 50, + lines: 50, + excludes: [ + 'other/directory/**/*.js' + ], + overrides: { + 'baz/component/**/*.js': { + statements: 98 + } + } + } + } + } + }); +}; + +// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#watermarks +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + watermarks: { + statements: [ 50, 75 ], + functions: [ 50, 75 ], + branches: [ 50, 75 ], + lines: [ 50, 75 ] + } + } + }); +}; + +// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#sourcestore +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + type : 'text', + dir : 'coverage/', + file : 'coverage.txt', + sourceStore : require('istanbul').Store.create('fslookup') + } + }); +}; + +// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#reporters +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + reporters:[ + {type: 'html', dir:'coverage/'}, + {type: 'teamcity'}, + {type: 'text-summary'} + ], + } + }); +}; + +// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#instrumenter +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + instrumenters: { ibrik : require('ibrik') }, + instrumenter: { + '**/*.coffee': 'ibrik' + }, + // ... + } + }); +}; + +var to5Options = { experimental: true }; + +// [...] + +module.exports = function(config: karma.Config) { + config.set({ + coverageReporter: { + instrumenters: { isparta : require('isparta') }, + instrumenter: { + '**/*.js': 'isparta' + }, + instrumenterOptions: { + isparta: { to5 : to5Options } + } + } + }); +}; diff --git a/karma-coverage/karma-coverage.d.ts b/karma-coverage/karma-coverage.d.ts new file mode 100644 index 000000000..07df06105 --- /dev/null +++ b/karma-coverage/karma-coverage.d.ts @@ -0,0 +1,28 @@ +// Type definitions for karma-coverage v0.5.3 +// Project: https://github.com/karma-runner/karma-coverage +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'karma' { + namespace karma { + interface ConfigOptions { + /** + * See https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md + */ + coverageReporter?: (Reporter|Reporter[]); + } + + interface Reporter { + type?: string; + dir?: string; + subdir?: string | ((browser: string) => string); + check?: any; + watermarks?: any; + includeAllSources?: boolean; + sourceStore?: any; // Should be istanbul.Store + instrumenter?: any; + } + } +} From ae5b3588168c495f77315076f681bc4cbbb0a247 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Sat, 21 Nov 2015 15:32:33 +0100 Subject: [PATCH 019/353] Simplified definition for Istanbul (https://github.com/gotwarlost/istanbul) --- istanbul/istanbul-tests.ts | 27 ++++++++++++++ istanbul/istanbul.d.ts | 73 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 istanbul/istanbul-tests.ts create mode 100644 istanbul/istanbul.d.ts diff --git a/istanbul/istanbul-tests.ts b/istanbul/istanbul-tests.ts new file mode 100644 index 000000000..b283e2dcc --- /dev/null +++ b/istanbul/istanbul-tests.ts @@ -0,0 +1,27 @@ +/// + +import * as istanbul from 'istanbul'; + +// Instrument code +var instrumenter = new istanbul.Instrumenter(); + +var generatedCode = instrumenter.instrumentSync('function meaningOfLife() { return 42; }', + 'filename.js'); + + +// Generate reports given a bunch of coverage JSON objects +var collector = new istanbul.Collector(), + reporter = new istanbul.Reporter(), + sync = false; + +var obj1 = {}, + obj2 = {}; + +collector.add(obj1); +collector.add(obj2); //etc. + +reporter.add('text'); +reporter.addAll([ 'lcov', 'clover' ]); +reporter.write(collector, sync, function () { + console.log('All reports generated'); +}); diff --git a/istanbul/istanbul.d.ts b/istanbul/istanbul.d.ts new file mode 100644 index 000000000..026ad8b00 --- /dev/null +++ b/istanbul/istanbul.d.ts @@ -0,0 +1,73 @@ +// Type definitions for Istanbul v0.4.0 +// Project: https://github.com/gotwarlost/istanbul +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'istanbul' { + namespace istanbul { + interface Istanbul { + new (options?: any): Istanbul; + Collector: Collector; + config: Config; + ContentWriter: ContentWriter; + FileWriter: FileWriter; + hook: Hook; + Instrumenter: Instrumenter; + Report: Report; + Reporter: Reporter; + Store: Store; + utils: ObjectUtils; + VERSION: string; + Writer: Writer; + } + + interface Collector { + new (options?: any): Collector; + add(coverage: any, testName?: string): void; + } + + interface Config { + } + + interface ContentWriter { + } + + interface FileWriter { + } + + interface Hook { + } + + interface Instrumenter { + new (options?: any): Instrumenter; + instrumentSync(code: string, filename: string): string; + } + + interface Report { + } + + interface Configuration { + new (obj: any, overrides: any): Configuration; + } + + interface Reporter { + new (cfg?: Configuration, dir?: string): Reporter; + add(fmt: string): void; + addAll(fmts: Array): void; + write(collector: Collector, sync: boolean, callback: Function): void; + } + + interface Store { + } + + interface ObjectUtils { + } + + interface Writer { + } + } + + var istanbul: istanbul.Istanbul; + + export = istanbul; +} From 02dd2f323e1bcb8a823269f89e0909ec9e5e38b5 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Sat, 21 Nov 2015 15:33:11 +0100 Subject: [PATCH 020/353] Remove trailing whitespaces --- karma/karma.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/karma/karma.d.ts b/karma/karma.d.ts index c489535eb..87d05843d 100644 --- a/karma/karma.d.ts +++ b/karma/karma.d.ts @@ -82,8 +82,8 @@ declare module 'karma' { interface ServerCallback { (exitCode: number): void; } - - interface Config { + + interface Config { set: (config: ConfigOptions) => void; LOG_DISABLE: string; LOG_ERROR: string; @@ -91,7 +91,7 @@ declare module 'karma' { LOG_INFO: string; LOG_DEBUG: string; } - + interface ConfigFile { configFile: string; } From 507d8b07b457c076028e0fbcf2858c323f3400c6 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Sat, 21 Nov 2015 15:33:37 +0100 Subject: [PATCH 021/353] Fix karma-coverage definition --- karma-coverage/karma-coverage-tests.ts | 2 +- karma-coverage/karma-coverage.d.ts | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/karma-coverage/karma-coverage-tests.ts b/karma-coverage/karma-coverage-tests.ts index f4bd45f77..8ca9edc63 100644 --- a/karma-coverage/karma-coverage-tests.ts +++ b/karma-coverage/karma-coverage-tests.ts @@ -1,6 +1,6 @@ /// -import karma = require('karma'); +import * as karma from 'karma-coverage'; // See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#basic diff --git a/karma-coverage/karma-coverage.d.ts b/karma-coverage/karma-coverage.d.ts index 07df06105..7b78a36de 100644 --- a/karma-coverage/karma-coverage.d.ts +++ b/karma-coverage/karma-coverage.d.ts @@ -4,10 +4,20 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// -declare module 'karma' { - namespace karma { - interface ConfigOptions { +declare module 'karma-coverage' { + import * as karma from 'karma'; + import * as istanbul from 'istanbul'; + + namespace karmaCoverage { + interface Karma extends karma.Karma {} + + interface Config extends karma.Config { + set: (config: ConfigOptions) => void; + } + + interface ConfigOptions extends karma.ConfigOptions { /** * See https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md */ @@ -21,8 +31,12 @@ declare module 'karma' { check?: any; watermarks?: any; includeAllSources?: boolean; - sourceStore?: any; // Should be istanbul.Store + sourceStore?: istanbul.Store; instrumenter?: any; } } + + var karmaCoverage: karmaCoverage.Karma; + + export = karmaCoverage; } From d8184977b0d72cce7fb5e03591de83b9424f6d0b Mon Sep 17 00:00:00 2001 From: emmanuel Date: Mon, 23 Nov 2015 14:35:47 +0100 Subject: [PATCH 022/353] Rename jquery.slick to slick-carousel --- .../slick-tests.ts => slick-carousel/slick-carousel-tests.ts | 2 +- jquery.slick/slick.d.ts => slick-carousel/slick-carousel.d.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename jquery.slick/slick-tests.ts => slick-carousel/slick-carousel-tests.ts (98%) rename jquery.slick/slick.d.ts => slick-carousel/slick-carousel.d.ts (100%) diff --git a/jquery.slick/slick-tests.ts b/slick-carousel/slick-carousel-tests.ts similarity index 98% rename from jquery.slick/slick-tests.ts rename to slick-carousel/slick-carousel-tests.ts index 90f61ca67..0279f5131 100644 --- a/jquery.slick/slick-tests.ts +++ b/slick-carousel/slick-carousel-tests.ts @@ -1,5 +1,5 @@ /// -/// +/// // -------------------------------------------------------- diff --git a/jquery.slick/slick.d.ts b/slick-carousel/slick-carousel.d.ts similarity index 100% rename from jquery.slick/slick.d.ts rename to slick-carousel/slick-carousel.d.ts From 3a605075a65f9d994c0878ca16f0151085a9db55 Mon Sep 17 00:00:00 2001 From: Denis Sokolov Date: Mon, 30 Nov 2015 12:05:22 +0200 Subject: [PATCH 023/353] 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 000000000..7aa24601a --- /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 000000000..fb0e52b46 --- /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 8f5faa4841838aeafdd63d446f9b5339ccfe2e34 Mon Sep 17 00:00:00 2001 From: Sam Vloeberghs Date: Wed, 2 Dec 2015 16:18:40 +0100 Subject: [PATCH 024/353] update fs --- foundation-sites/foundation.d.ts | 216 +++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 foundation-sites/foundation.d.ts diff --git a/foundation-sites/foundation.d.ts b/foundation-sites/foundation.d.ts new file mode 100644 index 000000000..3f0a99ade --- /dev/null +++ b/foundation-sites/foundation.d.ts @@ -0,0 +1,216 @@ +// Type definitions for Foundation Sites v6.0.4 +// Project: http://foundation.zurb.com/ +// Definitions by: Sam Vloeberghs +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare module Foundation { + + // http://foundation.zurb.com/sites/docs/abide.html#javascript-reference + export interface Abide { + requiredCheck: (element: Object) => boolean; + findLabel: (element:Object) => boolean; + addErrorClasses: (element: Object) => void; + removeErrorClasses: (element:Object) => void; + validateInput: (element: Object, form: Object) => void; + validateForm: (element: Object) => void; + validateText: (element: Object) => boolean; + validateRadio: (group: String) => boolean; + resetform: ($form: Object) => void; + } + interface AbideOptions { + + } + + // http://foundation.zurb.com/sites/docs/accordion.html#javascript-reference + export interface Accordion { + toggle: ($target : JQuery) => void; + down: ($target : JQuery, firstTime: boolean) => void; + up: ($target: JQuery) => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/accordion-menu.html#javascript-reference + export interface AccordionMenu { + toggle: ($target : JQuery) => void; + down: ($target : JQuery, firstTime: boolean) => void; + up: ($target: JQuery) => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/drilldown-menu.html#javascript-reference + export interface Drilldown { + _hideAll: ($elem : JQuery) => void; + _show: ($elem : JQuery) => void; + _hide: ($elem : JQuery) => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/dropdown.html#javascript-reference + export interface Dropdown { + getPositionClass: () => String; + open: () => void; + close: () => void; + toggle: () => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/dropdown-menu.html#javascript-reference + export interface DropdownMenu { + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/equalizer.html#javascript-reference + export interface Equalizer { + getHeights: (element: Object) => Array; + applyHeight: ($eqParent: Object, heights:Array) => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/interchange.html#javascript-reference + export interface Interchange { + replace: (path: String) => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/magellan.html#javascript-reference + export interface Magellan { + calcPoints: () => void; + reflow: () => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/offcanvas.html#javascript-reference + export interface OffCanvas { + open: (event: Object, trigger : JQuery) => void; + toggle: (event: Object, trigger : JQuery) => void; + close: () => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/orbit.html#javascript-reference + export interface Orbit { + changeSlide: (isLTR: boolean, chosenSlide?: Object, idx?: number) => void; + geoSync: () => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/reveal.html#javascript-reference + export interface Reveal { + open: () => void; + toggle: () => void; + close: () => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/slider.html#javascript-reference + export interface Slider { + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/sticky.html#javascript-reference + export interface Sticky { + _pauseListeners: (scrollListener: String) => void; + _calc: (checkSizes: boolean, scroll: number) => void; + destroy: () => void; + emCalc: (number: any) => void; + } + + // http://foundation.zurb.com/sites/docs/tabs.html#javascript-reference + export interface Tabs { + _handleTabChange: ($target : JQuery) => void; + selectTab: ($target : JQuery) => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/toggler.html#javascript-reference + export interface Toggler { + toggle: () => void; + destroy: () => void; + } + + // http://foundation.zurb.com/sites/docs/tooltip.html#javascript-reference + export interface Tooltip { + show: () => void; + hide: () =>void; + toggle: () => void; + destroy: () => void; + } + + // Utilities + // --------- + + export interface Box { + ImNotTouchingYou: (element: Object, parent?: Object, lrOnly?:boolean, tbOnly?:boolean) => boolean; + GetDimensions: (element: Object) => Object; + GetOffsets: (element: Object, anchor: Object, position:String, vOffset:number, hOffset:number, isOverflow:boolean) => Object; + } + + export interface KeyBoard { + parseKey: (event:any) => String; + findFocusable: ($element:Object) => Object; + } + + export interface MediaQuery { + get: (size:String) => String; + atLeast: (size:String) => boolean; + queries:Array; + current:any; + } + + export interface Motion { + animateIn: (element: Object, animation:any, cb:Function) => void; + animateOut: (element: Object, animation:any, cb:Function) => void; + } + + interface Move { + // TODO + } + + interface Nest { + // TODO + } + + export interface Timer { + start: () => void; + restart: () => void; + pause: () => void; + } + + interface Touch { + // TODO :extension on jQuery + } + + interface Triggers { + // TODO :extension on jQuery + } + + interface FoundationStatic { + version : string; + + rtl: () => boolean; + plugin: (plugin: Object, name:String) => void; + registerPlugin: (plugin: Object) => void; + unregisterPlugin: (plugin: Object) => void; + GetYoDigits: (length: number, namespace?: String) => String; + reflow: (elem: Object, plugins?: Array|String) => void; + getFnName: (fn: String) => String; + transitionend: () => String; + + util : { + throttle(func : (...args : any[]) => any, delay : number) : (...args : any[]) => any; + }; + onImagesLoaded: (images:Object, cb:Function) => void; + + Abide: (element:Object, options:AbideOptions) => void; + + } +} + +interface JQuery { + foundation(method:String|Array) : JQuery; +} + +declare var Foundation : Foundation.FoundationStatic; From a900641acedbaa2c647513f353ca5850aac33980 Mon Sep 17 00:00:00 2001 From: Kaoru Hagihara Date: Sun, 6 Dec 2015 16:55:24 +0900 Subject: [PATCH 025/353] 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 297379bbb..03c3e684f 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 cb707348a..4af732579 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 fad091f943a06f81f06c0d174d657fdf8c476657 Mon Sep 17 00:00:00 2001 From: Artem Berezin Date: Sun, 6 Dec 2015 17:45:33 +0900 Subject: [PATCH 026/353] Update angular-resource.d.ts fix IResourceArray. It is of array of IResource, not array of just T --- angularjs/angular-resource.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 76930196b..442d8fa60 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -141,7 +141,7 @@ declare module angular.resource { /** * Really just a regular Array object with $promise and $resolve attached to it */ - interface IResourceArray extends Array { + interface IResourceArray extends Array> { /** the promise of the original server interaction that created this collection. **/ $promise : angular.IPromise>; $resolved : boolean; From 9e91f2a6c21d668479629c1e708e677176f9a973 Mon Sep 17 00:00:00 2001 From: Sascha Thiel Date: Mon, 7 Dec 2015 14:31:10 +0100 Subject: [PATCH 027/353] PesistenceOptions is actually JQueryAjaxSettings. backbone.js:Backbone.sync > // Make the request, allowing the user to override any Ajax options. > var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); --- backbone/backbone-global.d.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/backbone/backbone-global.d.ts b/backbone/backbone-global.d.ts index 764aa83d7..192377f5f 100644 --- a/backbone/backbone-global.d.ts +++ b/backbone/backbone-global.d.ts @@ -41,11 +41,7 @@ declare module Backbone { parse?: any; } - interface PersistenceOptions { - url?: string; - beforeSend?: (jqxhr: JQueryXHR) => void; - success?: (modelOrCollection?: any, response?: any, options?: any) => void; - error?: (modelOrCollection?: any, jqxhr?: JQueryXHR, options?: any) => void; + interface PersistenceOptions extends JQueryAjaxSettings { } interface ModelSetOptions extends Silenceable, Validable { From 2f5765d6be3f8f5a0236a841b352d231e0cd257b Mon Sep 17 00:00:00 2001 From: Sascha Thiel Date: Mon, 7 Dec 2015 15:08:00 +0100 Subject: [PATCH 028/353] isn't the same, so just added the "data" attribute. --- backbone/backbone-global.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backbone/backbone-global.d.ts b/backbone/backbone-global.d.ts index 192377f5f..c16e1a59e 100644 --- a/backbone/backbone-global.d.ts +++ b/backbone/backbone-global.d.ts @@ -41,7 +41,12 @@ declare module Backbone { parse?: any; } - interface PersistenceOptions extends JQueryAjaxSettings { + interface PersistenceOptions { + url?: string; + data?: any; + beforeSend?: (jqxhr: JQueryXHR) => void; + success?: (modelOrCollection?: any, response?: any, options?: any) => void; + error?: (modelOrCollection?: any, jqxhr?: JQueryXHR, options?: any) => void; } interface ModelSetOptions extends Silenceable, Validable { From f67852cbc81823e9d0178e9cdc89aea4a5e3c40c Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Mon, 7 Dec 2015 18:29:53 +0100 Subject: [PATCH 029/353] Update validator: add "isMACAddress" function. --- validator/validator-tests.ts | 2 ++ validator/validator.d.ts | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/validator/validator-tests.ts b/validator/validator-tests.ts index b7f45d427..c5a55f59c 100644 --- a/validator/validator-tests.ts +++ b/validator/validator-tests.ts @@ -19,6 +19,8 @@ validator.isURL("sample"); validator.isFQDN("sample"); +validator.isMACAddress("sample"); + validator.isIP("sample"); validator.isAlpha("sample"); diff --git a/validator/validator.d.ts b/validator/validator.d.ts index 05a391fa4..2b29efac0 100644 --- a/validator/validator.d.ts +++ b/validator/validator.d.ts @@ -22,7 +22,7 @@ interface IEmailoptions { lowercase?: boolean } -// callback type for #extend +// callback type for #extend interface IExtendCallback { (argv: string): any } @@ -54,6 +54,9 @@ interface IValidatorStatic { // check if the string is a fully qualified domain name (e.g. domain.com). isFQDN(str: string, options?: IFQDNoptions): boolean; + // check if the string is a MAC address. + isMACAddress(str: string): boolean; + // check if the string is an IP (version 4 or 6). isIP(str: string, version?: number): boolean; @@ -177,7 +180,7 @@ interface IValidatorStatic { // remove characters that do not appear in the whitelist. whitelist(input: string, chars: string): string; - // remove characters that appear in the blacklist. + // remove characters that appear in the blacklist. blacklist(input: string, chars: string): string; // canonicalize an email address. From b2ee74c4c726246604c9e6dd8f8f5cab98b03eda Mon Sep 17 00:00:00 2001 From: Andrzej Gis Date: Mon, 7 Dec 2015 18:22:45 +0100 Subject: [PATCH 030/353] 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 0ea66d32e..2a7e418f7 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 565a3c25d..94e6ab51c 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 c6a1eb87530f8bbe638b121f4099b33f00dd3bd2 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Mon, 7 Dec 2015 18:46:54 +0100 Subject: [PATCH 031/353] Add definition "express-brute". --- express-brute/express-brute-tests.ts | 16 ++++ express-brute/express-brute.d.ts | 129 +++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 express-brute/express-brute-tests.ts create mode 100644 express-brute/express-brute.d.ts diff --git a/express-brute/express-brute-tests.ts b/express-brute/express-brute-tests.ts new file mode 100644 index 000000000..ea0f2f5b4 --- /dev/null +++ b/express-brute/express-brute-tests.ts @@ -0,0 +1,16 @@ +/// + +import express = require("express"); +import ExpressBrute = require("express-brute"); + +var store = new ExpressBrute.MemoryStore(); +store = new ExpressBrute.MemoryStore({ prefix: "prefix" }); +store.set("key", "value", 0, (error: any) => { }); +store.get("key", (error: any, data: Object) => { }); +store.reset("key", (error: any) => { }); + +var app = express(); +var bruteforce = new ExpressBrute(store); +app.post("/auth", bruteforce.prevent, (req, res, next) => { + res.send("Success!"); +}); diff --git a/express-brute/express-brute.d.ts b/express-brute/express-brute.d.ts new file mode 100644 index 000000000..377efcdce --- /dev/null +++ b/express-brute/express-brute.d.ts @@ -0,0 +1,129 @@ +// Type definitions for express-validator 2.9.0 +// Project: https://github.com/AdamPflug/express-brute +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "express-brute" { + import express = require("express"); + + /** + * @summary Options for {@link MemoryStore} class. + * @interface + */ + interface MemoryStoreOptions { + /** + * @summary Key prefix. + * @type {string} + */ + prefix: string; + } + + /** + * @summary Options for {@link ExpressBrute#getMiddleware} class. + * @interface + */ + interface ExpressBruteMiddleware { + /** + * @summary Allows you to override the value of failCallback for this middleware. + * @type {Function} + */ + failCallback: Function; + + /** + * @summary Disregard IP address when matching requests if set to true. Defaults to false. + * @type {boolean} + */ + ignoreIP: boolean; + + /** + * @summary Key. + * @type {any} + */ + key: any; + } + + /** + * @summary Middleware. + * @class + */ + class ExpressBrute { + /** + * @summary Constructor. + * @constructor + * @param {any} store The store. + */ + constructor(store: any); + + /** + * @summary Generates middleware that will bounce requests with the same key and IP address that happen faster than the current wait time by calling failCallback. + * @param {Object} options The options. + */ + getMiddleware(options: ExpressBruteMiddleware): express.RequestHandler; + + /** + * @summary Uses the current proxy trust settings to get the current IP from a request object. + * @param {Request} request The HTTP request. + * @return {RequestHandler} The Request handler. + */ + getIPFromRequest(request: express.Request): express.RequestHandler; + + /** + * @summary Middleware that will bounce requests that happen faster than the current wait time by calling failCallback. + * @param {Request} request The HTTP request. + * @param {Response} response The HTTP response. + * @param {Function} next The next middleware. + * @return {RequestHandler} The Request handler. + */ + prevent(request: express.Request, response: express.Response, next: Function): express.RequestHandler; + + /** + * @summary Resets the wait time between requests back to its initial value. + * @param {string} ip The IP address. + * @param {string} key The key. response. + * @param {Function} next The next middleware. + * @return {RequestHandler} The Request handler. + */ + reset(ip: string, key: string, next: Function): express.RequestHandler; + } + + module ExpressBrute { + /** + * @summary In-memory store. + * @class + */ + export class MemoryStore { + /** + * @summary Constructor. + * @constructor + * @param {Object} options The options. + */ + constructor(options?: MemoryStoreOptions); + /** + * @summary Gets key value. + * @param {string} key The key name. + * @param {Function} callbck The callback. + */ + get(key: string, callback: (error: any, data: Object) => void): void; + + /** + * @summary Sets the key value. + * @param {string} key The name. + * @param {string} value The value. + * @param {number} lifetime The lifetime. + * @param {Function} callback The callback. + */ + set(key: string, value: any, lifetime: number, callback: (error: any) => void): void; + + /** + * @summary Deletes the key. + * @param {string} key The name. + * @param {Function} callback The callback. + */ + reset(key: string, callback: (error: any) => void): void; + } + } + + export = ExpressBrute; +} From 41ecb256fe6fe1c59c537d158721ba68d783e16b Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Mon, 7 Dec 2015 19:19:49 +0100 Subject: [PATCH 032/353] Add definition for "express-brute-mongo". --- .../express-brute-mongo-tests.ts | 27 +++++++++++++++++++ express-brute-mongo/express-brute-mongo.d.ts | 22 +++++++++++++++ express-brute/express-brute.d.ts | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 express-brute-mongo/express-brute-mongo-tests.ts create mode 100644 express-brute-mongo/express-brute-mongo.d.ts diff --git a/express-brute-mongo/express-brute-mongo-tests.ts b/express-brute-mongo/express-brute-mongo-tests.ts new file mode 100644 index 000000000..a4512782b --- /dev/null +++ b/express-brute-mongo/express-brute-mongo-tests.ts @@ -0,0 +1,27 @@ +/// +/// +/// + +import express = require("express"); +import ExpressBrute = require("express-brute"); +import MongoStore = require("express-brute-mongo"); +import mongodb = require("mongodb"); +var MongoClient = mongodb.MongoClient; + +var store = new MongoStore(ready => { + MongoClient.connect("mongodb://127.0.0.1:27017/test", (err, db) => { + if (err) { + throw err; + } + + var collection = db.collection("bruteforce-store"); + ready(collection); + }); +}); + +var app = express(); +var bruteforce = new ExpressBrute(store); + +app.post("/auth", bruteforce.prevent, (req, res, next) => { + res.send("Success!"); +}); diff --git a/express-brute-mongo/express-brute-mongo.d.ts b/express-brute-mongo/express-brute-mongo.d.ts new file mode 100644 index 000000000..bc4d5e43d --- /dev/null +++ b/express-brute-mongo/express-brute-mongo.d.ts @@ -0,0 +1,22 @@ +// Type definitions for express-brute-mongo +// Project: https://github.com/auth0/express-brute-mongo +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "express-brute-mongo" { + /** + * @summary MongoDB store adapter. + * @class + */ + export = class MongoStore { + /** + * @summary Constructor. + * @constructor + * @param {Function} getCollection The collection. + * @param {Object} options The otpions. + */ + constructor(getCollection: (collection: any) => void, options?: Object); + } +} diff --git a/express-brute/express-brute.d.ts b/express-brute/express-brute.d.ts index 377efcdce..7242d44dc 100644 --- a/express-brute/express-brute.d.ts +++ b/express-brute/express-brute.d.ts @@ -1,4 +1,4 @@ -// Type definitions for express-validator 2.9.0 +// Type definitions for express-brute // Project: https://github.com/AdamPflug/express-brute // Definitions by: Cyril Schumacher // Definitions: https://github.com/borisyankov/DefinitelyTyped From a961bfca179fd8d16dcdc166bc4c026d11e3fec6 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Mon, 7 Dec 2015 19:39:31 +0100 Subject: [PATCH 033/353] Update definition for "nodemailer". --- nodemailer/nodemailer-tests.ts | 16 ++++++++++++++-- nodemailer/nodemailer.d.ts | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/nodemailer/nodemailer-tests.ts b/nodemailer/nodemailer-tests.ts index 1d99046c0..a991096d5 100644 --- a/nodemailer/nodemailer-tests.ts +++ b/nodemailer/nodemailer-tests.ts @@ -11,6 +11,20 @@ var transporter: nodemailer.Transporter = nodemailer.createTransport({ } }); +// create reusable transporter object using SMTP transport and set default values for mail options. +transporter = nodemailer.createTransport({ + service: 'Gmail', + auth: { + user: 'gmail.user@gmail.com', + pass: 'userpass' + } +}, { + from: 'sender@address', + headers: { + 'My-Awesome-Header': '123' + } +}); + // setup e-mail data with unicode symbols var mailOptions: nodemailer.SendMailOptions = { from: 'Fred Foo ✔ ', // sender address @@ -24,5 +38,3 @@ var mailOptions: nodemailer.SendMailOptions = { transporter.sendMail(mailOptions, (error: Error, info: nodemailer.SentMessageInfo): void => { // nothing }); - - diff --git a/nodemailer/nodemailer.d.ts b/nodemailer/nodemailer.d.ts index e0d1300b0..e7d09f54f 100644 --- a/nodemailer/nodemailer.d.ts +++ b/nodemailer/nodemailer.d.ts @@ -51,13 +51,13 @@ declare module "nodemailer" { /** * Create a direct transporter */ - export function createTransport(options?: directTransport.DirectOptions): Transporter; + export function createTransport(options?: directTransport.DirectOptions, defaults?: Object): Transporter; /** * Create an SMTP transporter */ - export function createTransport(options?: smtpTransport.SmtpOptions): Transporter; + export function createTransport(options?: smtpTransport.SmtpOptions, defaults?: Object): Transporter; /** * Create a transporter from a given implementation */ - export function createTransport(transport: Transport): Transporter; + export function createTransport(transport: Transport, defaults?: Object): Transporter; } From 5111e014788097f739548ef63025bc22371a5ae9 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Tue, 8 Dec 2015 10:24:22 +0100 Subject: [PATCH 034/353] Add definition for "connect-timeout". --- connect-timeout/connect-timeout-tests.ts | 28 ++++++++++++++++++ connect-timeout/connect-timeout.d.ts | 36 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 connect-timeout/connect-timeout-tests.ts create mode 100644 connect-timeout/connect-timeout.d.ts diff --git a/connect-timeout/connect-timeout-tests.ts b/connect-timeout/connect-timeout-tests.ts new file mode 100644 index 000000000..283ee2679 --- /dev/null +++ b/connect-timeout/connect-timeout-tests.ts @@ -0,0 +1,28 @@ +/// +/// +/// +/// + +import express = require("express"); +import timeout = require("connect-timeout"); +import bodyParser = require("body-parser"); +import cookieParser = require("cookie-parser"); + +// example of using this top-level; note the use of haltOnTimedout +// after every middleware; it will stop the request flow on a timeout +var app = express(); +app.use(timeout("5s", { respond: false })); +app.use(bodyParser()); +app.use(haltOnTimedout); +app.use(cookieParser()); +app.use(haltOnTimedout); + +// Add your routes here, etc. + +function haltOnTimedout(req, res, next) { + if (!req.timedout) { + next(); + } +} + +app.listen(3000); diff --git a/connect-timeout/connect-timeout.d.ts b/connect-timeout/connect-timeout.d.ts new file mode 100644 index 000000000..8b7ff2879 --- /dev/null +++ b/connect-timeout/connect-timeout.d.ts @@ -0,0 +1,36 @@ +// Type definitions for connect-timeout +// Project: https://github.com/expressjs/timeout +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Express { + export interface Request { + /** + * @summary Clears the timeout on the request. + */ + clearTimeout(): void; + + /** + * + * @return {boolean} true if timeout fired; false otherwise. + */ + timedout(event: string, message: string): boolean; + } +} + +declare module "connect-timeout" { + import express = require("express"); + + interface TimeoutOptions extends Object { + /** + * @summary Controls if this module will "respond" in the form of forwarding an error. + * @type {boolean} + */ + respond: boolean; + } + + function timeout(timeout: string, options?: TimeoutOptions): express.RequestHandler; + export = timeout; +} From 784857f638e949d67c80fcd7d7f5ab5de53fb808 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Tue, 8 Dec 2015 10:26:56 +0100 Subject: [PATCH 035/353] Fix errors. --- connect-timeout/connect-timeout-tests.ts | 2 +- connect-timeout/connect-timeout.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/connect-timeout/connect-timeout-tests.ts b/connect-timeout/connect-timeout-tests.ts index 283ee2679..920c7fdc6 100644 --- a/connect-timeout/connect-timeout-tests.ts +++ b/connect-timeout/connect-timeout-tests.ts @@ -19,7 +19,7 @@ app.use(haltOnTimedout); // Add your routes here, etc. -function haltOnTimedout(req, res, next) { +function haltOnTimedout(req: express.Request, res: express.Response, next: Function) { if (!req.timedout) { next(); } diff --git a/connect-timeout/connect-timeout.d.ts b/connect-timeout/connect-timeout.d.ts index 8b7ff2879..8494a3afb 100644 --- a/connect-timeout/connect-timeout.d.ts +++ b/connect-timeout/connect-timeout.d.ts @@ -1,6 +1,6 @@ // Type definitions for connect-timeout // Project: https://github.com/expressjs/timeout -// Definitions by: Cyril Schumacher +// Definitions by: Cyril Schumacher // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From be0eda50824f411753ec1364d341e5305000b4ab Mon Sep 17 00:00:00 2001 From: lgrignon Date: Tue, 8 Dec 2015 10:59:11 +0100 Subject: [PATCH 036/353] 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 000000000..fe4d93041 --- /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 000000000..5e57694e4 --- /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 000000000..0c434b432 --- /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 000000000..a1e00514f --- /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 000000000..6269a4b9d --- /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 000000000..68b24ca27 --- /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 037/353] 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 a1e00514f..34b752065 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 038/353] 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 5e57694e4..8c10fe0de 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 039/353] 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 0c434b432..4175d0862 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 040/353] 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 8c10fe0de..20db40a62 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 34b752065..96b11f95d 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 041/353] 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 96b11f95d..465861644 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 042/353] 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 000000000..7334afc83 --- /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 000000000..2f31889c2 --- /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 043/353] 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 da1343413..4fa378bc2 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 f5cf9bcb2..0d692b824 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 b8c618001c9769b653da68e2f8b7d279f12b0366 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Wed, 9 Dec 2015 10:42:31 +0100 Subject: [PATCH 044/353] Update definition for "express-validator": add "isMACAddress" function. --- express-validator/express-validator.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/express-validator/express-validator.d.ts b/express-validator/express-validator.d.ts index 428c90afd..78073231b 100644 --- a/express-validator/express-validator.d.ts +++ b/express-validator/express-validator.d.ts @@ -66,12 +66,14 @@ declare module ExpressValidator { * Accepts http, https, ftp */ isUrl(): Validator; + /** * Combines isIPv4 and isIPv6 */ isIP(): Validator; isIPv4(): Validator; isIPv6(): Validator; + isMACAddress(): Validator; isAlpha(): Validator; isAlphanumeric(): Validator; isNumeric(): Validator; From 0eef583c76ec45f52808b60fe4be2bf835c859a4 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 7 Dec 2015 05:31:07 +0500 Subject: [PATCH 045/353] node: signatures of module "querystring" have been changed --- node/node-tests.ts | 47 ++++++++++++++++++++++++++++++++++++++-------- node/node.d.ts | 14 ++++++++++++-- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index 4ca651b33..aa0f55bb6 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -239,16 +239,47 @@ ds.send(new Buffer("hello"), 0, 5, 5000, "127.0.0.1", (error: Error, bytes: numb }); //////////////////////////////////////////////////// -///Querystring tests : https://gist.github.com/musubu/2202583 +///Querystring tests : https://nodejs.org/api/querystring.html //////////////////////////////////////////////////// -var original: string = 'http://example.com/product/abcde.html'; -var escaped: string = querystring.escape(original); -console.log(escaped); -// http%3A%2F%2Fexample.com%2Fproduct%2Fabcde.html -var unescaped: string = querystring.unescape(escaped); -console.log(unescaped); -// http://example.com/product/abcde.html +module querystring_tests { + type SampleObject = {a: string; b: number;} + + { + let obj: SampleObject; + let sep: string; + let eq: string; + let options: querystring.StringifyOptions; + let result: string; + + result = querystring.stringify(obj); + result = querystring.stringify(obj, sep); + result = querystring.stringify(obj, sep, eq); + result = querystring.stringify(obj, sep, eq); + result = querystring.stringify(obj, sep, eq, options); + } + + { + let str: string; + let sep: string; + let eq: string; + let options: querystring.ParseOptions; + let result: SampleObject; + + result = querystring.parse(str); + result = querystring.parse(str, sep); + result = querystring.parse(str, sep, eq); + result = querystring.parse(str, sep, eq, options); + } + + { + let str: string; + let result: string; + + result = querystring.escape(str); + result = querystring.unescape(str); + } +} //////////////////////////////////////////////////// /// path tests : http://nodejs.org/api/path.html diff --git a/node/node.d.ts b/node/node.d.ts index 39be040a4..34e6ffedc 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -405,8 +405,18 @@ declare module "buffer" { } declare module "querystring" { - export function stringify(obj: any, sep?: string, eq?: string): string; - export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any; + export interface StringifyOptions { + encodeURIComponent?: Function; + } + + export interface ParseOptions { + maxKeys?: number; + decodeURIComponent?: Function; + } + + export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; export function escape(str: string): string; export function unescape(str: string): string; } From 87b5e5f03fdfa0e2561c87c9cca4a3c4d8817d64 Mon Sep 17 00:00:00 2001 From: Kaoru Hagihara Date: Thu, 10 Dec 2015 23:01:39 +0900 Subject: [PATCH 046/353] 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 4af732579..650c8d98c 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 624237a55346531ec0b6e9194895d36993eab051 Mon Sep 17 00:00:00 2001 From: Adam Babcock Date: Thu, 10 Dec 2015 09:34:27 -0600 Subject: [PATCH 047/353] Add containDeepOrdered --- should/should-tests.ts | 7 +++++++ should/should.d.ts | 1 + 2 files changed, 8 insertions(+) diff --git a/should/should-tests.ts b/should/should-tests.ts index c940f7c13..43b21d0ef 100644 --- a/should/should-tests.ts +++ b/should/should-tests.ts @@ -172,3 +172,10 @@ obj.should.have.keys('foo', 'bar'); obj.should.have.keys(['foo', 'bar']); (1).should.eql(0, 'some useful description'); + +[ 1, 2, 3].should.containDeepOrdered([1, 2]); +[ 1, 2, [ 1, 2, 3 ]].should.containDeepOrdered([ 1, [ 2, 3 ]]); + +({ a: 10, b: { c: 10, d: [1, 2, 3] }}).should.containDeepOrdered({a: 10}); +({ a: 10, b: { c: 10, d: [1, 2, 3] }}).should.containDeepOrdered({b: {c: 10}}); +({ a: 10, b: { c: 10, d: [1, 2, 3] }}).should.containDeepOrdered({b: {d: [1, 3]}}); diff --git a/should/should.d.ts b/should/should.d.ts index ba32f571b..26a42d7ed 100644 --- a/should/should.d.ts +++ b/should/should.d.ts @@ -64,6 +64,7 @@ interface ShouldAssertion { contain(obj: any): ShouldAssertion; containEql(obj: any): ShouldAssertion; containDeep(obj: any): ShouldAssertion; + containDeepOrdered(obj: any): ShouldAssertion; keys(...allKeys: string[]): ShouldAssertion; keys(allKeys: string[]): ShouldAssertion; header(field: string, val?: string): ShouldAssertion; 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 048/353] 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 7c5fa8b4d..48f893d06 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 049/353] 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 000000000..c20782030 --- /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 000000000..14fce22a5 --- /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 000000000..61a0e6e97 --- /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 000000000..14fce22a5 --- /dev/null +++ b/wu/wu.d.ts.tscparams @@ -0,0 +1 @@ +--target ES6 From 9d54d10a8847504e6009c15aba5244942941b6d8 Mon Sep 17 00:00:00 2001 From: Alexander <4nonym0us@xakep.ru> Date: Thu, 10 Dec 2015 21:09:58 +0200 Subject: [PATCH 050/353] Raact to Ionic 1.2 release https://github.com/driftyco/ionic/pull/4613/files --- ionic/ionic.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ionic/ionic.d.ts b/ionic/ionic.d.ts index bb009df51..ce097a226 100644 --- a/ionic/ionic.d.ts +++ b/ionic/ionic.d.ts @@ -343,6 +343,7 @@ declare module ionic { select(index: number): void; selectedIndex(): number; $getByHandle(handle: string): IonicTabsDelegate; + showBar(show?: boolean): boolean; } } module utility { From 4a61f4eccd1f334ac07c24f68e8668b7e7913f37 Mon Sep 17 00:00:00 2001 From: Nax Date: Thu, 10 Dec 2015 20:18:16 +0100 Subject: [PATCH 051/353] Added socketty v0.2.2 --- socketty/socketty.d.ts | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 socketty/socketty.d.ts diff --git a/socketty/socketty.d.ts b/socketty/socketty.d.ts new file mode 100644 index 000000000..9cbbeeef9 --- /dev/null +++ b/socketty/socketty.d.ts @@ -0,0 +1,57 @@ +// Type definitions for Socketty v0.2.2 +// Project: https://www.npmjs.com/package/socketty +// Definitions by: Nax +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare var socketty: Socketty; + +declare module 'socketty' { + export = socketty; +} + +interface Socketty { + /** + * Connect to a socketty server. + * @param url The server url + * @param callback The callback to be run when the connection is open + * @return A Socket + */ + connect(url: string, callback: (SockettySocket) => void): SockettySocket; + + /** + * Create a socketty server. + * @param httpServer The HTTP server to use + * @return A socketty server + */ + createServer(httpServer: any): void; +} + +interface SockettySocket { + /** + * Listen for an action. + * @param action The action to listen to + * @param callback A callback to be run when the action is fired + */ + on(action: string, callback: (any?) => void): void; + + /** + * Send an action, as well as an optional message. + * @param action The action to send + * @param message The message to send + */ + send(action: string, message?: any): void; + + /** + * Specify a callback to be run when the socket is disconnected. + * @param callback The disconnect callback + */ + disconnect(callback: () => void): void; +} + +interface SockettyServer { + /** + * Specify a callback to be run when a new socket connects to the server. + * @param callback The callback + */ + connection(callback: (SockettySocket) => void): void; +} From 6f04aca222d233a4c610b5020a09c760140d33f5 Mon Sep 17 00:00:00 2001 From: Nax Date: Thu, 10 Dec 2015 20:39:16 +0100 Subject: [PATCH 052/353] Fixed typescript errors and added tests --- socketty/socketty-tests.ts | 24 ++++++++++++++++++++++++ socketty/socketty.d.ts | 8 ++++---- 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 socketty/socketty-tests.ts diff --git a/socketty/socketty-tests.ts b/socketty/socketty-tests.ts new file mode 100644 index 000000000..22809a6b0 --- /dev/null +++ b/socketty/socketty-tests.ts @@ -0,0 +1,24 @@ +/// + +/* Server */ + +var httpServer = {}; // Assume it's a real HTTP server object + +var webSocketServer = socketty.createServer(httpServer); + +webSocketServer.connection((socket: SockettySocket) => { + console.log('Client connected'); + socket.on('msg', (message?: any) => { + console.log('Client said' + message); + }); + socket.disconnect(() => { + console.log('Goodbye, client!'); + }); +}); + +/* Client */ + +socketty.connect('ws://localhost:8080', (socket: SockettySocket) => { + console.log('Connected !'); + socket.send('msg', 'Hello server!'); +}); diff --git a/socketty/socketty.d.ts b/socketty/socketty.d.ts index 9cbbeeef9..da7f82507 100644 --- a/socketty/socketty.d.ts +++ b/socketty/socketty.d.ts @@ -16,14 +16,14 @@ interface Socketty { * @param callback The callback to be run when the connection is open * @return A Socket */ - connect(url: string, callback: (SockettySocket) => void): SockettySocket; + connect(url: string, callback: (socket: SockettySocket) => void): SockettySocket; /** * Create a socketty server. * @param httpServer The HTTP server to use * @return A socketty server */ - createServer(httpServer: any): void; + createServer(httpServer: any): SockettyServer; } interface SockettySocket { @@ -32,7 +32,7 @@ interface SockettySocket { * @param action The action to listen to * @param callback A callback to be run when the action is fired */ - on(action: string, callback: (any?) => void): void; + on(action: string, callback: (message?: any) => void): void; /** * Send an action, as well as an optional message. @@ -53,5 +53,5 @@ interface SockettyServer { * Specify a callback to be run when a new socket connects to the server. * @param callback The callback */ - connection(callback: (SockettySocket) => void): void; + connection(callback: (socket: SockettySocket) => void): void; } From c48c6ff985ad6c2dc12976c86fc959bf56bad48c Mon Sep 17 00:00:00 2001 From: Samuel Reed Date: Thu, 10 Dec 2015 13:42:29 -0600 Subject: [PATCH 053/353] Fix Bluebird nodeify() when not passed callback .nodeify() will return the Promise it was called on, not void, when no callback is passed. --- bluebird/bluebird.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index da3b9902a..f3420957a 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -117,7 +117,7 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { * Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything. */ nodeify(callback: (err: any, value?: R) => void, options?: Promise.SpreadOption): Promise; - nodeify(...sink: any[]): void; + nodeify(...sink: any[]): Promise; /** * Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise. From be2e3466d4007b38209664d0508ab23181886e56 Mon Sep 17 00:00:00 2001 From: Alexander <4nonym0us@xakep.ru> Date: Thu, 10 Dec 2015 22:55:08 +0200 Subject: [PATCH 054/353] Adding tests for $ionicTabsDelegate.showBar() --- ionic/ionic-tests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ionic/ionic-tests.ts b/ionic/ionic-tests.ts index c68846715..9c5cfdad0 100644 --- a/ionic/ionic-tests.ts +++ b/ionic/ionic-tests.ts @@ -360,6 +360,8 @@ class IonicTestController { this.$ionicTabsDelegate.select(1); var selectedIndex: number = this.$ionicTabsDelegate.selectedIndex(); var ionicTabsDelegate: ionic.tabs.IonicTabsDelegate = this.$ionicTabsDelegate.$getByHandle("handle"); + this.$ionicTabsDelegate.showBar(true); + var isBarShown: boolean = this.$ionicTabsDelegate.showBar(); } private testUtility(): void { var {top: number, left: number, width: number, height: number} = this.$ionicPositionService.position(angular.element("body")); From d84ba2d2c36776b81a954ad2b84cefb560dc2cd9 Mon Sep 17 00:00:00 2001 From: stunaz Date: Thu, 10 Dec 2015 19:55:49 -0500 Subject: [PATCH 055/353] =?UTF-8?q?-=20Added=20namespace=20=E2=80=98Loadin?= =?UTF-8?q?gBar=E2=80=99=20-=20Added=20loadingBar=20interface=20Definition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../angular-loading-bar-tests.ts | 10 +++++++ angular-loading-bar/angular-loading-bar.d.ts | 26 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/angular-loading-bar/angular-loading-bar-tests.ts b/angular-loading-bar/angular-loading-bar-tests.ts index b7ca2894e..6acdfa6d5 100644 --- a/angular-loading-bar/angular-loading-bar-tests.ts +++ b/angular-loading-bar/angular-loading-bar-tests.ts @@ -13,3 +13,13 @@ class TestController { } app.controller('TestController', TestController); + + + +var barConfig: angular.loadingBar.ILoadingBarProvider[] = []; +barConfig.push({ + includeSpinner: true, + includeBar: true, + spinnerTemplate: 'template', + latencyThreshold: 100 +}); diff --git a/angular-loading-bar/angular-loading-bar.d.ts b/angular-loading-bar/angular-loading-bar.d.ts index b1a8cd55d..d026db098 100644 --- a/angular-loading-bar/angular-loading-bar.d.ts +++ b/angular-loading-bar/angular-loading-bar.d.ts @@ -6,7 +6,7 @@ /// -declare module angular { +declare module angular.loadingBar { interface IRequestShortcutConfig { /** @@ -15,4 +15,26 @@ declare module angular { ignoreLoadingBar?: boolean; } -} \ No newline at end of file + interface ILoadingBarProvider{ + /** + * Turn the spinner on or off + */ + includeSpinner?: boolean; + + /** + * Turn the loading bar on or off + */ + includeBar?: boolean; + + /** + * HTML template + */ + spinnerTemplate?: string; + + /** + * Latency Threshold + */ + latencyThreshold?: number; + } + +} From 79e875c9566e3da496fe68292d11700f2bc9a6af Mon Sep 17 00:00:00 2001 From: Artem Berezin Date: Fri, 11 Dec 2015 11:13:32 +0900 Subject: [PATCH 056/353] Update angular-resource.d.ts --- angularjs/angular-resource.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 442d8fa60..fca03678f 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -141,7 +141,7 @@ declare module angular.resource { /** * Really just a regular Array object with $promise and $resolve attached to it */ - interface IResourceArray extends Array> { + interface IResourceArray extends Array> { /** the promise of the original server interaction that created this collection. **/ $promise : angular.IPromise>; $resolved : boolean; From 7238dde0a51c96f6c3d0fbde772d9f510a59050c Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 11 Dec 2015 09:43:45 +0500 Subject: [PATCH 057/353] lodash: signatures of _.debounce have been changed --- lodash/lodash-tests.ts | 56 ++++++++++++++++++--------- lodash/lodash.d.ts | 87 +++++++++++++++++++++++++----------------- 2 files changed, 90 insertions(+), 53 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index b4528be6d..2d244b16e 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -4811,28 +4811,50 @@ curryResult7 = _.curryRight(testCurry2)(true)(2); curryResult8 = _.curryRight(testCurry2)(true); curryResult9 = _.curryRight(testCurry2); -declare var source: any; -result = _.debounce(function () { }, 150); +// _.debounce +module TestDebounce { + interface SampleFunc { + (n: number, s: string): boolean; + } -jQuery('#postbox').on('click', _.debounce(function () { }, 300, { - 'leading': true, - 'trailing': false -})); + interface Options { + leading?: boolean; + maxWait?: number; + trailing?: boolean; + } -source.addEventListener('message', _.debounce(function () { }, 250, { - 'maxWait': 1000 -}), false); + interface ResultFunc { + (n: number, s: string): boolean; + cancel(): void; + } -result = <_.LoDashImplicitObjectWrapper>_(function () { }).debounce(150); + let func: SampleFunc; + let options: Options; -jQuery('#postbox').on('click', <_.LoDashImplicitObjectWrapper>_(function () { }).debounce(300, { - 'leading': true, - 'trailing': false -})); + { + let result: ResultFunc; -source.addEventListener('message', <_.LoDashImplicitObjectWrapper>_(function () { }).debounce(250, { - 'maxWait': 1000 -}), false); + result = _.debounce(func); + result = _.debounce(func, 42); + result = _.debounce(func, 42, options); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _(func).debounce(); + result = _(func).debounce(42); + result = _(func).debounce(42, options); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(func).chain().debounce(); + result = _(func).chain().debounce(42); + result = _(func).chain().debounce(42, options); + } +} // _.defer module TestDefer { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index f44d3f63f..8425f1d82 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -8380,54 +8380,69 @@ declare module _ { } //_.debounce + interface DebounceSettings { + /** + * Specify invoking on the leading edge of the timeout. + */ + leading?: boolean; + + /** + * The maximum time func is allowed to be delayed before it’s invoked. + */ + maxWait?: number; + + /** + * Specify invoking on the trailing edge of the timeout. + */ + trailing?: boolean; + } + interface LoDashStatic { /** - * Creates a function that will delay the execution of func until after wait milliseconds have - * elapsed since the last time it was invoked. Provide an options object to indicate that func - * should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls - * to the debounced function will return the result of the last func call. - * - * Note: If leading and trailing options are true func will be called on the trailing edge of - * the timeout only if the the debounced function is invoked more than once during the wait - * timeout. - * @param func The function to debounce. - * @param wait The number of milliseconds to delay. - * @param options The options object. - * @param options.leading Specify execution on the leading edge of the timeout. - * @param options.maxWait The maximum time func is allowed to be delayed before it's called. - * @param options.trailing Specify execution on the trailing edge of the timeout. - * @return The new debounced function. - **/ + * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since + * the last time the debounced function was invoked. The debounced function comes with a cancel method to + * cancel delayed invocations. Provide an options object to indicate that func should be invoked on the + * leading and/or trailing edge of the wait timeout. Subsequent calls to the debounced function return the + * result of the last func invocation. + * + * Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only + * if the the debounced function is invoked more than once during the wait timeout. + * + * See David Corbacho’s article for details over the differences between _.debounce and _.throttle. + * + * @param func The function to debounce. + * @param wait The number of milliseconds to delay. + * @param options The options object. + * @param options.leading Specify invoking on the leading edge of the timeout. + * @param options.maxWait The maximum time func is allowed to be delayed before it’s invoked. + * @param options.trailing Specify invoking on the trailing edge of the timeout. + * @return Returns the new debounced function. + */ debounce( func: T, - wait: number, - options?: DebounceSettings): T; + wait?: number, + options?: DebounceSettings + ): T & Cancelable; } interface LoDashImplicitObjectWrapper { /** - * @see _.debounce - **/ + * @see _.debounce + */ debounce( - wait: number, - options?: DebounceSettings): LoDashImplicitObjectWrapper; + wait?: number, + options?: DebounceSettings + ): LoDashImplicitObjectWrapper; } - interface DebounceSettings { + interface LoDashExplicitObjectWrapper { /** - * Specify execution on the leading edge of the timeout. - **/ - leading?: boolean; - - /** - * The maximum time func is allowed to be delayed before it's called. - **/ - maxWait?: number; - - /** - * Specify execution on the trailing edge of the timeout. - **/ - trailing?: boolean; + * @see _.debounce + */ + debounce( + wait?: number, + options?: DebounceSettings + ): LoDashExplicitObjectWrapper; } //_.defer From e1fa07aaf86dbf299bf4999d613ea76a8fa63540 Mon Sep 17 00:00:00 2001 From: hadriandeoliveira Date: Fri, 11 Dec 2015 03:48:23 -0200 Subject: [PATCH 058/353] added LeState type definitions --- lestate/lestate-tests.ts | 20 ++++++++++++++++++++ lestate/lestate.d.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 lestate/lestate-tests.ts create mode 100644 lestate/lestate.d.ts diff --git a/lestate/lestate-tests.ts b/lestate/lestate-tests.ts new file mode 100644 index 000000000..9a007c68d --- /dev/null +++ b/lestate/lestate-tests.ts @@ -0,0 +1,20 @@ +/// + +let State = LeState.createState() + +State.set({ + test : {} +}) + +let currentState = State.get() + +State.insert({ + test : {} +}) + +let currentDescription = State.getDescription() + +State.createListener({ + id : 0, + selector : state => ({ test : state.test }) +}) diff --git a/lestate/lestate.d.ts b/lestate/lestate.d.ts new file mode 100644 index 000000000..d36a137eb --- /dev/null +++ b/lestate/lestate.d.ts @@ -0,0 +1,27 @@ +// Type definitions for LeState v0.1.3 +// Project: https://github.com/LeTools/LeState +// Definitions by: Hadrian Oliveira +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare let LeState : { + createState: (props?: { + initialState: {}; + }) => { + set(newValue: {}): [{ + id: number; + state: {}; + }]; + get(): any; + insert(newValue: {}): void; + getDescription(): {}; + createListener({ id, selector, force }: { + id: number; + selector: (state :any) => {}; + force?: boolean; + }): void; + }; +}; + +declare module "lestate" { + export default LeState; +} From 9abd523d14733b66e641eba4ac94951cf98a554d Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 11 Dec 2015 08:40:27 +0100 Subject: [PATCH 059/353] 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 000000000..5e4e42df2 --- /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 cd96dfe21..c00c0ce1a 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 060/353] 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 c00c0ce1a..921b25665 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 061/353] 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 5e4e42df2..1347b3bb7 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 f9d722838776698c634a9af179d10eb3a7858c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20Sojo?= Date: Fri, 11 Dec 2015 09:12:43 +0100 Subject: [PATCH 062/353] Fix position type, string to any, in jQueryui autocompleteOptions https://api.jqueryui.com/autocomplete/#option-position --- jqueryui/jqueryui.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 9dd576e1a..ade8eb735 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -49,7 +49,7 @@ declare module JQueryUI { delay?: number; disabled?: boolean; minLength?: number; - position?: string; + position?: any; // object source?: any; // [], string or () } From 482c331129ac50e6bc680700a3405baae517a06a Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 11 Dec 2015 11:45:17 +0100 Subject: [PATCH 063/353] 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 edb9aefb3..d586eee54 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 f7ba60bb1434c6d538a03bb5338fafa9ef2646c9 Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Fri, 11 Dec 2015 12:16:01 +0100 Subject: [PATCH 064/353] Update definition of ITemplateOptions --- angular-formly/angular-formly.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts index 2bf75af7d..d52df5e48 100644 --- a/angular-formly/angular-formly.d.ts +++ b/angular-formly/angular-formly.d.ts @@ -70,6 +70,11 @@ declare module AngularFormly { postWrapper?: ITemplateManipulator[]; } + interface ISelectOption { + name: string; + value: string; + group?: string; + } /** * see http://docs.angular-formly.com/docs/ngmodelattrstemplatemanipulator @@ -104,6 +109,12 @@ declare module AngularFormly { description?: string; [key: string]: any; + // types for select/radio fields + options?: ISelectOption | any; + groupProp?: string; // default: group + valueProp?: string; // default: value + labelProp?: string; // default: name + } From 0eaa2e33f76641182d1713c2f865c1417c68a37c Mon Sep 17 00:00:00 2001 From: Nick Zamosenchuk Date: Fri, 11 Dec 2015 14:13:49 +0100 Subject: [PATCH 065/353] [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 000000000..4a03d62ce --- /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 000000000..f1092df62 --- /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 066/353] 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 000000000..eeba3f080 --- /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 000000000..5f2ddd069 --- /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 067/353] 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 eeba3f080..40fceb8fb 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 5f2ddd069..d3f22afc1 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 fc18b2dfd426eaf96ce4ca0f003d23656b952da6 Mon Sep 17 00:00:00 2001 From: Stefan Geneshky Date: Fri, 11 Dec 2015 10:14:44 -0800 Subject: [PATCH 068/353] 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 3cd0e21e4..c2304e7ec 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 069/353] 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 6400dba7e..7415bdd73 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 070/353] 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 6d68111a6..27f50f89c 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 3ad5c4d09..95f02af63 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 071/353] 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 f6e0f96b4..e5a83b14a 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 6dc4f65d3..f695a6670 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 072/353] 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 000000000..ba7ff1f72 --- /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 000000000..b70fbb6b4 --- /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 073/353] 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 ba7ff1f72..f8b560607 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 b70fbb6b4..75faeff7a 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 074/353] 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 61a0e6e97..cb794ff30 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 075/353] 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 2d244b16e..9cf772cab 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 8425f1d82..81d78b1bc 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 076/353] 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 7334afc83..000000000 --- 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 2f31889c2..000000000 --- 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 077/353] 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 122c47587..000000000 --- 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 fe4d93041..000000000 --- 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 20db40a62..000000000 --- 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 4175d0862..000000000 --- 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 465861644..000000000 --- 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 6269a4b9d..000000000 --- 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 68b24ca27..000000000 --- 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 078/353] 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 222faec1d..f1ef8278c 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 079/353] 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 ce9fd7223..105e64c85 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 080/353] 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 23f5f8f17..8d9ce6cce 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 081/353] 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 8cac3a81c..107031cad 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 082/353] 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 d4ac5ad75..248ee29f2 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 083/353] 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 86355a310..f5308dd9e 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 d3f5a12fa..000000000 --- a/modernizr/modernizr-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modernizr/modernizr.d.ts b/modernizr/modernizr.d.ts index a9104fd22..fa976c217 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 084/353] 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 77d2898fd..febf50a62 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 085/353] 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 2d244b16e..8ccf58aa2 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 8425f1d82..dea870c2d 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 086/353] 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 d586eee54..fdcb409ca 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 087/353] 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 67580dae5..42faf0909 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 0da1ce2d6..e0278df26 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 d2afc4aa8..49fb30ae0 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 088/353] 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 7c5fa8b4d..12d53dcc6 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 1bd11135c8be706a519b46753f477e3e3c4029fa Mon Sep 17 00:00:00 2001 From: hinamiyagk Date: Mon, 14 Dec 2015 12:09:18 +0900 Subject: [PATCH 089/353] Add electron.hideInternalModules() --- github-electron/github-electron-main-tests.ts | 4 ++- github-electron/github-electron.d.ts | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index ef9c21e52..8a0d4125f 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -19,6 +19,8 @@ import { shell } from 'electron'; +require('electron').hideInternalModules(); + import path = require('path'); // Quick start @@ -201,7 +203,7 @@ ipcMain.on('online-status-changed', (event: any, status: any) => { app.on('ready', () => { window = new BrowserWindow({ width: 800, - height: 600, + height: 600, titleBarStyle: 'hidden-inset', }); window.loadURL('https://github.com'); diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 7c5fa8b4d..5dcaba2ff 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1312,7 +1312,7 @@ declare module GitHubElectron { */ read(format: string, type?: string): any; } - + interface CrashReporterStartOptions { /** * Default: Electron @@ -1343,7 +1343,7 @@ declare module GitHubElectron { */ extra?: {} } - + interface CrashReporterPayload extends Object { /** * E.g., "electron-crash-service". @@ -1383,17 +1383,17 @@ declare module GitHubElectron { */ upload_file_minidump: File; } - + interface CrashReporter { start(options?: CrashReporterStartOptions): void; - + /** * @returns The date and ID of the last crash report. When there was no crash report * sent or the crash reporter is not started, null will be returned. */ getLastCrashReport(): CrashReporterPayload; } - + interface Shell{ /** * Show the given file in a file manager. If possible, select the file. @@ -1469,7 +1469,7 @@ declare module GitHubElectron { */ process: any; } - + interface WebFrame { /** * Changes the zoom factor to the specified factor, zoom factor is @@ -1588,7 +1588,7 @@ declare module GitHubElectron { ENABLE_SAMPLING: number; RECORD_CONTINUOUSLY: number; } - + interface Dialog { /** * @param callback If supplied, the API call will be asynchronous. @@ -1608,7 +1608,7 @@ declare module GitHubElectron { * @returns The index of the clicked button. */ showMessageBox: typeof GitHubElectron.Dialog.showMessageBox; - + /** * Runs a modal dialog that shows an error message. This API can be called safely * before the ready event of app module emits, it is usually used to report errors @@ -1616,7 +1616,7 @@ declare module GitHubElectron { */ showErrorBox(title: string, content: string): void; } - + interface GlobalShortcut { /** * Registers a global shortcut of accelerator. @@ -1643,14 +1643,14 @@ declare module GitHubElectron { */ unregisterAll(): void; } - + class RequestFileJob { /** * Create a request job which would query a file of path and set corresponding mime types. */ constructor(path: string); } - + class RequestStringJob { /** * Create a request job which sends a string as response. @@ -1667,7 +1667,7 @@ declare module GitHubElectron { data?: string; }); } - + class RequestBufferJob { /** * Create a request job which accepts a buffer and sends a string as response. @@ -1684,7 +1684,7 @@ declare module GitHubElectron { data?: Buffer; }); } - + interface Protocol { registerProtocol(scheme: string, handler: (request: any) => void): void; unregisterProtocol(scheme: string): void; @@ -1718,6 +1718,7 @@ declare module GitHubElectron { powerMonitor: NodeJS.EventEmitter; protocol: GitHubElectron.Protocol; Tray: typeof GitHubElectron.Tray; + hideInternalModules(): any; } } From 20d5ad78bc140881d443476b4aa658d90c7ded4e Mon Sep 17 00:00:00 2001 From: Wang Zishi Date: Mon, 14 Dec 2015 12:14:05 +0800 Subject: [PATCH 090/353] Add definitions for cookies v0.5.8 for [cookies](https://github.com/pillarjs/cookies) v0.5.8 --- cookies/cookies-tests.ts | 42 +++++++++++++++++ cookies/cookies.d.ts | 98 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 cookies/cookies-tests.ts create mode 100644 cookies/cookies.d.ts diff --git a/cookies/cookies-tests.ts b/cookies/cookies-tests.ts new file mode 100644 index 000000000..3e3274a4d --- /dev/null +++ b/cookies/cookies-tests.ts @@ -0,0 +1,42 @@ +/// +/// + +import * as Cookies from 'cookies'; +import * as http from 'http'; + +const server = http.createServer((req, res) => { + const cookies = new Cookies(req, res); + let unsigned: string, + signed: string, + tampered: string + + if (req.url == "/set") { + cookies + // set a regular cookie + .set("unsigned", "foo", { httpOnly: false }) + + // set a signed cookie + .set("signed", "bar", { signed: true }) + + // mimic a signed cookie, but with a bogus signature + .set("tampered", "baz") + .set("tampered.sig", "bogus") + + res.writeHead(302, { "Location": "/" }) + return res.end("Now let's check.") + } + + unsigned = cookies.get("unsigned") + signed = cookies.get("signed", { signed: true }) + tampered = cookies.get("tampered", { signed: true }) + + res.writeHead(200, { "Content-Type": "text/plain" }) + res.end( + "unsigned expected: foo\n\n" + + "unsigned actual: " + unsigned + "\n\n" + + "signed expected: bar\n\n" + + "signed actual: " + signed + "\n\n" + + "tampered expected: undefined\n\n" + + "tampered: " + tampered + "\n\n" + ) +}) \ No newline at end of file diff --git a/cookies/cookies.d.ts b/cookies/cookies.d.ts new file mode 100644 index 000000000..24984f7fd --- /dev/null +++ b/cookies/cookies.d.ts @@ -0,0 +1,98 @@ +// Type definitions for cookie-parser v0.5.1 +// Project: https://github.com/pillarjs/cookies +// Definitions by: Wang Zishi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "cookies" { + import * as http from "http" + + interface ICookies { + /** + * This extracts the cookie with the given name from the + * Cookie header in the request. If such a cookie exists, + * its value is returned. Otherwise, nothing is returned. + */ + get(name: string): string; + /** + * This extracts the cookie with the given name from the + * Cookie header in the request. If such a cookie exists, + * its value is returned. Otherwise, nothing is returned. + */ + get(name: string, opts?: IOptions): string; + + /** + * This sets the given cookie in the response and returns + * the current context to allow chaining.If the value is omitted, + * an outbound header with an expired date is used to delete the cookie. + */ + set(name: string, value: string): ICookies; + /** + * This sets the given cookie in the response and returns + * the current context to allow chaining.If the value is omitted, + * an outbound header with an expired date is used to delete the cookie. + */ + set(name: string, value: string, opts?: IOptions): ICookies; + } + + interface IOptions { + /** + * a number representing the milliseconds from Date.now() for expiry + */ + maxAge?: number; + /** + * a Date object indicating the cookie's expiration + * date (expires at the end of session by default). + */ + expires?: Date; + /** + * a string indicating the path of the cookie (/ by default). + */ + path?: string; + /** + * a string indicating the domain of the cookie (no default). + */ + domain?: string; + /** + * a boolean indicating whether the cookie is only to be sent + * over HTTPS (false by default for HTTP, true by default for HTTPS). + */ + secure?: boolean; + /** + * a boolean indicating whether the cookie is only to be sent + * over HTTPS (use this if you handle SSL not in your node process). + */ + secureProxy?: boolean; + /** + * a boolean indicating whether the cookie is only to be sent over HTTP(S), + * and not made available to client JavaScript (true by default). + */ + httpOnly?: boolean; + /** + * a boolean indicating whether the cookie is to be signed (false by default). + * If this is true, another cookie of the same name with the .sig suffix + * appended will also be sent, with a 27-byte url-safe base64 SHA1 value + * representing the hash of cookie-name=cookie-value against the first Keygrip key. + * This signature key is used to detect tampering the next time a cookie is received. + */ + signed?: boolean; + /** + * a boolean indicating whether to overwrite previously set + * cookies of the same name (false by default). If this is true, + * all cookies set during the same request with the same + * name (regardless of path or domain) are filtered out of + * the Set-Cookie header when setting this cookie. + */ + overwrite?: boolean; + } + + interface CookiesStatic { + new (request: http.IncomingMessage, response: http.ServerResponse): ICookies; + new (request: http.IncomingMessage, response: http.ServerResponse, keys?: Array): ICookies; + } + + const _tmp: CookiesStatic; + + export = _tmp +} \ No newline at end of file From 05e67b229d29cc921dd8fd3c42991c897445f547 Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Sat, 12 Dec 2015 23:52:03 +0200 Subject: [PATCH 091/353] 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 000000000..655e92a87 --- /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 000000000..6434af26c --- /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 092/353] 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 3e0697c1d..ca3c5000e 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 d3e5e35f8..c523810ee 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 093/353] 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 000000000..2d734add0 --- /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 094/353] 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 2d244b16e..f493b4260 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 8425f1d82..350757ded 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 095/353] - 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 000000000..b43289d86 --- /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 000000000..ccd049530 --- /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 a77e03f09222a03e3ba25c485de29f6bdf2aebb6 Mon Sep 17 00:00:00 2001 From: Rafal Witczak Date: Tue, 1 Dec 2015 19:35:07 -0800 Subject: [PATCH 096/353] TSD definitions for cordova-plugin-mapsforge --- .../cordova-plugin-mapsforge-tests.ts | 73 +++++ .../cordova-plugin-mapsforge.d.ts | 249 ++++++++++++++++++ 2 files changed, 322 insertions(+) create mode 100644 cordova-plugin-mapsforge/cordova-plugin-mapsforge-tests.ts create mode 100644 cordova-plugin-mapsforge/cordova-plugin-mapsforge.d.ts diff --git a/cordova-plugin-mapsforge/cordova-plugin-mapsforge-tests.ts b/cordova-plugin-mapsforge/cordova-plugin-mapsforge-tests.ts new file mode 100644 index 000000000..52ef78700 --- /dev/null +++ b/cordova-plugin-mapsforge/cordova-plugin-mapsforge-tests.ts @@ -0,0 +1,73 @@ +/// + + +mapsforge.embedded.initialize(["/mnt/sdcard/spain.map",0,0]); //Creates the view +mapsforge.embedded.setCenter(43.360056,-5.845757); //Sets the center of the view +mapsforge.embedded.setMaxZoom(18); +mapsforge.embedded.setZoom(15); + +//Adding a marker +var markerKey: number; +mapsforge.embedded.addMarker([mapsforge.embedded.MARKER_YELLOW,43.360056,-5.845757],function(key){markerKey = key;}); + +//Adding a polyline +var points = [43.360056,-5.845757, 43.160056,-5.645757,43.560056,-5.895757]; +var polylineKey: number; +mapsforge.embedded.addPolyline([mapsforge.embedded.COLOR_GREEN,10,points], function(key){polylineKey = key;}, function(error){alert(error);}); + + + +mapsforge.cache.initialize("/mnt/sdcard/spain.map"); //Initializes the renderer with the offline map + +/*Now you can use the Leaflet code seen before*/ + +mapsforge.cache.setExternalCache(false); //Sets the cache to internal for faster performance + +//Now we set the cache size to 50 MB. This will increase the time between cleanings, but +//it will also make those cleanings slower, since there are a lot more of images to +//delete...so be careful when you choose the cache size +mapsforge.cache.setMaxCacheSize(50); + + + +var L: any; + +interface TilePoint { + x: number; + y: number; + z: number; +} + +interface Tile { + src: string; + _layer: any; + onload: any; + onerror: any; +} + +L.OfflineTileLayer = L.TileLayer.extend({ + getTileUrl : function(tilePoint: TilePoint, tile: Tile) { + var zoom = tilePoint.z, x = tilePoint.x, y = tilePoint.y; + + if (mapsforge.cache) { + mapsforge.cache.getTile([x,y,zoom], function(result) {tile.src=result;}, + function() {tile.src = "path to an error image";}); + }else{ + tile.src = "path to an error image"; + } + }, + + _loadTile: function (tile: Tile, tilePoint: TilePoint) { + tile._layer = this; + tile.onload = this._tileOnLoad; + tile.onerror = this._tileOnError; + + this._adjustTilePoint(tilePoint); + this.getTileUrl(tilePoint, tile); + + this.fire('tileloadstart', { + tile: tile, + url: tile.src + }); + } +}); diff --git a/cordova-plugin-mapsforge/cordova-plugin-mapsforge.d.ts b/cordova-plugin-mapsforge/cordova-plugin-mapsforge.d.ts new file mode 100644 index 000000000..6314a09fb --- /dev/null +++ b/cordova-plugin-mapsforge/cordova-plugin-mapsforge.d.ts @@ -0,0 +1,249 @@ +// Type definitions for cordova-plugin-mapsforge +// Project: https://github.com/afsuarez/mapsforge-cordova-plugin +// Definitions by: rafw87 +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Window { + mapsforge: MapsforgePlugin; +} + +declare var mapsforge: MapsforgePlugin; + +interface MapsforgePlugin { + embedded: MapsforgeEmbeddedPlugin; + cache: MapsforgeCachePlugin; +} + +interface MapsforgeEmbeddedPlugin { + + COLOR_DKGRAY: number|string; + COLOR_CYAN: number|string; + COLOR_BLACK: number|string; + COLOR_BLUE: number|string; + COLOR_GREEN: number|string; + COLOR_RED: number|string; + COLOR_WHITE: number|string; + COLOR_TRANSPARENT: number|string; + COLOR_YELLOW: number|string; + + MARKER_RED: number|string; + MARKER_GREEN: number|string; + MARKER_BLUE: number|string; + MARKER_YELLOW: number|string; + MARKER_BLACK: number|string; + MARKER_WHITE: number|string; + + /** + * The map file path provided must be the absolute file path. You can specify the width and height values for the view that will be added, + * or you can set them to 0 for set the value to MATCH_PARENT. You must call this method before any other method. + * @param args Array in the following form: [String mapFilePath, int viewWidth, int viewHeight]. + * @param success Success callback. + * @param error Error callback + */ + initialize(args: any[], success?: () => void, error?: (message: string) => void): void; + + /** + * To show the map view. + * @param success Success callback. + * @param error Error callback + */ + show(success?: () => void, error?: (message: string) => void): void; + + /** + * To hide the map view. + * @param success Success callback. + * @param error Error callback + */ + hide(success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the center of the map to the given coordinates. + * @param lat Latitude of the new center. + * @param lng Longitude of the new center. + * @param success Success callback. + * @param error Error callback + */ + setCenter(lat: number, lng: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the zoom to the specified value (if it is between the zoom limits). + * @param zoomLevel New zoom level. + * @param success Success callback. + * @param error Error callback + */ + setZoom(zoomLevel: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the maximum zoom level. + * @param maxZoom New maximum zoom level. + * @param success Success callback. + * @param error Error callback + */ + setMaxZoom(maxZoom: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the minimum zoom level. + * @param minZoom New minimum zoom level. + * @param success Success callback. + * @param error Error callback + */ + setMinZoom(minZoom: number, success?: () => void, error?: (message: string) => void): void; + + /** + * The path to the map ile is required, and the path to the render theme may be null in order to apply the default render theme. + * @param args Array in the following form: [String mapFilePath, String renderThemePath] + * @param success Success callback. + * @param error Error callback + */ + setOfflineTileLayer(args: any[], success?: () => void, error?: (message: string) => void): void; + + /** + * + * @param args Array in the following form: [String providerName, String host, String baseUrl, String extension, int port] + * @param success Success callback. + * @param error Error callback + */ + setOnlineTileLayer(args: any[], success?: () => void, error?: (message: string) => void): void; + + /** + * Adds a marker to the map in the specified coordinates and returns the key for that marker to the success function. + * @param arg Array in the following form: [String marker_color, double lat, double lng]. + * The color of the marker should be one of the constants from mapsforge.embedded object; if the marker doesn't exist a green marker will be used instead. + * @param success Success callback. Gets the key of created marker. That key is the one you have to use if you want to delete it. + * @param error Error callback + */ + addMarker(arg: any[], success?: (key: number) => void, error?: (message: string) => void): void; + + /** + * + * @param arg Array in the following form: [int color, int strokeWidth,[double points]]. + * The color can be one of the constants specified before, or the new color you want. + * This function will use the odd positions of the array of points for the latitudes and the even positions for the longitudes. + * Example: [lat1, lng1, lat2, lng2, lat3, lng3]. + * If the length of the array is not even, the function will throw an exception and return the error message to the error function. + * @param success Success callback. Gets the key of created polyline. + * @param error Error callback + */ + addPolyline(arg: any[], success?: (key: number) => void, error?: (message: string) => void): void; + + /** + * Deletes the layer(markers or polylines) with the specified key from the map. + * @param key Key of marker or polyline. + * @param success Success callback. + * @param error Error callback + */ + deleteLayer(key: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Initializes again the map if the onStop method was called. + * @param success Success callback. + * @param error Error callback + */ + onStart(success?: () => void, error?: (message: string) => void): void; + + + /** + * Stops the rendering. Useful for when the app goes to the background. You have to call the onStart method to restart it. + * @param success Success callback. + * @param error Error callback + */ + onStop(success?: () => void, error?: (message: string) => void): void; + + /** + * Stops and cleans the resources that have been used. + * @param success Success callback. + * @param error Error callback + */ + onDestroy(success?: () => void, error?: (message: string) => void): void; +} + +interface MapsforgeCachePlugin { + + /** + * You should call this method before any other one, and provide it with the absolute map file path. + * @param mapFilePath Absolute map file path. + * @param success Success callback. + * @param error Error callback + */ + initialize(mapFilePath: string, success?: () => void, error?: (message: string) => void): void; + + /** + * This method is the one that provides the tiles, generating them if their are not in the cache. + * @param args Array in the following form: [double lat, double lng, byte zoom] + * @param success Success callback. Gets the tile path. + * @param error Error callback + */ + getTile(args: any[], success?: (tilePath: string) => void, error?: (message: string) => void): void; + + /** + * Enables or disables the cache. If disabled, the plugin will generate the tiles always from scratch. Cache is enabled by default. + * @param enabled Cache enabled or disabled. + * @param success Success callback. + * @param error Error callback + */ + setCacheEnabled(enabled: boolean, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets whether or not the cache should be placed in the internal memory or in the SD card. + * By default it is placed in SD card, so devices with not too much memory have a better performance. + * @param external Cache external or internal. + * @param success Success callback. + * @param error Error callback + */ + setExternalCache(external: boolean, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the map file to be used for rendering to the map specified by its absolute path. + * @param absolutePath Absolute map file path. + * @param success Success callback. + * @param error Error callback + */ + setMapFile(absolutePath: string, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the age for the generated images. This means that when the cache is being cleaned, all images younger than the specified value will be kept in the cache in order to avoid deleting images that are being used at the moment. + * @param milliseconds Max cache age in milliseconds. + * @param success Success callback. + * @param error Error callback + */ + setMaxCacheAge(milliseconds: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the maximum size for the cache. This size must be specified in megabytes. If there is not that space available, the cache will fit the maximum size. + * @param sizeInMB Max cache size in megabytes. + * @param success Success callback. + * @param error Error callback + */ + setMaxCacheSize(sizeInMB: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the tile size. By default the tile size is set to 256. + * @param size Tile size. + * @param success Success callback. + * @param error Error callback + */ + setMaxCacheSize(size: number, success?: () => void, error?: (message: string) => void): void; + + /** + * This method sets the size in megabytes that will remain always available in memory in order to avoid that the application uses all space available. + * @param sizeInMB Size in megabytes that will remain always available in memory. + * @param success Success callback. + * @param error Error callback + */ + setCacheCleaningTrigger(sizeInMB: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets a flag to destroy the cache when the onDestroy method is called. + * @param destroy If true, cache will be destroyed when the onDestroy method will be called. + * @param success Success callback. + * @param error Error callback + */ + destroyCacheOnExit(destroy: boolean, success?: () => void, error?: (message: string) => void): void; + + /** + * Deletes the cache depending on the flag state. + * @param success Success callback. + * @param error Error callback + */ + onDestroy(success?: () => void, error?: (message: string) => void): void; +} From d220aeca45e917dd5237fabd997cbeb13bbce849 Mon Sep 17 00:00:00 2001 From: Kaur Kuut Date: Sat, 12 Dec 2015 17:06:39 +0200 Subject: [PATCH 097/353] Added definitions for scrypt-async v1.2.0. --- scrypt-async/scrypt-async-tests.ts | 25 +++++++++++++++++++ scrypt-async/scrypt-async.d.ts | 39 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 scrypt-async/scrypt-async-tests.ts create mode 100644 scrypt-async/scrypt-async.d.ts diff --git a/scrypt-async/scrypt-async-tests.ts b/scrypt-async/scrypt-async-tests.ts new file mode 100644 index 000000000..745d3ae62 --- /dev/null +++ b/scrypt-async/scrypt-async-tests.ts @@ -0,0 +1,25 @@ +// Tests by: Kaur Kuut + +/// + +var callback = function(key: string | number[]) { }; + +scrypt("abc", "def", 10, 8, 32, 1000, callback, "base64"); +scrypt("abc", [4,5,6], 10, 8, 32, 1000, callback, "base64"); +scrypt([1,2,3], "def", 10, 8, 32, 1000, callback, "base64"); +scrypt([1,2,3], [4,5,6], 10, 8, 32, 1000, callback, "base64"); + +scrypt("abc", "def", 10, 8, 32, 1000, callback); +scrypt("abc", [4,5,6], 10, 8, 32, 1000, callback); +scrypt([1,2,3], "def", 10, 8, 32, 1000, callback); +scrypt([1,2,3], [4,5,6], 10, 8, 32, 1000, callback); + +scrypt("abc", "def", 10, 8, 32, callback, "base64"); +scrypt("abc", [4,5,6], 10, 8, 32, callback, "base64"); +scrypt([1,2,3], "def", 10, 8, 32, callback, "base64"); +scrypt([1,2,3], [4,5,6], 10, 8, 32, callback, "base64"); + +scrypt("abc", "def", 10, 8, 32, callback); +scrypt("abc", [4,5,6], 10, 8, 32, callback); +scrypt([1,2,3], "def", 10, 8, 32, callback); +scrypt([1,2,3], [4,5,6], 10, 8, 32, callback); \ No newline at end of file diff --git a/scrypt-async/scrypt-async.d.ts b/scrypt-async/scrypt-async.d.ts new file mode 100644 index 000000000..618d49e8a --- /dev/null +++ b/scrypt-async/scrypt-async.d.ts @@ -0,0 +1,39 @@ +// Type definitions for scrypt-async v1.2.0 +// Project: https://github.com/dchest/scrypt-async-js +// Definitions by: Kaur Kuut +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module ScryptAsync { + interface CallbackFunc { + (key: string): any; + (key: number[]): any; + } + + interface ScryptStatic { + (password: string, salt: string, logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc, encoding: string): void; + (password: string, salt: number[], logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc, encoding: string): void; + (password: number[], salt: string, logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc, encoding: string): void; + (password: number[], salt: number[], logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc, encoding: string): void; + + (password: string, salt: string, logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc): void; + (password: string, salt: number[], logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc): void; + (password: number[], salt: string, logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc): void; + (password: number[], salt: number[], logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc): void; + + (password: string, salt: string, logN: number, r: number, dkLen: number, callback: CallbackFunc, encoding: string): void; + (password: string, salt: number[], logN: number, r: number, dkLen: number, callback: CallbackFunc, encoding: string): void; + (password: number[], salt: string, logN: number, r: number, dkLen: number, callback: CallbackFunc, encoding: string): void; + (password: number[], salt: number[], logN: number, r: number, dkLen: number, callback: CallbackFunc, encoding: string): void; + + (password: string, salt: string, logN: number, r: number, dkLen: number, callback: CallbackFunc): void; + (password: string, salt: number[], logN: number, r: number, dkLen: number, callback: CallbackFunc): void; + (password: number[], salt: string, logN: number, r: number, dkLen: number, callback: CallbackFunc): void; + (password: number[], salt: number[], logN: number, r: number, dkLen: number, callback: CallbackFunc): void; + } +} + +declare var scrypt: ScryptAsync.ScryptStatic; + +declare module "scrypt-async" { + export = scrypt; +} \ No newline at end of file From 8adab1a506255d3c821401e1afcf2708156831dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn?= Date: Mon, 14 Dec 2015 22:59:12 +0100 Subject: [PATCH 098/353] Added definitions for protractor-http-mock. --- .../protractor-http-mock-tests.ts | 211 ++++++++++++++++++ .../protractor-http-mock.d.ts | 202 +++++++++++++++++ 2 files changed, 413 insertions(+) create mode 100644 protractor-http-mock/protractor-http-mock-tests.ts create mode 100644 protractor-http-mock/protractor-http-mock.d.ts diff --git a/protractor-http-mock/protractor-http-mock-tests.ts b/protractor-http-mock/protractor-http-mock-tests.ts new file mode 100644 index 000000000..9fdf0695a --- /dev/null +++ b/protractor-http-mock/protractor-http-mock-tests.ts @@ -0,0 +1,211 @@ +/// + +function TestConfig() { + mock.config = { + rootDirectory: 'root', + protractorConfig: 'protractor.conf.js' + }; +} + +function TestCtorOverloads() { + let noParam: mock.ProtractorHttpMock = mock(); + let emptyArray: mock.ProtractorHttpMock = mock([]); + let skipDefaults: mock.ProtractorHttpMock = mock([], true); + + let del: mock.requests.Delete = { + request: { + path: 'path', + method: 'DELETE' + }, + response: { + status: 400, + data: 1 + } + }; + let put: mock.requests.Put = { + request: { + path: 'path', + method: 'PUT' + }, + response: { + status: 400, + data: 1 + } + }; + let mocks: mock.ProtractorHttpMock = mock([del, put]); +} + +function TestTeardown() { + mock.teardown(); +} + +function TestRequestsMade() { + let values: Array; + mock.requestsMade().then(v => values = v); +} + +function TestClearRequests() { + let promiseValue: boolean; + mock.clearRequests().then(value => { + promiseValue = value; + }); +} + +function TestGetRequestDefinitions() { + let getMinium: mock.requests.Get = { + request: { + path: 'path', + method: 'GET' + }, + response: { + data: 1, + status: 500 + } + }; + + let getParams: mock.requests.Get = { + request: { + path: 'path', + method: 'GET', + params: { + param1: 'param1', + param2: 2 + } + }, + response: { + data: 1, + status: 500 + } + }; + + let post: mock.requests.Post = { + request: { + path: 'path', + method: 'POST' + }, + response: { + data: 1, + status: 500 + } + }; + + let getQueryString: mock.requests.Get = { + request: { + path: 'path', + method: 'GET', + queryString: { + query1: 'query1', + query2: 2 + } + }, + response: { + data: 1, + status: 500 + } + }; + + let getHeaders: mock.requests.Get = { + request: { + path: 'path', + method: 'GET', + headers: { + head1: 'head1', + head2: 'head2' + } + }, + response: { + data: 1, + status: 500 + } + }; +} + +function TestPostRequestDefinitions() { + let post: mock.requests.Post = { + request: { + path: 'path', + method: 'POST' + }, + response: { + data: 1, + status: 500 + } + }; + + let postData: mock.requests.PostData = { + request: { + path: 'path', + method: 'POST', + data: 'data' + }, + response: { + data: 1, + status: 500 + } + }; +} + +function TestHeadRequestDefinitions() { + let head: mock.requests.Head = { + request: { + path: 'path', + method: 'HEAD' + }, + response: { + status: 500, + data: 1 + } + }; +} + +function TestDeleteRequestDefinitions() { + let del: mock.requests.Delete = { + request: { + path: 'path', + method: 'DELETE' + }, + response: { + status: 500, + data: 1 + } + }; +} + +function TestPutRequestDefinitions() { + let put: mock.requests.Put = { + request: { + path: 'path', + method: 'PUT' + }, + response: { + status: 500, + data: 1 + } + }; +} + +function TestPatchRequestDefinitions() { + let patch: mock.requests.Patch = { + request: { + path: 'path', + method: 'PATCH' + }, + response: { + status: 500, + data: 1 + } + }; +} + +function TestJsonpRequestDefinitions() { + let jsonp: mock.requests.Jsonp = { + request: { + path: 'path', + method: 'JSONP' + }, + response: { + status: 500, + data: 1 + } + }; +} diff --git a/protractor-http-mock/protractor-http-mock.d.ts b/protractor-http-mock/protractor-http-mock.d.ts new file mode 100644 index 000000000..446c7b3e9 --- /dev/null +++ b/protractor-http-mock/protractor-http-mock.d.ts @@ -0,0 +1,202 @@ +// Type definitions for protractor-http-mock +// Project: https://github.com/atecarlos/protractor-http-mock +// Definitions by: Crevil +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module mock { + interface ProtractorHttpMock { + /** + * Instantiate mock module. This must be done before the browser connects. + * + * @param mocks An array of mock modules to load into the application. + * @param skipDefaults Set true to skip loading of default mocks. + */ + (mocks?: Array>, skipDefaults?: boolean): ProtractorHttpMock; + + /** + * Clean up. + * Typically done in the afterEach call to ensure the teardown + * is executed regardless of what happens in the test execution. + */ + teardown(): void; + + /** + * Returns a promise that will be resolved with an array of + * all matched HTTP requests. + */ + requestsMade(): webdriver.promise.Promise>; + + /** + * Returns a promise that will be resolved with a true boolean + * when all matched HTTP requests are cleared. + */ + clearRequests(): webdriver.promise.Promise; + + /** + * Module configuration to setup + */ + config: { + /** + * Mocks directory where mock files are located. + * Default: process.cwd() + */ + rootDirectory?: string; + + /** + * Path to protractor configuration file. + * Default: protractor.conf + */ + protractorConfig?: string; + }; + } + + /** + * Matched request. + */ + interface ReceivedRequest { + url: string; + method: string; + } + + module requests { + /** + * Base request mock used for all mocks. + */ + interface BaseRequest { + request: { + method: string; + path: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * GET request mock. + */ + interface Get extends BaseRequest { + request: { + method: string; + path: string; + params?: Object; + queryString?: Object; + headers?: Object; + interceptedRequest?: boolean; + interceptedAnonymousRequest?: boolean; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * POST request mock with payload. + */ + interface PostData extends BaseRequest { + request: { + path: string; + method: string; + data: TPayload; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * POST request mock. + */ + interface Post extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * HEAD request mock. + */ + interface Head extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * HTTP Delete request mock. + */ + interface Delete extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * PUT request mock. + */ + interface Put extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * PATCH request mock. + */ + interface Patch extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * JSONP request mock. + */ + interface Jsonp extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + } +} + +declare var mock: mock.ProtractorHttpMock; + +declare module 'protractor-http-mock' { + export = mock; +} From c4329e1413cd2dfc53c573d4fd08abaf78b547e7 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Mon, 14 Dec 2015 17:02:46 -0800 Subject: [PATCH 099/353] Replaced deprecated properties with new versions. --- threejs/three-orbitcontrols.d.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/threejs/three-orbitcontrols.d.ts b/threejs/three-orbitcontrols.d.ts index 69cde47a7..b904ab321 100644 --- a/threejs/three-orbitcontrols.d.ts +++ b/threejs/three-orbitcontrols.d.ts @@ -7,10 +7,10 @@ declare module THREE { class OrbitControls { - constructor(object:Camera, domElement?:HTMLElement); + constructor(object: Camera, domElement?: HTMLElement); - object:Camera; - domElement:HTMLElement; + object: Camera; + domElement: HTMLElement; // API enabled: boolean; @@ -19,13 +19,13 @@ declare module THREE { // deprecated center: THREE.Vector3; - noZoom: boolean; + enableZoom: boolean; zoomSpeed: number; minDistance: number; maxDistance: number; - noRotate: boolean; + enableRotate: boolean; rotateSpeed: number; - noPan: boolean; + enablePan: boolean; keyPanSpeed: number; autoRotate: boolean; autoRotateSpeed: number; @@ -33,24 +33,27 @@ declare module THREE { maxPolarAngle: number; minAzimuthAngle: number; maxAzimuthAngle: number; - noKeys: boolean; + enableKeys: boolean; keys: { LEFT: number; UP: number; RIGHT: number; BOTTOM: number; }; mouseButtons: { ORBIT: MOUSE; ZOOM: MOUSE; PAN: MOUSE; }; + enableDamping: boolean; + dampingFactor: number; + rotateLeft(angle?: number): void; rotateUp(angle?: number): void; panLeft(distance?: number): void; panUp(distance?: number): void; - pan( deltaX: number, deltaY: number): void; + pan(deltaX: number, deltaY: number): void; dollyIn(dollyScale: number): void; dollyOut(dollyScale: number): void; update(): void; reset(): void; - getPolarAngle() : number; + getPolarAngle(): number; getAzimuthalAngle(): number; // EventDispatcher mixins - addEventListener(type: string, listener: (event: any) => void ): void; + addEventListener(type: string, listener: (event: any) => void): void; hasEventListener(type: string, listener: (event: any) => void): void; removeEventListener(type: string, listener: (event: any) => void): void; dispatchEvent(event: { type: string; target: any; }): void; From d275c4c26ae677c4653067fd6901eceefbd835cd Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Mon, 14 Dec 2015 17:11:32 -0800 Subject: [PATCH 100/353] Several fixes, and allow CSS-style string where a hex number is allowed. --- threejs/three.d.ts | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index fb890afe6..b4231f566 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -1227,7 +1227,7 @@ declare module THREE { */ computeBoundingSphere(): void; - merge( geometry: Geometry, matrix: Matrix, materialIndexOffset: number): void; + merge( geometry: Geometry, matrix: Matrix, materialIndexOffset?: number): void; mergeMesh( mesh: Mesh ): void; @@ -1677,7 +1677,7 @@ declare module THREE { * Abstract base class for lights. */ export class Light extends Object3D { - constructor(hex?: number); + constructor(hex?: number|string); color: Color; receiveShadow: boolean; @@ -1727,7 +1727,7 @@ declare module THREE { * This creates a Ambientlight with a color. * @param hex Numeric value of the RGB component of the color. */ - constructor(hex?: number); + constructor(hex?: number|string); clone(recursive?: boolean): AmbientLight; copy(source: AmbientLight): AmbientLight; @@ -1746,7 +1746,7 @@ declare module THREE { */ export class DirectionalLight extends Light { - constructor(hex?: number, intensity?: number); + constructor(hex?: number|string, intensity?: number); /** * Target used for shadow camera orientation. @@ -1766,7 +1766,7 @@ declare module THREE { } export class HemisphereLight extends Light { - constructor(skyColorHex?: number, groundColorHex?: number, intensity?: number); + constructor(skyColorHex?: number|string, groundColorHex?: number|string, intensity?: number); groundColor: Color; intensity: number; @@ -1784,7 +1784,7 @@ declare module THREE { * scene.add( light ); */ export class PointLight extends Light { - constructor(hex?: number, intensity?: number, distance?: number, decay?: number); + constructor(hex?: number|string, intensity?: number, distance?: number, decay?: number); /* * Light's intensity. @@ -1810,7 +1810,7 @@ declare module THREE { * A point light that can cast shadow in one direction. */ export class SpotLight extends Light { - constructor(hex?: number, intensity?: number, distance?: number, angle?: number, exponent?: number, decay?: number); + constructor(hex?: number|string, intensity?: number, distance?: number, angle?: number, exponent?: number, decay?: number); /** * Spotlight focus points at target.position. @@ -2244,7 +2244,7 @@ declare module THREE { } export interface LineBasicMaterialParameters extends MaterialParameters { - color?: number; + color?: number|string; linewidth?: number; linecap?: string; linejoin?: string; @@ -2267,7 +2267,7 @@ declare module THREE { } export interface LineDashedMaterialParameters extends MaterialParameters { - color?: number; + color?: number|string; linewidth?: number; scale?: number; dashSize?: number; @@ -2295,7 +2295,7 @@ declare module THREE { * parameters is an object with one or more properties defining the material's appearance. */ export interface MeshBasicMaterialParameters extends MaterialParameters{ - color?: number; + color?: number|string; opacity?: number; map?: Texture; aoMap?: Texture; @@ -2361,7 +2361,7 @@ declare module THREE { } export interface MeshLambertMaterialParameters extends MaterialParameters{ - color?: number; + color?: number|string; emissive?: number; opacity?: number; map?: Texture; @@ -2433,7 +2433,7 @@ declare module THREE { export interface MeshPhongMaterialParameters extends MaterialParameters { /** geometry color in hexadecimal. Default is 0xffffff. */ - color?: number; + color?: number | string; emissive?: number; specular?: number; shininess?: number; @@ -2461,7 +2461,7 @@ declare module THREE { blending?: Blending; depthTest?: boolean; depthWrite?: boolean; - wireframe?: string; + wireframe?: boolean; wireframeLinewidth?: number; vertexColors?: Colors; skinning?: boolean; @@ -2528,7 +2528,7 @@ declare module THREE { } export interface PointsMaterialParameters extends MaterialParameters{ - color?: number; + color?: number|string; opacity?: number; map?: Texture; size?: number; @@ -2604,7 +2604,7 @@ declare module THREE { } export interface SpriteMaterialParameters extends MaterialParameters { - color?: number; + color?: number|string; opacity?: number; map?: Texture; blending?: Blending; @@ -4470,6 +4470,11 @@ declare module THREE { clearAlpha?: number; devicePixelRatio?: number; + + /** + * default is false. + */ + logarithmicDepthBuffer?: boolean; } @@ -5106,7 +5111,7 @@ declare module THREE { * This class contains the parameters that define linear fog, i.e., that grows exponentially denser with the distance. */ export class FogExp2 implements IFog { - constructor(hex: number, density?: number); + constructor(hex: number|string, density?: number); name: string; color: Color; From 8cbbfe0bc8731b2611322fc57b06f60106bf39d9 Mon Sep 17 00:00:00 2001 From: Wang Zishi Date: Tue, 15 Dec 2015 09:24:48 +0800 Subject: [PATCH 101/353] update definitions --- cookies/cookies.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookies/cookies.d.ts b/cookies/cookies.d.ts index 24984f7fd..53de9fe09 100644 --- a/cookies/cookies.d.ts +++ b/cookies/cookies.d.ts @@ -20,7 +20,7 @@ declare module "cookies" { * Cookie header in the request. If such a cookie exists, * its value is returned. Otherwise, nothing is returned. */ - get(name: string, opts?: IOptions): string; + get(name: string, opts: IOptions): string; /** * This sets the given cookie in the response and returns @@ -33,7 +33,7 @@ declare module "cookies" { * the current context to allow chaining.If the value is omitted, * an outbound header with an expired date is used to delete the cookie. */ - set(name: string, value: string, opts?: IOptions): ICookies; + set(name: string, value: string, opts: IOptions): ICookies; } interface IOptions { From 2a90bb4dd66299e1b4d1e1512cedf8932689260a Mon Sep 17 00:00:00 2001 From: ravishivt Date: Mon, 14 Dec 2015 17:42:49 -0800 Subject: [PATCH 102/353] Added definitions for protractor.ExpectedConditions Added definitions and tests for ExpectedConditions documented at https://angular.github.io/protractor/#/api?view=ExpectedConditions. --- .../angular-protractor-tests.ts | 21 +++ angular-protractor/angular-protractor.d.ts | 139 ++++++++++++++++++ 2 files changed, 160 insertions(+) diff --git a/angular-protractor/angular-protractor-tests.ts b/angular-protractor/angular-protractor-tests.ts index 45a5d7edc..0f98aead1 100644 --- a/angular-protractor/angular-protractor-tests.ts +++ b/angular-protractor/angular-protractor-tests.ts @@ -196,6 +196,27 @@ function TestWebDriverUntilModule() { conditionWebElements = protractor.until.elementsLocated(by.className('class')); } +function TestWebDriverExpectedConditionsModule() { + var conditionB: protractor.until.Condition; + var el: protractor.ElementFinder = element(by.id('id')); + + conditionB = protractor.ExpectedConditions.alertIsPresent(); + conditionB = protractor.ExpectedConditions.elementToBeClickable(el); + conditionB = protractor.ExpectedConditions.textToBePresentInElement(el, 'text'); + conditionB = protractor.ExpectedConditions.textToBePresentInElementValue(el, 'text'); + conditionB = protractor.ExpectedConditions.titleContains('text'); + conditionB = protractor.ExpectedConditions.titleIs('text'); + conditionB = protractor.ExpectedConditions.presenceOf(el); + conditionB = protractor.ExpectedConditions.stalenessOf(el); + conditionB = protractor.ExpectedConditions.visibilityOf(el); + conditionB = protractor.ExpectedConditions.invisibilityOf(el); + conditionB = protractor.ExpectedConditions.elementToBeSelected(el); + + conditionB = protractor.ExpectedConditions.not(protractor.ExpectedConditions.alertIsPresent()); + conditionB = protractor.ExpectedConditions.and(protractor.ExpectedConditions.alertIsPresent(), protractor.ExpectedConditions.elementToBeClickable(el)); + conditionB = protractor.ExpectedConditions.or(protractor.ExpectedConditions.alertIsPresent(), protractor.ExpectedConditions.elementToBeClickable(el)); +} + function TestProtractor() { var ptor: protractor.Protractor; var driver: webdriver.WebDriver = new webdriver.Builder(). diff --git a/angular-protractor/angular-protractor.d.ts b/angular-protractor/angular-protractor.d.ts index ff8324238..dc969927e 100644 --- a/angular-protractor/angular-protractor.d.ts +++ b/angular-protractor/angular-protractor.d.ts @@ -501,6 +501,145 @@ declare module protractor { function titleMatches(regex: RegExp): webdriver.until.Condition; } + module ExpectedConditions { + /** + * Negates the result of a promise. + * + * @param {webdriver.until.Condition} expectedCondition + * @return {!webdriver.until.Condition} An expected condition that returns the negated value. + */ + function not(expectedCondition: webdriver.until.Condition): webdriver.until.Condition; + + /** + * Chain a number of expected conditions using logical_and, short circuiting at the + * first expected condition that evaluates to false. + * + * @param {...webdriver.until.Condition[]} fns An array of expected conditions to 'and' together. + * @return {!webdriver.until.Condition} An expected condition that returns a promise which evaluates + * to the result of the logical and. + */ + function and(...fns: webdriver.until.Condition[]): webdriver.until.Condition; + + /** + * Chain a number of expected conditions using logical_or, short circuiting at the + * first expected condition that evaluates to true. + * + * @param {...webdriver.until.Condition[]} fns An array of expected conditions to 'or' together. + * @return {!webdriver.until.Condition} An expected condition that returns a promise which + * evaluates to the result of the logical or. + */ + function or(...fns: webdriver.until.Condition[]): webdriver.until.Condition; + + /** + * Expect an alert to be present. + * + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether an alert is present. + */ + function alertIsPresent(): webdriver.until.Condition; + + /** + * An Expectation for checking an element is visible and enabled such that you can click it. + * + * @param {ElementFinder} element The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the element is clickable. + */ + function elementToBeClickable(element: ElementFinder): webdriver.until.Condition; + + /** + * An expectation for checking if the given text is present in the element. + * Returns false if the elementFinder does not find an element. + * + * @param {ElementFinder} element The element to check + * @param {string} text The text to verify against + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the text is present in the element. + */ + function textToBePresentInElement(element: ElementFinder, text: string): webdriver.until.Condition; + + /** + * An expectation for checking if the given text is present in the element’s value. + * Returns false if the elementFinder does not find an element. + * + * @param {ElementFinder} element The element to check + * @param {string} text The text to verify against + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the text is present in the element's value. + */ + function textToBePresentInElementValue( + element: ElementFinder, text: string + ): webdriver.until.Condition; + + /** + * An expectation for checking that the title contains a case-sensitive substring. + * + * @param {string} title The fragment of title expected + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the title contains the string. + */ + function titleContains(title: string): webdriver.until.Condition; + + /** + * An expectation for checking the title of a page. + * + * @param {string} title The expected title, which must be an exact match. + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the title equals the string. + */ + function titleIs(title: string): webdriver.until.Condition; + + /** + * An expectation for checking that an element is present on the DOM of a page. This does not necessarily + * mean that the element is visible. This is the opposite of 'stalenessOf'. + * + * @param {ElementFinder} elementFinder The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise + * representing whether the element is present. + */ + function presenceOf(element: ElementFinder): webdriver.until.Condition; + + /** + * An expectation for checking that an element is not attached to the DOM of a page. + * This is the opposite of 'presenceOf'. + * + * @param {ElementFinder} elementFinder The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the element is stale. + */ + function stalenessOf(element: ElementFinder): webdriver.until.Condition; + + /** + * An expectation for checking that an element is present on the DOM of a page and visible. + * Visibility means that the element is not only displayed but also has a height and width that is + * greater than 0. This is the opposite of 'invisibilityOf'. + * + * @param {ElementFinder} elementFinder The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the element is visible. + */ + function visibilityOf(element: ElementFinder): webdriver.until.Condition; + + /** + * An expectation for checking that an element is present on the DOM of a page. This does not necessarily + * mean that the element is visible. This is the opposite of 'stalenessOf'. + * + * @param {ElementFinder} elementFinder The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the element is invisible. + */ + function invisibilityOf(element: ElementFinder): webdriver.until.Condition; + + /** + * An expectation for checking the selection is selected. + * + * @param {ElementFinder} elementFinder The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the element is selected. + */ + function elementToBeSelected(element: ElementFinder): webdriver.until.Condition; + } + //endregion /** From cf172aab99c3139a718aa8e65398a22c53dd7ead Mon Sep 17 00:00:00 2001 From: Sagar Vadodaria Date: Tue, 15 Dec 2015 14:39:20 +0530 Subject: [PATCH 103/353] added missing property As per AngularJs Documentation, (https://docs.angularjs.org/api/ngRoute/provider/$routeProvider) , $routeProvider has a property as well. caseInsensitiveMatch , which can be used to turn off the case sensitive match globally. --- angularjs/angular-route.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/angularjs/angular-route.d.ts b/angularjs/angular-route.d.ts index 5f426d51c..eafdf714c 100644 --- a/angularjs/angular-route.d.ts +++ b/angularjs/angular-route.d.ts @@ -128,6 +128,12 @@ declare module angular.route { } interface IRouteProvider extends IServiceProvider { + /** + * Match routes without being case sensitive + * + * This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive + */ + caseInsensitiveMatch?: boolean; /** * Sets route definition that will be used on route change when no other route definition is matched. * From 911b32f0cee09a9f34a7aeb778fae9dba90d9241 Mon Sep 17 00:00:00 2001 From: BSO Date: Tue, 15 Dec 2015 10:14:58 +0100 Subject: [PATCH 104/353] Added constructor using mock files. --- .../protractor-http-mock-tests.ts | 3 ++- protractor-http-mock/protractor-http-mock.d.ts | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/protractor-http-mock/protractor-http-mock-tests.ts b/protractor-http-mock/protractor-http-mock-tests.ts index 9fdf0695a..6c39f1401 100644 --- a/protractor-http-mock/protractor-http-mock-tests.ts +++ b/protractor-http-mock/protractor-http-mock-tests.ts @@ -9,7 +9,8 @@ function TestConfig() { function TestCtorOverloads() { let noParam: mock.ProtractorHttpMock = mock(); - let emptyArray: mock.ProtractorHttpMock = mock([]); + let emptyArray: mock.ProtractorHttpMock = mock([]); + let mockFiles: mock.ProtractorHttpMock = mock(['mock1', 'mock2']); let skipDefaults: mock.ProtractorHttpMock = mock([], true); let del: mock.requests.Delete = { diff --git a/protractor-http-mock/protractor-http-mock.d.ts b/protractor-http-mock/protractor-http-mock.d.ts index 446c7b3e9..41c4ef41f 100644 --- a/protractor-http-mock/protractor-http-mock.d.ts +++ b/protractor-http-mock/protractor-http-mock.d.ts @@ -9,15 +9,22 @@ declare module mock { interface ProtractorHttpMock { /** * Instantiate mock module. This must be done before the browser connects. - * + * * @param mocks An array of mock modules to load into the application. * @param skipDefaults Set true to skip loading of default mocks. */ (mocks?: Array>, skipDefaults?: boolean): ProtractorHttpMock; + /** + * Instantiate mock modules from files. This must be done before the browser connects. + * + * @param mocks An array of mock module names relative to the rootDirectory configuration. + */ + (mocks: Array): ProtractorHttpMock; + /** * Clean up. - * Typically done in the afterEach call to ensure the teardown + * Typically done in the afterEach call to ensure the teardown * is executed regardless of what happens in the test execution. */ teardown(): void; @@ -35,7 +42,7 @@ declare module mock { clearRequests(): webdriver.promise.Promise; /** - * Module configuration to setup + * Module configuration to setup */ config: { /** @@ -51,7 +58,7 @@ declare module mock { protractorConfig?: string; }; } - + /** * Matched request. */ From dabf57f42e7854c15f239ef0b2e81166c0f0e553 Mon Sep 17 00:00:00 2001 From: Ben Joffe Date: Tue, 15 Dec 2015 21:21:41 +1100 Subject: [PATCH 105/353] 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 fb890afe6..45bc1b4ab 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 5dc8ee8dce912a84449a8024d34ef0609cf86824 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Tue, 15 Dec 2015 11:29:13 +0100 Subject: [PATCH 106/353] fixed es6 imports to have types properly exported instead of string --- angular-translate/angular-translate.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-translate/angular-translate.d.ts b/angular-translate/angular-translate.d.ts index e4f69c688..0d4048b0a 100644 --- a/angular-translate/angular-translate.d.ts +++ b/angular-translate/angular-translate.d.ts @@ -6,8 +6,8 @@ /// declare module "angular-translate" { - var _: string; - export = _; + import ngt = angular.translate; + export = ngt; } declare module angular.translate { From 09fa17a56f4d1e7318b5d2ab105950d0add62826 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Tue, 15 Dec 2015 10:40:04 +0000 Subject: [PATCH 107/353] Add commonJS support to angular-resource --- angularjs/angular-resource.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 76930196b..030ddd0c4 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -5,6 +5,10 @@ /// +declare module 'angular-resource' { + var _: string; + export = _; +} /////////////////////////////////////////////////////////////////////////////// // ngResource module (angular-resource.js) From 77e5ef281cd7b71713b32382c63dcc4c75e3c127 Mon Sep 17 00:00:00 2001 From: Laurence C Date: Tue, 15 Dec 2015 11:42:25 +0000 Subject: [PATCH 108/353] Add definitions for SwiftClick --- swiftclick/swiftclick-tests.ts | 7 +++++++ swiftclick/swiftclick.d.ts | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 swiftclick/swiftclick-tests.ts create mode 100644 swiftclick/swiftclick.d.ts diff --git a/swiftclick/swiftclick-tests.ts b/swiftclick/swiftclick-tests.ts new file mode 100644 index 000000000..237978996 --- /dev/null +++ b/swiftclick/swiftclick-tests.ts @@ -0,0 +1,7 @@ +/// + +var swiftClick = SwiftClick.attach(document.body); + +swiftClick.replaceNodeNamesToTrack(["a", "div", "h1"]); +swiftClick.addNodeNamesToTrack(["li"]); +swiftClick.useCssParser(true); \ No newline at end of file diff --git a/swiftclick/swiftclick.d.ts b/swiftclick/swiftclick.d.ts new file mode 100644 index 000000000..d00e9f761 --- /dev/null +++ b/swiftclick/swiftclick.d.ts @@ -0,0 +1,20 @@ +// Type definitions for SwiftClick v1.2.0 +// Project: https://github.com/munkychop/swiftclick +// Definitions by: Laurence C +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface SwiftClickObject { + addNodeNamesToTrack(nodeNamesArray: string[]): void; + replaceNodeNamesToTrack(nodeNamesArray: string[]): void; + useCssParser(useParser: boolean): void; +} + +interface SwiftClickStatic { + attach(contextEl: Element): SwiftClickObject; +} + +declare module "swiftclick" { + export = SwiftClick; +} + +declare var SwiftClick: SwiftClickStatic; From f3917c6c0bff6f5c2db8d44a90f4fe19c928224c Mon Sep 17 00:00:00 2001 From: lgrignon Date: Tue, 15 Dec 2015 15:48:20 +0100 Subject: [PATCH 109/353] backbone definitions (splitted PR) --- .../backbone.localstorage-tests.ts | 6 +++ .../backbone.localstorage.d.ts | 51 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 backbone.localstorage/backbone.localstorage-tests.ts create mode 100644 backbone.localstorage/backbone.localstorage.d.ts diff --git a/backbone.localstorage/backbone.localstorage-tests.ts b/backbone.localstorage/backbone.localstorage-tests.ts new file mode 100644 index 000000000..0d44897a8 --- /dev/null +++ b/backbone.localstorage/backbone.localstorage-tests.ts @@ -0,0 +1,6 @@ +/// + +var store: Store = new Store('testStore'); +store.findAll(); + +store.save(); diff --git a/backbone.localstorage/backbone.localstorage.d.ts b/backbone.localstorage/backbone.localstorage.d.ts new file mode 100644 index 000000000..122c47587 --- /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 c92a91b9eb4e669bb9c5b9a3d3288647acc75c8a Mon Sep 17 00:00:00 2001 From: Julien Renaux Date: Tue, 15 Dec 2015 10:03:54 -0600 Subject: [PATCH 110/353] Change Connections to string Connections are strings not numbers --- cordova/plugins/NetworkInformation.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cordova/plugins/NetworkInformation.d.ts b/cordova/plugins/NetworkInformation.d.ts index 53093284f..1ba2ae9e0 100644 --- a/cordova/plugins/NetworkInformation.d.ts +++ b/cordova/plugins/NetworkInformation.d.ts @@ -45,16 +45,16 @@ interface Connection { * Connection.CELL * Connection.NONE */ - type: number + type: string } declare var Connection: { - UNKNOWN: number; - ETHERNET: number; - WIFI: number; - CELL_2G: number; - CELL_3G: number; - CELL_4G: number; - CELL: number; - NONE: number; -} \ No newline at end of file + UNKNOWN: string; + ETHERNET: string; + WIFI: string; + CELL_2G: string; + CELL_3G: string; + CELL_4G: string; + CELL: string; + NONE: string; +} From a04c6d2afafb44fb6ecb77d48f503df720568725 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Dec 2015 22:02:23 +0500 Subject: [PATCH 111/353] lodash: signatures of _.some have been changed --- lodash/lodash-tests.ts | 40 +++++++++++++++++++++++++++++++++ lodash/lodash.d.ts | 50 ++++++++++++++++++++++++++++++++---------- 2 files changed, 78 insertions(+), 12 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2398b8d43..010e24480 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2694,9 +2694,11 @@ module TestAny { let array: TResult[]; let list: _.List; let dictionary: _.Dictionary; + let numericDictionary: _.NumericDictionary; let listIterator: (value: TResult, index: number, collection: _.List) => boolean; let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean; + let numericDictionaryIterator: (value: TResult, key: number, collection: _.NumericDictionary) => boolean; { let result: boolean; @@ -2719,6 +2721,12 @@ module TestAny { result = _.any(dictionary, ''); result = _.any<{a: number}, TResult>(dictionary, {a: 42}); + result = _.any(numericDictionary); + result = _.any(numericDictionary, numericDictionaryIterator); + result = _.any(numericDictionary, numericDictionaryIterator, any); + result = _.any(numericDictionary, ''); + result = _.any<{a: number}, TResult>(numericDictionary, {a: 42}); + result = _(array).any(); result = _(array).any(listIterator); result = _(array).any(listIterator, any); @@ -2736,6 +2744,12 @@ module TestAny { result = _(dictionary).any(dictionaryIterator, any); result = _(dictionary).any(''); result = _(dictionary).any<{a: number}>({a: 42}); + + result = _(numericDictionary).any(); + result = _(numericDictionary).any(numericDictionaryIterator); + result = _(numericDictionary).any(numericDictionaryIterator, any); + result = _(numericDictionary).any(''); + result = _(numericDictionary).any<{a: number}>({a: 42}); } { @@ -2758,6 +2772,12 @@ module TestAny { result = _(dictionary).chain().any(dictionaryIterator, any); result = _(dictionary).chain().any(''); result = _(dictionary).chain().any<{a: number}>({a: 42}); + + result = _(numericDictionary).chain().any(); + result = _(numericDictionary).chain().any(numericDictionaryIterator); + result = _(numericDictionary).chain().any(numericDictionaryIterator, any); + result = _(numericDictionary).chain().any(''); + result = _(numericDictionary).chain().any<{a: number}>({a: 42}); } } @@ -4378,9 +4398,11 @@ module TestSome { let array: TResult[]; let list: _.List; let dictionary: _.Dictionary; + let numericDictionary: _.NumericDictionary; let listIterator: (value: TResult, index: number, collection: _.List) => boolean; let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean; + let numericDictionaryIterator: (value: TResult, key: number, collection: _.NumericDictionary) => boolean; { let result: boolean; @@ -4403,6 +4425,12 @@ module TestSome { result = _.some(dictionary, ''); result = _.some<{a: number}, TResult>(dictionary, {a: 42}); + result = _.some(numericDictionary); + result = _.some(numericDictionary, numericDictionaryIterator); + result = _.some(numericDictionary, numericDictionaryIterator, any); + result = _.some(numericDictionary, ''); + result = _.some<{a: number}, TResult>(numericDictionary, {a: 42}); + result = _(array).some(); result = _(array).some(listIterator); result = _(array).some(listIterator, any); @@ -4420,6 +4448,12 @@ module TestSome { result = _(dictionary).some(dictionaryIterator, any); result = _(dictionary).some(''); result = _(dictionary).some<{a: number}>({a: 42}); + + result = _(numericDictionary).some(); + result = _(numericDictionary).some(numericDictionaryIterator); + result = _(numericDictionary).some(numericDictionaryIterator, any); + result = _(numericDictionary).some(''); + result = _(numericDictionary).some<{a: number}>({a: 42}); } { @@ -4442,6 +4476,12 @@ module TestSome { result = _(dictionary).chain().some(dictionaryIterator, any); result = _(dictionary).chain().some(''); result = _(dictionary).chain().some<{a: number}>({a: 42}); + + result = _(numericDictionary).chain().some(); + result = _(numericDictionary).chain().some(numericDictionaryIterator); + result = _(numericDictionary).chain().some(numericDictionaryIterator, any); + result = _(numericDictionary).chain().some(''); + result = _(numericDictionary).chain().some<{a: number}>({a: 42}); } } diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 64b4da950..bdaa88c83 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -4062,7 +4062,16 @@ declare module _ { * @see _.some */ any( - collection: List|Dictionary, + collection: NumericDictionary, + predicate?: NumericDictionaryIterator, + thisArg?: any + ): boolean; + + /** + * @see _.some + */ + any( + collection: List|Dictionary|NumericDictionary, predicate?: string, thisArg?: any ): boolean; @@ -4071,7 +4080,7 @@ declare module _ { * @see _.some */ any( - collection: List|Dictionary, + collection: List|Dictionary|NumericDictionary, predicate?: TObject ): boolean; } @@ -4081,7 +4090,7 @@ declare module _ { * @see _.some */ any( - predicate?: ListIterator, + predicate?: ListIterator|NumericDictionaryIterator, thisArg?: any ): boolean; @@ -4106,7 +4115,7 @@ declare module _ { * @see _.some */ any( - predicate?: ListIterator|DictionaryIterator, + predicate?: ListIterator|DictionaryIterator|NumericDictionaryIterator, thisArg?: any ): boolean; @@ -4131,7 +4140,7 @@ declare module _ { * @see _.some */ any( - predicate?: ListIterator, + predicate?: ListIterator|NumericDictionaryIterator, thisArg?: any ): LoDashExplicitWrapper; @@ -4156,7 +4165,7 @@ declare module _ { * @see _.some */ any( - predicate?: ListIterator|DictionaryIterator, + predicate?: ListIterator|DictionaryIterator|NumericDictionaryIterator, thisArg?: any ): LoDashExplicitWrapper; @@ -7477,7 +7486,16 @@ declare module _ { * @see _.some */ some( - collection: List|Dictionary, + collection: NumericDictionary, + predicate?: NumericDictionaryIterator, + thisArg?: any + ): boolean; + + /** + * @see _.some + */ + some( + collection: List|Dictionary|NumericDictionary, predicate?: string, thisArg?: any ): boolean; @@ -7486,7 +7504,7 @@ declare module _ { * @see _.some */ some( - collection: List|Dictionary, + collection: List|Dictionary|NumericDictionary, predicate?: TObject ): boolean; } @@ -7496,7 +7514,7 @@ declare module _ { * @see _.some */ some( - predicate?: ListIterator, + predicate?: ListIterator|NumericDictionaryIterator, thisArg?: any ): boolean; @@ -7521,7 +7539,7 @@ declare module _ { * @see _.some */ some( - predicate?: ListIterator|DictionaryIterator, + predicate?: ListIterator|DictionaryIterator|NumericDictionaryIterator, thisArg?: any ): boolean; @@ -7546,7 +7564,7 @@ declare module _ { * @see _.some */ some( - predicate?: ListIterator, + predicate?: ListIterator|NumericDictionaryIterator, thisArg?: any ): LoDashExplicitWrapper; @@ -7571,7 +7589,7 @@ declare module _ { * @see _.some */ some( - predicate?: ListIterator|DictionaryIterator, + predicate?: ListIterator|DictionaryIterator|NumericDictionaryIterator, thisArg?: any ): LoDashExplicitWrapper; @@ -13743,6 +13761,10 @@ declare module _ { (value: T, key?: string, collection?: Dictionary): TResult; } + interface NumericDictionaryIterator { + (value: T, key?: number, collection?: Dictionary): TResult; + } + interface ObjectIterator { (element: T, key?: string, collection?: any): TResult; } @@ -13777,6 +13799,10 @@ declare module _ { [index: string]: T; } + interface NumericDictionary { + [index: number]: T; + } + interface StringRepresentable { toString(): string; } From c7f2c236186e7da6b3711bcafc0469786622ffc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Junges?= Date: Tue, 15 Dec 2015 23:00:36 -0200 Subject: [PATCH 112/353] Add support to .component from Angularjs 1.5 --- angularjs/angular.d.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index a489141d5..713e6681d 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -181,6 +181,13 @@ declare module angular { animation(name: string, animationFactory: Function): IModule; animation(name: string, inlineAnnotatedFunction: any[]): IModule; animation(object: Object): IModule; + /** + * Use this method to register a component. + * + * @param name The name of the component. + * @param options A definition object passed into the component. + */ + component(name: string, options: IComponentOptions): IModule; /** * Use this method to register work which needs to be performed on module loading. * @@ -1619,6 +1626,23 @@ declare module angular { */ totalPendingRequests: number; } + + /////////////////////////////////////////////////////////////////////////// + // Component + // see http://angularjs.blogspot.com.br/2015/11/angularjs-15-beta2-and-14-releases.html + // and http://toddmotto.com/exploring-the-angular-1-5-component-method/ + /////////////////////////////////////////////////////////////////////////// + + interface IComponentOptions { + bindings?: Object, + controller: Function|string, + controllerAs?: string, + isolate?: boolean, + restrict?: string, + template?: Array|Function, + templateUrl?: string, + transclude?: boolean + } /////////////////////////////////////////////////////////////////////////// // Directive From 3746eb32840de17c1f4eb306047c505639194644 Mon Sep 17 00:00:00 2001 From: hinamiyagk Date: Wed, 16 Dec 2015 10:50:52 +0900 Subject: [PATCH 113/353] Fix wrong returning type of electron.hideInternalModules --- 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 5dcaba2ff..7334d04ae 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1718,7 +1718,7 @@ declare module GitHubElectron { powerMonitor: NodeJS.EventEmitter; protocol: GitHubElectron.Protocol; Tray: typeof GitHubElectron.Tray; - hideInternalModules(): any; + hideInternalModules(): void; } } From 07b87e60644a79da813e44e8dd7c8ade85f1ce06 Mon Sep 17 00:00:00 2001 From: f111fei Date: Wed, 16 Dec 2015 09:50:54 +0800 Subject: [PATCH 114/353] #7152 [node] parameter type of "signal" in process.kill --- node/node-0.10.d.ts | 2 +- node/node-0.11.d.ts | 2 +- node/node-0.12.d.ts | 2 +- node/node-0.8.8.d.ts | 2 +- node/node.d.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/node/node-0.10.d.ts b/node/node-0.10.d.ts index a4cd5b1a6..ba170e864 100644 --- a/node/node-0.10.d.ts +++ b/node/node-0.10.d.ts @@ -176,7 +176,7 @@ declare module NodeJS { visibility: string; }; }; - kill(pid: number, signal?: string): void; + kill(pid:number, signal?: string|number): void; pid: number; title: string; arch: string; diff --git a/node/node-0.11.d.ts b/node/node-0.11.d.ts index 05aee911d..b05e53494 100644 --- a/node/node-0.11.d.ts +++ b/node/node-0.11.d.ts @@ -176,7 +176,7 @@ declare module NodeJS { visibility: string; }; }; - kill(pid: number, signal?: string): void; + kill(pid:number, signal?: string|number): void; pid: number; title: string; arch: string; diff --git a/node/node-0.12.d.ts b/node/node-0.12.d.ts index 11fd92d24..39f0aa37a 100644 --- a/node/node-0.12.d.ts +++ b/node/node-0.12.d.ts @@ -256,7 +256,7 @@ declare module NodeJS { visibility: string; }; }; - kill(pid: number, signal?: string): void; + kill(pid:number, signal?: string|number): void; pid: number; title: string; arch: string; diff --git a/node/node-0.8.8.d.ts b/node/node-0.8.8.d.ts index 1972e0cdc..ea56c7306 100644 --- a/node/node-0.8.8.d.ts +++ b/node/node-0.8.8.d.ts @@ -150,7 +150,7 @@ interface NodeProcess extends EventEmitter { visibility: string; }; }; - kill(pid: number, signal?: string): void; + kill(pid:number, signal?: string|number): void; pid: number; title: string; arch: string; diff --git a/node/node.d.ts b/node/node.d.ts index 06c4bb960..449583a30 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -256,7 +256,7 @@ declare module NodeJS { visibility: string; }; }; - kill(pid: number, signal?: string): void; + kill(pid:number, signal?: string|number): void; pid: number; title: string; arch: string; From a7054eca4ee3bba7f7924fedc92b1b467bb7467e Mon Sep 17 00:00:00 2001 From: sodatea Date: Wed, 16 Dec 2015 12:23:18 +0800 Subject: [PATCH 115/353] 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 000000000..a01675a1c --- /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 000000000..50bf0aab8 --- /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 9b6a4f0c872faa9b2bd768965e61a2e7ad1ce912 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 16 Dec 2015 11:48:44 +0500 Subject: [PATCH 116/353] node: signatures of module "readline" have been changed --- node/node-tests.ts | 102 ++++++++++++++++++++++++++++++++++++++++----- node/node.d.ts | 39 ++++++++++++++--- 2 files changed, 124 insertions(+), 17 deletions(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index aa0f55bb6..e21b5d981 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -421,21 +421,101 @@ module path_tests { } //////////////////////////////////////////////////// -///ReadLine tests : https://nodejs.org/api/readline.html +/// readline tests : https://nodejs.org/api/readline.html //////////////////////////////////////////////////// -var rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, -}); +module readline_tests { + let rl: readline.ReadLine; -rl.setPrompt("$>"); -rl.prompt(); -rl.prompt(true); + { + let options: readline.ReadLineOptions; + let input: NodeJS.ReadableStream; + let output: NodeJS.WritableStream; + let completer: readline.Completer; + let terminal: boolean; -rl.question("do you like typescript?", function(answer: string) { - rl.close(); -}); + let result: readline.ReadLine; + + result = readline.createInterface(options); + result = readline.createInterface(input); + result = readline.createInterface(input, output); + result = readline.createInterface(input, output, completer); + result = readline.createInterface(input, output, completer, terminal); + } + + { + let prompt: string; + + rl.setPrompt(prompt); + } + + { + let preserveCursor: boolean; + + rl.prompt(); + rl.prompt(preserveCursor); + } + + { + let query: string; + let callback: (answer: string) => void; + + rl.question(query, callback); + } + + { + let result: readline.ReadLine; + + result = rl.pause(); + } + + { + let result: readline.ReadLine; + + result = rl.resume(); + } + + { + rl.close(); + } + + { + let data: string|Buffer; + let key: readline.Key; + + rl.write(data); + rl.write(null, key); + } + + { + let stream: NodeJS.WritableStream; + let x: number; + let y: number; + + readline.cursorTo(stream, x, y); + } + + { + let stream: NodeJS.WritableStream; + let dx: number|string; + let dy: number|string; + + readline.moveCursor(stream, dx, dy); + } + + { + let stream: NodeJS.WritableStream; + let dir: number; + + readline.clearLine(stream, dir); + } + + { + let stream: NodeJS.WritableStream; + + readline.clearScreenDown(stream); + } +} ////////////////////////////////////////////////////////////////////// /// Child Process tests: https://nodejs.org/api/child_process.html /// diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..63478c451 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -826,22 +826,49 @@ declare module "readline" { import * as events from "events"; import * as stream from "stream"; + export interface Key { + sequence?: string; + name?: string; + ctrl?: boolean; + meta?: boolean; + shift?: boolean; + } + export interface ReadLine extends events.EventEmitter { setPrompt(prompt: string): void; prompt(preserveCursor?: boolean): void; - question(query: string, callback: Function): void; - pause(): void; - resume(): void; + question(query: string, callback: (answer: string) => void): void; + pause(): ReadLine; + resume(): ReadLine; close(): void; - write(data: any, key?: any): void; + write(data: string|Buffer, key?: Key): void; } + + export interface Completer { + (line: string): CompleterResult; + (line: string, callback: (err: any, result: CompleterResult) => void): any; + } + + export interface CompleterResult { + completions: string[]; + line: string; + } + export interface ReadLineOptions { input: NodeJS.ReadableStream; - output: NodeJS.WritableStream; - completer?: Function; + output?: NodeJS.WritableStream; + completer?: Completer; terminal?: boolean; + historySize?: number; } + + export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine; export function createInterface(options: ReadLineOptions): ReadLine; + + export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; + export function moveCursor(stream: NodeJS.WritableStream, dx: number|string, dy: number|string): void; + export function clearLine(stream: NodeJS.WritableStream, dir: number): void; + export function clearScreenDown(stream: NodeJS.WritableStream): void; } declare module "vm" { From e5f4e76f6b9cd219fa2b89d33e03fd2507c60461 Mon Sep 17 00:00:00 2001 From: Denis Sokolov Date: Wed, 16 Dec 2015 09:38:22 +0200 Subject: [PATCH 117/353] 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 118/353] 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 fb0e52b46..947fbcdae 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 5d78b33357dde02151413b63ffa569246cab0b2f Mon Sep 17 00:00:00 2001 From: LAN Xingcan Date: Wed, 16 Dec 2015 19:01:52 +0800 Subject: [PATCH 119/353] Allow pass buffer argument for pbkdf2 function --- node/node-0.10.d.ts | 4 ++-- node/node-0.11.d.ts | 4 ++-- node/node-0.12.d.ts | 4 ++-- node/node-0.8.8.d.ts | 4 ++-- node/node.d.ts | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/node/node-0.10.d.ts b/node/node-0.10.d.ts index a4cd5b1a6..f6aff4f70 100644 --- a/node/node-0.10.d.ts +++ b/node/node-0.10.d.ts @@ -1191,8 +1191,8 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer; export function randomBytes(size: number): Buffer; export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; export function pseudoRandomBytes(size: number): Buffer; diff --git a/node/node-0.11.d.ts b/node/node-0.11.d.ts index 05aee911d..8c8959ecd 100644 --- a/node/node-0.11.d.ts +++ b/node/node-0.11.d.ts @@ -1099,8 +1099,8 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer; export function randomBytes(size: number): Buffer; export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; export function pseudoRandomBytes(size: number): Buffer; diff --git a/node/node-0.12.d.ts b/node/node-0.12.d.ts index 11fd92d24..2c411c4a9 100644 --- a/node/node-0.12.d.ts +++ b/node/node-0.12.d.ts @@ -1654,8 +1654,8 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer; export function randomBytes(size: number): Buffer; diff --git a/node/node-0.8.8.d.ts b/node/node-0.8.8.d.ts index 1972e0cdc..c6b2acf50 100644 --- a/node/node-0.8.8.d.ts +++ b/node/node-0.8.8.d.ts @@ -326,7 +326,7 @@ declare module "cluster" { export function disconnect(callback?: Function): void; export var workers: any; - // Event emitter + // Event emitter export function addListener(event: string, listener: Function): void; export function on(event: string, listener: Function): any; export function once(event: string, listener: Function): void; @@ -970,7 +970,7 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; export function randomBytes(size: number, callback?: (err: Error, buf: Buffer) =>void ); } diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..e031cbf74 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1694,10 +1694,10 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer; + export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string) : Buffer; export function randomBytes(size: number): Buffer; export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; export function pseudoRandomBytes(size: number): Buffer; From 793ee5fa00b4c78fb7619e1137085aa376eade11 Mon Sep 17 00:00:00 2001 From: Eric Nicholson Date: Wed, 16 Dec 2015 09:20:08 -0500 Subject: [PATCH 120/353] Added bluebird mapSeries definitions --- bluebird/bluebird-tests.ts | 97 +++++++++++++++++++++++++++++++++++--- bluebird/bluebird.d.ts | 25 ++++++++++ 2 files changed, 116 insertions(+), 6 deletions(-) diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index bd4f46fc4..5f96d28ef 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -607,19 +607,19 @@ Promise.all([fooProm, barProm, fooProm]).then(result => { //TODO fix collection inference -barArrProm = fooProm.map((item: Foo, index: number, arrayLength: number) => { +barArrProm = fooArrProm.map((item: Foo, index: number, arrayLength: number) => { return bar; }); -barArrProm = fooProm.map((item: Foo) => { +barArrProm = fooArrProm.map((item: Foo) => { return bar; }); -barArrProm = fooProm.map((item: Foo, index: number, arrayLength: number) => { +barArrProm = fooArrProm.map((item: Foo, index: number, arrayLength: number) => { return bar; }, { concurrency: 1 }); -barArrProm = fooProm.map((item: Foo) => { +barArrProm = fooArrProm.map((item: Foo) => { return bar; }, { concurrency: 1 @@ -627,10 +627,20 @@ barArrProm = fooProm.map((item: Foo) => { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -barProm = fooProm.reduce((memo: Bar, item: Foo, index: number, arrayLength: number) => { +barArrProm = fooArrProm.mapSeries((item: Foo, index: number, arrayLength: number) => { + return bar; +}); +barArrProm = fooArrProm.mapSeries((item: Foo) => { + return bar; +}); + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +barProm = fooArrProm.reduce((memo: Bar, item: Foo, index: number, arrayLength: number) => { return memo; }); -barProm = fooProm.reduce((memo: Bar, item: Foo) => { +barProm = fooArrProm.reduce((memo: Bar, item: Foo) => { return memo; }, bar); @@ -1008,6 +1018,81 @@ barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) concurrency: 1 }); +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// mapSeries() + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooThenArrThen + +barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo) => { + return barThen; +}); +barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooArrThen + +barArrProm = Promise.mapSeries(fooArrThen, (item: Foo) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooArrThen, (item: Foo) => { + return barThen; +}); +barArrProm = Promise.mapSeries(fooArrThen, (item: Foo, index: number, arrayLength: number) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooArrThen, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}); + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooThenArr + +barArrProm = Promise.mapSeries(fooThenArr, (item: Foo) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooThenArr, (item: Foo) => { + return barThen; +}); +barArrProm = Promise.mapSeries(fooThenArr, (item: Foo, index: number, arrayLength: number) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooThenArr, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}); + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooArr + +barArrProm = Promise.mapSeries(fooArr, (item: Foo) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooArr, (item: Foo) => { + return barThen; +}); +barArrProm = Promise.mapSeries(fooArr, (item: Foo, index: number, arrayLength: number) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooArr, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // reduce() diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index f3420957a..3d205f2ed 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -315,6 +315,12 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { map(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; map(mapper: (item: Q, index: number, arrayLength: number) => U, options?: Promise.ConcurrencyOption): Promise; + /** + * Same as `Promise.mapSeries(thisPromise, mapper)`. + */ + // TODO type inference from array-resolving promise? + mapSeries(mapper: (item: Q, index: number, arrayLength: number) => U|Promise.Thenable): Promise; + /** * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ @@ -573,6 +579,25 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U, options?: Promise.ConcurrencyOption): Promise; + /** + * Similar to `map` with concurrency set to 1 but guaranteed to execute in sequential order + * + * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well. + * + * *The original array is not modified.* + */ + // promise of array with promises of value + static mapSeries(values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U|Promise.Thenable): Promise; + + // promise of array with values + static mapSeries(values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U|Promise.Thenable): Promise; + + // array with promises of value + static mapSeries(values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U|Promise.Thenable): Promise; + + // array with values + static mapSeries(values: R[], mapper: (item: R, index: number, arrayLength: number) => U|Promise.Thenable): Promise; + /** * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. * From f2a49a691651e4fcd3a8d14be5c9bdcde9c374b7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 16 Dec 2015 09:55:29 -0800 Subject: [PATCH 121/353] Add schemeNumber part of javascript-bignum library --- javascript-bignum/javascript-bignum-tests.ts | 21 ++++++++ javascript-bignum/javascript-bignum.d.ts | 53 ++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 javascript-bignum/javascript-bignum-tests.ts create mode 100644 javascript-bignum/javascript-bignum.d.ts diff --git a/javascript-bignum/javascript-bignum-tests.ts b/javascript-bignum/javascript-bignum-tests.ts new file mode 100644 index 000000000..57555fcce --- /dev/null +++ b/javascript-bignum/javascript-bignum-tests.ts @@ -0,0 +1,21 @@ +/// +let m = SchemeNumber("1"); +let n = SchemeNumber(2); + +let sum: SchemeNumber = SchemeNumber.fn["+"](m, n); +sum = SchemeNumber.fn["+"](m, 1); +sum = SchemeNumber.fn["+"](m, "12"); +sum = SchemeNumber.fn["+"]("12", "25"); + +let floored: SchemeNumber = SchemeNumber.fn.floor(m); + +let str: string = floored.toString(16); +str = floored.toExponential(2); +str = floored.toPrecision(2); +str = floored.toFixed(2); + +let num: number = maxIntegerDigits; +num = VERSION[0]; +num = VERSION.length; + +raise("fake error", "This is not really an error", m); diff --git a/javascript-bignum/javascript-bignum.d.ts b/javascript-bignum/javascript-bignum.d.ts new file mode 100644 index 000000000..a088837d1 --- /dev/null +++ b/javascript-bignum/javascript-bignum.d.ts @@ -0,0 +1,53 @@ +// Type definitions for javascript-bignum +// Project: https://github.com/jtobey/javascript-bignum +// Definitions by: Nathan Shively-Sanders +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Documentation: http://john-edwin-tobey.org/Scheme/javascript-bignum/docs/files/schemeNumber-js.html + +// This version only includes typing for schemeNumber, not the full library +declare type SchemeOperator = (...args: (string | SchemeNumber | number)[]) => SchemeNumber; +declare var VERSION: number[]; +declare function raise(conditionType: string, message: string, ...irritants: any[]): void; +declare var maxIntegerDigits: number; +declare interface SchemeFn { + [opname: string]: SchemeOperator; + inexact: SchemeOperator; + exact: SchemeOperator; + max: SchemeOperator; + min: SchemeOperator; + abs: SchemeOperator; + div: SchemeOperator; + mod: SchemeOperator; + div0: SchemeOperator; + mod0: SchemeOperator; + gcd: SchemeOperator; + lcm: SchemeOperator; + numerator: SchemeOperator; + denominator: SchemeOperator; + floor: SchemeOperator; + ceiling: SchemeOperator; + truncate: SchemeOperator; + round: SchemeOperator; + rationalize: SchemeOperator; + exp: SchemeOperator; + log: SchemeOperator; + sin: SchemeOperator; + cos: SchemeOperator; + tan: SchemeOperator; + asin: SchemeOperator; + acos: SchemeOperator; + atan: SchemeOperator; + sqrt: SchemeOperator; + expt: SchemeOperator; + magnitude: SchemeOperator; + angle: SchemeOperator; +} +declare interface SchemeNumber { + (value: string | number): SchemeNumber; + toString(radix: number): string; + toFixed(fractionDigits: number): string; + toExponential(fractionDigits: number): string; + toPrecision(precision: number): string; + fn: SchemeFn; +} +declare var SchemeNumber: SchemeNumber; From 223687fd0d9f082e0be46589967acb09c327c4cf Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Wed, 16 Dec 2015 22:55:03 +0100 Subject: [PATCH 122/353] BUGFIX in ITemplateOptions definition --- angular-formly/angular-formly.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts index d52df5e48..fce793e7e 100644 --- a/angular-formly/angular-formly.d.ts +++ b/angular-formly/angular-formly.d.ts @@ -72,7 +72,7 @@ declare module AngularFormly { interface ISelectOption { name: string; - value: string; + value?: string; group?: string; } @@ -110,7 +110,7 @@ declare module AngularFormly { [key: string]: any; // types for select/radio fields - options?: ISelectOption | any; + options?: Array; groupProp?: string; // default: group valueProp?: string; // default: value labelProp?: string; // default: name From ea6787006265bcfbb7a051f85dfd2f74506a0a01 Mon Sep 17 00:00:00 2001 From: amritk Date: Wed, 16 Dec 2015 15:25:21 -0800 Subject: [PATCH 123/353] Updated stripe.d.ts Added bank account methods for managed accounts. --- stripe/stripe.d.ts | 48 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index 96d8758bc..f18dff0ee 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -1,6 +1,6 @@ // Type definitions for stripe // Project: https://stripe.com/ -// Definitions by: Andy Hawkins , Eric J. Smith +// Definitions by: Andy Hawkins , Eric J. Smith , Amrit Kahlon // Definitions: https://github.com/borisyankov/DefinitelyTyped interface StripeStatic { @@ -11,7 +11,8 @@ interface StripeStatic { cardType(cardNumber: string): string; getToken(token: string, responseHandler: (status: number, response: StripeTokenResponse) => void): void; card: StripeCardData; - createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void; + createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void; + bankAccount: StripeBankAccount; } interface StripeTokenData { @@ -40,7 +41,10 @@ interface StripeTokenResponse { } interface StripeError { + type: string; + code: string; message: string; + param?: string; } interface StripeCardData { @@ -60,7 +64,45 @@ interface StripeCardData { address_country?: string; } +interface StripeBankAccount +{ + createToken(params: StripeBankTokenParams, stripeResponseHandler: (response: StripeBankTokenResponse) => void): void; + validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean; + validateAccountNumber(accountNumber: number | string, countryCode: string): boolean; +} + +interface StripeBankTokenParams +{ + country: string; + currency: string; + routing_number?: number | string; + account_number?: number | string; + transit_number?: number | string; + institution_number?: number | string; + bsb?: number | string; + sort_code?: string; + iban?: string; +} + +interface StripeBankTokenResponse +{ + id: string; + bank_account: { + country: string; + bank_name: string; + last4: number; + validated: boolean; + object: string; + }; + created: number; + livemode: boolean; + type: string; + object: string; + used: boolean; + error: StripeError; +} + declare var Stripe: StripeStatic; declare module "Stripe" { - export = StripeStatic; + export = StripeStatic; } From b6f9544291b2fc44e33771c699158a3a0543a331 Mon Sep 17 00:00:00 2001 From: amritk Date: Wed, 16 Dec 2015 15:33:27 -0800 Subject: [PATCH 124/353] update stripe.d.ts Added status to bank token creation response --- stripe/stripe.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index f18dff0ee..3fcf771e3 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -66,7 +66,7 @@ interface StripeCardData { interface StripeBankAccount { - createToken(params: StripeBankTokenParams, stripeResponseHandler: (response: StripeBankTokenResponse) => void): void; + createToken(params: StripeBankTokenParams, stripeResponseHandler: (status:number, response: StripeBankTokenResponse) => void): void; validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean; validateAccountNumber(accountNumber: number | string, countryCode: string): boolean; } From 8907ae9ff9c1b62b1883190871aafbe0f5574203 Mon Sep 17 00:00:00 2001 From: amritk Date: Wed, 16 Dec 2015 16:26:17 -0800 Subject: [PATCH 125/353] update stripe.d.ts All those extra bank fields are passed as routing number. --- stripe/stripe.d.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index 3fcf771e3..06901ee9f 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -75,13 +75,8 @@ interface StripeBankTokenParams { country: string; currency: string; + account_number: number | string; routing_number?: number | string; - account_number?: number | string; - transit_number?: number | string; - institution_number?: number | string; - bsb?: number | string; - sort_code?: string; - iban?: string; } interface StripeBankTokenResponse From 336361b4e23da3f5e8b2181f9fc715213685d159 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 16 Dec 2015 18:09:23 -0800 Subject: [PATCH 126/353] 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 000000000..eddf870a4 --- /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 000000000..ea8f33d9d --- /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 a30d1017ee9f822c332eaba3d128dd0af5f00816 Mon Sep 17 00:00:00 2001 From: amritk Date: Wed, 16 Dec 2015 18:32:12 -0800 Subject: [PATCH 127/353] Update stripe.d.ts --- stripe/stripe.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index 06901ee9f..27d60d961 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -83,6 +83,7 @@ interface StripeBankTokenResponse { id: string; bank_account: { + id: string; country: string; bank_name: string; last4: number; From 230dcd425bd9e818df6cdc1ff9f29d5368123031 Mon Sep 17 00:00:00 2001 From: Joshua Filby Date: Wed, 16 Dec 2015 21:05:01 -0600 Subject: [PATCH 128/353] 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 000000000..acfc48e43 --- /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 000000000..3d3128d02 --- /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 129/353] 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 ea8f33d9d..3d37bf0c5 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 4f03ef7344e97760125f45950a870b09fc3e3081 Mon Sep 17 00:00:00 2001 From: Sven Reglitzki Date: Thu, 17 Dec 2015 10:08:48 +0100 Subject: [PATCH 130/353] Add sandboxed-module definitions --- sandboxed-module/sandboxed-module.d.ts | 103 +++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 sandboxed-module/sandboxed-module.d.ts diff --git a/sandboxed-module/sandboxed-module.d.ts b/sandboxed-module/sandboxed-module.d.ts new file mode 100644 index 000000000..94fb37450 --- /dev/null +++ b/sandboxed-module/sandboxed-module.d.ts @@ -0,0 +1,103 @@ +// Type definitions for sandboxed-module v2.0.3 +// Project: https://github.com/felixge/node-sandboxed-module +// Definitions by: Sven Reglitzki +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "sandboxed-module" { + + interface SandboxOptions { + /** + * An object containing moduleIds and the values to inject for them when required by the sandboxed module. + * This does not affect children of the sandboxed module. + */ + requires?: Object; + /** + * An object of global variables to inject into the sandboxed module. + */ + globals?: Object; + /** + * An object of local variables to inject into the sandboxed module. + */ + locals?: Object; + /** + * An object of named functions which will transform the source code required with SandboxedModule.require. + * For example, CoffeeScript & istanbul support is implemented with built-in sourceTransformer functions + * (see #registerBuiltInSourceTransformer). + * + * A source transformer receives the source (as it's been transformed thus far) and must return the transformed + * source (whether it's changed or unchanged). + * + * An example source transformer to change all instances of the number "3" to "5" would look like this: + * + * SandboxedModule.require('../fixture/baz', { + * sourceTransformers: { + * turn3sInto5s: function(source) { + * return source.replace(/3/g,'5'); + * } + * } + * }) + */ + sourceTransformers?: Object; + /** + * If false, modules that are required by the sandboxed module will not be sandboxed. By default all modules + * required by the sandboxedModule will be sandboxed using the same options that were used for the original + * sandboxed module. + */ + singleOnly?: boolean; + /** + * If false, the source transformers will not be run against modules required by the sandboxed module. + * By default it will take the same value as {@link SandboxOptions.singleOnly}. + */ + sourceTransformersSingleOnly?: boolean; + } + + class SandboxedModule { + /** + * See {@link SandboxOptions.requires} + */ + required:Object; + /** + * See {@link SandboxOptions.globals} + */ + globals:Object; + /** + * See {@link SandboxOptions.locals} + */ + locals:Object; + /** + * See {@link SandboxOptions.sourceTransformers}. + */ + sourceTransformers:Object; + /** + * The full path to the module. + */ + filename:string; + /** + * The underlaying node.js Module instance. + */ + module:string; + /** + * A getter returning the sandboxedModule.module.exports object. + */ + exports:any; + /** + * Returns a new SandboxedModule where moduleId is a regular module path / id as you would normally pass into + * require(). The new module will be loaded in its own v8 context, but otherwise have access to the normal + * node.js environment. + * + * @param moduleId the ID of the module to load + * @param options the loading options + */ + static load(moduleId:string, options?:SandboxOptions):SandboxedModule + + /** + * Identical to {@link SandboxedModule.load()}, but returns sandboxedModule.exports directly. + * + * @param moduleId the ID of the module to require + * @param options the requiring options + */ + static require(moduleId:string, options?:SandboxOptions):any + } + + export = SandboxedModule; +} From 725408f13522c67f3393be1fc51d1c311fb3ebfb Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Thu, 17 Dec 2015 11:04:10 +0100 Subject: [PATCH 131/353] Add host and port to TlsOptions --- node/node-tests.ts | 7 +++++++ node/node.d.ts | 2 ++ 2 files changed, 9 insertions(+) diff --git a/node/node-tests.ts b/node/node-tests.ts index aa0f55bb6..717220afc 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -198,6 +198,13 @@ var ctx: tls.SecureContext = tls.createSecureContext({ }); var blah = ctx.context; +var tlsOpts: tls.TlsOptions = { + host: "127.0.0.1", + port: 55 +}; +var tlsSocket = tls.connect(tlsOpts); + + //////////////////////////////////////////////////// // Make sure .listen() and .close() retuern a Server instance diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..2b7c2a10d 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1535,6 +1535,8 @@ declare module "tls" { var CLIENT_RENEG_WINDOW: number; export interface TlsOptions { + host?: string; + port?: number; pfx?: any; //string or buffer key?: any; //string or buffer passphrase?: string; From 1ebf010a1eecb2025777b44e5c0387a4c9f0472c Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Thu, 17 Dec 2015 11:31:43 +0100 Subject: [PATCH 132/353] http.RequestOptions.agent can also be a boolean https://nodejs.org/api/http.html#http_http_request_options_callback --- node/node-tests.ts | 10 ++++++++++ node/node.d.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index aa0f55bb6..021517169 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -226,6 +226,16 @@ module http_tests { }); var agent: http.Agent = http.globalAgent; + + http.request({ + agent: false + }); + http.request({ + agent: agent + }); + http.request({ + agent: undefined + }); } //////////////////////////////////////////////////// diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..f937b53eb 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -453,7 +453,7 @@ declare module "http" { path?: string; headers?: { [key: string]: any }; auth?: string; - agent?: Agent; + agent?: Agent|boolean; } export interface Server extends events.EventEmitter { From 22997bee704f7d14033b5a1972d3811ad65e576c Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Thu, 17 Dec 2015 11:40:40 +0100 Subject: [PATCH 133/353] Add all options to child_process.fork() https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options --- node/node.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..dfc3cff11 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -907,7 +907,11 @@ declare module "child_process" { export function fork(modulePath: string, args?: string[], options?: { cwd?: string; env?: any; - encoding?: string; + execPath?: string; + execArgv?: string[]; + silent?: boolean; + uid?: number; + gid?: number; }): ChildProcess; export function spawnSync(command: string, args?: string[], options?: { cwd?: string; From 96a1146cdab67999add011ce79611b8544a9dcb2 Mon Sep 17 00:00:00 2001 From: Sven Reglitzki Date: Thu, 17 Dec 2015 12:23:50 +0100 Subject: [PATCH 134/353] Add some tests to sandboxed-module --- sandboxed-module/sandboxed-module-tests.ts | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sandboxed-module/sandboxed-module-tests.ts diff --git a/sandboxed-module/sandboxed-module-tests.ts b/sandboxed-module/sandboxed-module-tests.ts new file mode 100644 index 000000000..a2e6ff2c4 --- /dev/null +++ b/sandboxed-module/sandboxed-module-tests.ts @@ -0,0 +1,28 @@ +// Type definitions for sandboxed-module v2.0.3 +// Project: https://github.com/felixge/node-sandboxed-module +// Definitions by: Sven Reglitzki +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +import SandboxedModule = require("sandboxed-module"); + +var sandboxedModule:SandboxedModule = SandboxedModule.load("foo"); +var sandboxedModuleExports:any = SandboxedModule.require("foo"); + +var sandboxedModuleExportsWithOptions:any = SandboxedModule.require("foo", { + requires: { + someDep: {} + }, + globals: { + theAnswer: 42 + }, + locals: { + someLocal: 1 + }, + sourceTransformers: { + identity: (src:string) => src + }, + singleOnly: true, + sourceTransformersSingleOnly: true +}); From 90a746fd3b9f1afb19453ceb3764d7978f3dd14f Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 17 Dec 2015 16:03:22 +0500 Subject: [PATCH 135/353] lodash: signatures of _.uniq have been changed --- lodash/lodash-tests.ts | 348 ++++++++++++-- lodash/lodash.d.ts | 1011 +++++++++++++++++++++++++++++----------- 2 files changed, 1059 insertions(+), 300 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d661839d5..efdc7ecdc 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1671,37 +1671,329 @@ module TestUnion { } } -result = _.uniq([1, 2, 1, 3, 1]); -result = _.uniq([1, 1, 2, 2, 3], true); -result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { - return letter.toLowerCase(); -}); -result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); -result = <{ x: number; }[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +// _.uniq +module TestUniq { + type SampleObject = {a: number; b: string; c: boolean}; -result = _.unique([1, 2, 1, 3, 1]); -result = _.unique([1, 1, 2, 2, 3], true); -result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { - return letter.toLowerCase(); -}); -result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); -result = <{ x: number; }[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + let array: SampleObject[]; + let list: _.List; -result = _([1, 2, 1, 3, 1]).uniq().value(); -result = _([1, 1, 2, 2, 3]).uniq(true).value(); -result = _(['A', 'b', 'C', 'a', 'B', 'c']).uniq(function (letter) { - return letter.toLowerCase(); -}).value(); -result = _([1, 2.5, 3, 1.5, 2, 3.5]).uniq(function (num) { return this.floor(num); }, Math).value(); -result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).uniq('x').value(); + let stringIterator: (value: string, index: number, collection: string) => string; + let listIterator: (value: SampleObject, index: number, collection: _.List) => number; -result = _([1, 2, 1, 3, 1]).unique().value(); -result = _([1, 1, 2, 2, 3]).unique(true).value(); -result = _(['A', 'b', 'C', 'a', 'B', 'c']).unique(function (letter) { - return letter.toLowerCase(); -}).value(); -result = _([1, 2.5, 3, 1.5, 2, 3.5]).unique(function (num) { return this.floor(num); }, Math).value(); -result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).unique('x').value(); + { + let result: string[]; + + result = _.uniq('abc'); + result = _.uniq('abc', true); + result = _.uniq('abc', true, stringIterator); + result = _.uniq('abc', true, stringIterator, any); + result = _.uniq('abc', true, stringIterator); + result = _.uniq('abc', true, stringIterator, any); + result = _.uniq('abc', stringIterator); + result = _.uniq('abc', stringIterator, any); + result = _.uniq('abc', stringIterator); + result = _.uniq('abc', stringIterator, any); + } + + { + let result: SampleObject[]; + + result = _.uniq(array); + result = _.uniq(array, true); + result = _.uniq(array, true, listIterator); + result = _.uniq(array, true, listIterator, any); + result = _.uniq(array, true, listIterator); + result = _.uniq(array, true, listIterator, any); + result = _.uniq(array, listIterator); + result = _.uniq(array, listIterator, any); + result = _.uniq(array, listIterator); + result = _.uniq(array, listIterator, any); + result = _.uniq(array, true, 'a'); + result = _.uniq(array, true, 'a', any); + result = _.uniq(array, 'a'); + result = _.uniq(array, 'a', any); + result = _.uniq(array, true, {a: 42}); + result = _.uniq<{a: number}, SampleObject>(array, true, {a: 42}); + result = _.uniq(array, {a: 42}); + result = _.uniq<{a: number}, SampleObject>(array, {a: 42}); + + result = _.uniq(list); + result = _.uniq(list, true); + result = _.uniq(list, true, listIterator); + result = _.uniq(list, true, listIterator, any); + result = _.uniq(list, true, listIterator); + result = _.uniq(list, true, listIterator, any); + result = _.uniq(list, listIterator); + result = _.uniq(list, listIterator, any); + result = _.uniq(list, listIterator); + result = _.uniq(list, listIterator, any); + result = _.uniq(list, true, 'a'); + result = _.uniq(list, true, 'a', any); + result = _.uniq(list, 'a'); + result = _.uniq(list, 'a', any); + result = _.uniq(list, true, {a: 42}); + result = _.uniq<{a: number}, SampleObject>(list, true, {a: 42}); + result = _.uniq(list, {a: 42}); + result = _.uniq<{a: number}, SampleObject>(list, {a: 42}); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _('abc').uniq(); + result = _('abc').uniq(true); + result = _('abc').uniq(true, stringIterator); + result = _('abc').uniq(true, stringIterator, any); + result = _('abc').uniq(stringIterator); + result = _('abc').uniq(stringIterator, any); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).uniq(); + result = _(array).uniq(true); + result = _(array).uniq(true, listIterator); + result = _(array).uniq(true, listIterator, any); + result = _(array).uniq(listIterator); + result = _(array).uniq(listIterator, any); + result = _(array).uniq(true, 'a'); + result = _(array).uniq(true, 'a', any); + result = _(array).uniq('a'); + result = _(array).uniq('a', any); + result = _(array).uniq<{a: number}>(true, {a: 42}); + result = _(array).uniq<{a: number}>({a: 42}); + + result = _(list).uniq(); + result = _(list).uniq(true); + result = _(list).uniq(true, listIterator); + result = _(list).uniq(true, listIterator, any); + result = _(list).uniq(true, listIterator); + result = _(list).uniq(true, listIterator, any); + result = _(list).uniq(listIterator); + result = _(list).uniq(listIterator, any); + result = _(list).uniq(listIterator); + result = _(list).uniq(listIterator, any); + result = _(list).uniq(true, 'a'); + result = _(list).uniq(true, 'a', any); + result = _(list).uniq('a'); + result = _(list).uniq('a', any); + result = _(list).uniq(true, {a: 42}); + result = _(list).uniq<{a: number}, SampleObject>(true, {a: 42}); + result = _(list).uniq({a: 42}); + result = _(list).uniq<{a: number}, SampleObject>({a: 42}); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _('abc').chain().uniq(); + result = _('abc').chain().uniq(true); + result = _('abc').chain().uniq(true, stringIterator); + result = _('abc').chain().uniq(true, stringIterator, any); + result = _('abc').chain().uniq(stringIterator); + result = _('abc').chain().uniq(stringIterator, any); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().uniq(); + result = _(array).chain().uniq(true); + result = _(array).chain().uniq(true, listIterator); + result = _(array).chain().uniq(true, listIterator, any); + result = _(array).chain().uniq(listIterator); + result = _(array).chain().uniq(listIterator, any); + result = _(array).chain().uniq(true, 'a'); + result = _(array).chain().uniq(true, 'a', any); + result = _(array).chain().uniq('a'); + result = _(array).chain().uniq('a', any); + result = _(array).chain().uniq<{a: number}>(true, {a: 42}); + result = _(array).chain().uniq<{a: number}>({a: 42}); + + result = _(list).chain().uniq(); + result = _(list).chain().uniq(true); + result = _(list).chain().uniq(true, listIterator); + result = _(list).chain().uniq(true, listIterator, any); + result = _(list).chain().uniq(true, listIterator); + result = _(list).chain().uniq(true, listIterator, any); + result = _(list).chain().uniq(listIterator); + result = _(list).chain().uniq(listIterator, any); + result = _(list).chain().uniq(listIterator); + result = _(list).chain().uniq(listIterator, any); + result = _(list).chain().uniq(true, 'a'); + result = _(list).chain().uniq(true, 'a', any); + result = _(list).chain().uniq('a'); + result = _(list).chain().uniq('a', any); + result = _(list).chain().uniq(true, {a: 42}); + result = _(list).chain().uniq<{a: number}, SampleObject>(true, {a: 42}); + result = _(list).chain().uniq({a: 42}); + result = _(list).chain().uniq<{a: number}, SampleObject>({a: 42}); + } +} + +// _.unique +module TestUnique { + type SampleObject = {a: number; b: string; c: boolean}; + + let array: SampleObject[]; + let list: _.List; + + let stringIterator: (value: string, index: number, collection: string) => string; + let listIterator: (value: SampleObject, index: number, collection: _.List) => number; + + { + let result: string[]; + + result = _.unique('abc'); + result = _.unique('abc', true); + result = _.unique('abc', true, stringIterator); + result = _.unique('abc', true, stringIterator, any); + result = _.unique('abc', true, stringIterator); + result = _.unique('abc', true, stringIterator, any); + result = _.unique('abc', stringIterator); + result = _.unique('abc', stringIterator, any); + result = _.unique('abc', stringIterator); + result = _.unique('abc', stringIterator, any); + } + + { + let result: SampleObject[]; + + result = _.unique(array); + result = _.unique(array, true); + result = _.unique(array, true, listIterator); + result = _.unique(array, true, listIterator, any); + result = _.unique(array, true, listIterator); + result = _.unique(array, true, listIterator, any); + result = _.unique(array, listIterator); + result = _.unique(array, listIterator, any); + result = _.unique(array, listIterator); + result = _.unique(array, listIterator, any); + result = _.unique(array, true, 'a'); + result = _.unique(array, true, 'a', any); + result = _.unique(array, 'a'); + result = _.unique(array, 'a', any); + result = _.unique(array, true, {a: 42}); + result = _.unique<{a: number}, SampleObject>(array, true, {a: 42}); + result = _.unique(array, {a: 42}); + result = _.unique<{a: number}, SampleObject>(array, {a: 42}); + + result = _.unique(list); + result = _.unique(list, true); + result = _.unique(list, true, listIterator); + result = _.unique(list, true, listIterator, any); + result = _.unique(list, true, listIterator); + result = _.unique(list, true, listIterator, any); + result = _.unique(list, listIterator); + result = _.unique(list, listIterator, any); + result = _.unique(list, listIterator); + result = _.unique(list, listIterator, any); + result = _.unique(list, true, 'a'); + result = _.unique(list, true, 'a', any); + result = _.unique(list, 'a'); + result = _.unique(list, 'a', any); + result = _.unique(list, true, {a: 42}); + result = _.unique<{a: number}, SampleObject>(list, true, {a: 42}); + result = _.unique(list, {a: 42}); + result = _.unique<{a: number}, SampleObject>(list, {a: 42}); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _('abc').unique(); + result = _('abc').unique(true); + result = _('abc').unique(true, stringIterator); + result = _('abc').unique(true, stringIterator, any); + result = _('abc').unique(stringIterator); + result = _('abc').unique(stringIterator, any); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).unique(); + result = _(array).unique(true); + result = _(array).unique(true, listIterator); + result = _(array).unique(true, listIterator, any); + result = _(array).unique(listIterator); + result = _(array).unique(listIterator, any); + result = _(array).unique(true, 'a'); + result = _(array).unique(true, 'a', any); + result = _(array).unique('a'); + result = _(array).unique('a', any); + result = _(array).unique<{a: number}>(true, {a: 42}); + result = _(array).unique<{a: number}>({a: 42}); + + result = _(list).unique(); + result = _(list).unique(true); + result = _(list).unique(true, listIterator); + result = _(list).unique(true, listIterator, any); + result = _(list).unique(true, listIterator); + result = _(list).unique(true, listIterator, any); + result = _(list).unique(listIterator); + result = _(list).unique(listIterator, any); + result = _(list).unique(listIterator); + result = _(list).unique(listIterator, any); + result = _(list).unique(true, 'a'); + result = _(list).unique(true, 'a', any); + result = _(list).unique('a'); + result = _(list).unique('a', any); + result = _(list).unique(true, {a: 42}); + result = _(list).unique<{a: number}, SampleObject>(true, {a: 42}); + result = _(list).unique({a: 42}); + result = _(list).unique<{a: number}, SampleObject>({a: 42}); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _('abc').chain().unique(); + result = _('abc').chain().unique(true); + result = _('abc').chain().unique(true, stringIterator); + result = _('abc').chain().unique(true, stringIterator, any); + result = _('abc').chain().unique(stringIterator); + result = _('abc').chain().unique(stringIterator, any); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().unique(); + result = _(array).chain().unique(true); + result = _(array).chain().unique(true, listIterator); + result = _(array).chain().unique(true, listIterator, any); + result = _(array).chain().unique(listIterator); + result = _(array).chain().unique(listIterator, any); + result = _(array).chain().unique(true, 'a'); + result = _(array).chain().unique(true, 'a', any); + result = _(array).chain().unique('a'); + result = _(array).chain().unique('a', any); + result = _(array).chain().unique<{a: number}>(true, {a: 42}); + result = _(array).chain().unique<{a: number}>({a: 42}); + + result = _(list).chain().unique(); + result = _(list).chain().unique(true); + result = _(list).chain().unique(true, listIterator); + result = _(list).chain().unique(true, listIterator, any); + result = _(list).chain().unique(true, listIterator); + result = _(list).chain().unique(true, listIterator, any); + result = _(list).chain().unique(listIterator); + result = _(list).chain().unique(listIterator, any); + result = _(list).chain().unique(listIterator); + result = _(list).chain().unique(listIterator, any); + result = _(list).chain().unique(true, 'a'); + result = _(list).chain().unique(true, 'a', any); + result = _(list).chain().unique('a'); + result = _(list).chain().unique('a', any); + result = _(list).chain().unique(true, {a: 42}); + result = _(list).chain().unique<{a: number}, SampleObject>(true, {a: 42}); + result = _(list).chain().unique({a: 42}); + result = _(list).chain().unique<{a: number}, SampleObject>({a: 42}); + } +} // _.upzip module TestUnzip { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 4e86afb66..d53fa00d2 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2837,343 +2837,810 @@ declare module _ { //_.uniq interface LoDashStatic { /** - * Creates a duplicate-value-free version of an array using strict equality for comparisons, - * i.e. ===. If the array is sorted, providing true for isSorted will use a faster algorithm. - * If a callback is provided each element of array is passed through the callback before - * uniqueness is computed. The callback is bound to thisArg and invoked with three arguments; - * (value, index, array). - * - * If a property name is provided for callback the created "_.pluck" style callback will - * return the property value of the given element. - * - * If an object is provided for callback the created "_.where" style callback will return - * true for elements that have the properties of the given object, else false. - * @param array Array to remove duplicates from. - * @param isSorted True if `array` is already sorted, optiona, default = false. - * @param iterator Transform the elements of `array` before comparisons for uniqueness. - * @param context 'this' object in `iterator`, optional. - * @return Copy of `array` where all elements are unique. - **/ - uniq(array: Array, isSorted?: boolean): T[]; - - /** - * @see _.uniq - **/ - uniq(array: List, isSorted?: boolean): T[]; - - /** - * @see _.uniq - **/ - uniq( - array: Array, - isSorted: boolean, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - **/ - uniq( - array: List, - isSorted: boolean, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - **/ - uniq( - array: Array, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - **/ - uniq( - array: List, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - uniq( - array: Array, - isSorted: boolean, - pluckValue: string): T[]; - - /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ + * Creates a duplicate-free version of an array, using SameValueZero for equality comparisons, in which only + * the first occurrence of each element is kept. Providing true for isSorted performs a faster search + * algorithm for sorted arrays. If an iteratee function is provided it’s invoked for each element in the + * array to generate the criterion by which uniqueness is computed. The iteratee is bound to thisArg and + * invoked with three arguments: (value, index, array). + * + * If a property name is provided for iteratee the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for iteratee the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * @alias _.unique + * + * @param array The array to inspect. + * @param isSorted Specify the array is sorted. + * @param iteratee The function invoked per iteration. + * @param thisArg iteratee + * @return Returns the new duplicate-value-free array. + */ uniq( array: List, - isSorted: boolean, - pluckValue: string): T[]; + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): T[]; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - uniq( - array: Array, - pluckValue: string): T[]; + * @see _.uniq + */ + uniq( + array: List, + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): T[]; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ + * @see _.uniq + */ uniq( array: List, - pluckValue: string): T[]; + iteratee?: ListIterator, + thisArg?: any + ): T[]; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( - array: Array, - isSorted: boolean, - whereValue: W): T[]; - - /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( + * @see _.uniq + */ + uniq( array: List, - isSorted: boolean, - whereValue: W): T[]; + iteratee?: ListIterator, + thisArg?: any + ): T[]; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( - array: Array, - whereValue: W): T[]; - - /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( + * @see _.uniq + */ + uniq( array: List, - whereValue: W): T[]; + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): T[]; /** - * @see _.uniq - **/ - unique(array: Array, isSorted?: boolean): T[]; - - /** - * @see _.uniq - **/ - unique(array: List, isSorted?: boolean): T[]; - - /** - * @see _.uniq - **/ - unique( - array: Array, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - **/ - unique( + * @see _.uniq + */ + uniq( array: List, - callback: ListIterator, - thisArg?: any): T[]; + iteratee?: string, + thisArg?: any + ): T[]; /** - * @see _.uniq - **/ - unique( - array: Array, - isSorted: boolean, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - **/ - unique( + * @see _.uniq + */ + uniq( array: List, - isSorted: boolean, - callback: ListIterator, - thisArg?: any): T[]; + isSorted?: boolean, + iteratee?: Object + ): T[]; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique( - array: Array, - isSorted: boolean, - pluckValue: string): T[]; - - /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique( + * @see _.uniq + */ + uniq( array: List, - isSorted: boolean, - pluckValue: string): T[]; + isSorted?: boolean, + iteratee?: TWhere + ): T[]; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique( - array: Array, - pluckValue: string): T[]; - - /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique( + * @see _.uniq + */ + uniq( array: List, - pluckValue: string): T[]; + iteratee?: Object + ): T[]; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - array: Array, - whereValue?: W): T[]; - - /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( + * @see _.uniq + */ + uniq( array: List, - whereValue?: W): T[]; + iteratee?: TWhere + ): T[]; + } + + interface LoDashImplicitWrapper { + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - array: Array, - isSorted: boolean, - whereValue?: W): T[]; - - /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - array: List, - isSorted: boolean, - whereValue?: W): T[]; + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; } interface LoDashImplicitArrayWrapper { /** - * @see _.uniq - **/ - uniq(isSorted?: boolean): LoDashImplicitArrayWrapper; - - /** - * @see _.uniq - **/ + * @see _.uniq + */ uniq( - isSorted: boolean, - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - **/ + * @see _.uniq + */ uniq( - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ + * @see _.uniq + */ uniq( - isSorted: boolean, - pluckValue: string): LoDashImplicitArrayWrapper; + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - uniq(pluckValue: string): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + uniq( + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( - isSorted: boolean, - whereValue: W): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( - whereValue: W): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + uniq( + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - **/ - unique(isSorted?: boolean): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - **/ + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: Object + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: Object + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitWrapper { + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: Object + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: Object + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + } + + //_.unique + interface LoDashStatic { + /** + * @see _.uniq + */ + unique( + array: List, + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + iteratee?: ListIterator, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + iteratee?: ListIterator, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + iteratee?: string, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + isSorted?: boolean, + iteratee?: Object + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + isSorted?: boolean, + iteratee?: TWhere + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + iteratee?: Object + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + iteratee?: TWhere + ): T[]; + } + + interface LoDashImplicitWrapper { + /** + * @see _.uniq + */ unique( - isSorted: boolean, - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - **/ + * @see _.uniq + */ unique( - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ unique( - isSorted: boolean, - pluckValue: string): LoDashImplicitArrayWrapper; + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique(pluckValue: string): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + unique( + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - isSorted: boolean, - whereValue: W): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - whereValue: W): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + unique( + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: Object + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: Object + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitWrapper { + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: Object + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: Object + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; } //_.unzip From 331d30c38ced4d10efb77d67f3afbdab438411ac Mon Sep 17 00:00:00 2001 From: John Grimsey Date: Thu, 17 Dec 2015 11:42:08 +0000 Subject: [PATCH 136/353] Return type fix --- email-addresses/email-addresses.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/email-addresses/email-addresses.d.ts b/email-addresses/email-addresses.d.ts index a0c4ffb2c..c8cd74d1a 100644 --- a/email-addresses/email-addresses.d.ts +++ b/email-addresses/email-addresses.d.ts @@ -4,6 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "email-addresses" { - function parseOneAddress(opts: any): Object; - function parseAddressList(opts: any): Object; + function parseOneAddress(opts: any): any; + function parseAddressList(opts: any): any; } From 4f245aafeb6c138804f25e20b03e10f8f9754038 Mon Sep 17 00:00:00 2001 From: Marcel Ernst Date: Thu, 17 Dec 2015 15:54:50 +0100 Subject: [PATCH 137/353] Fix type for DatePickerProps formatDate --- material-ui/material-ui.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index 2c59d5416..4b46cee7b 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -319,7 +319,7 @@ declare namespace __MaterialUI { interface DatePickerProps extends React.Props { autoOk?: boolean; defaultDate?: Date; - formatDate?: string; + formatDate?: (date:Date) => string; hintText?: string; floatingLabelText?: string; hideToolbarYearChange?: boolean; From 76352a94c6e4a51e7f382aebaf0b63d9ac06ae12 Mon Sep 17 00:00:00 2001 From: cither1 Date: Fri, 18 Dec 2015 00:14:39 +0900 Subject: [PATCH 138/353] Modified a method name. --- onsenui/onsenui-tests.ts | 2 +- onsenui/onsenui.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/onsenui/onsenui-tests.ts b/onsenui/onsenui-tests.ts index 58b72da6e..f0918dc62 100644 --- a/onsenui/onsenui-tests.ts +++ b/onsenui/onsenui-tests.ts @@ -191,7 +191,7 @@ function onsTabbar(tabBar: TabbarView): void { keepPage: true }; tabBar.setActiveTab(2, options); - var activeTab: number = tabBar.getActiveTab(); + var activeTab: number = tabBar.getActiveTabIndex(); tabBar.loadPage('myPage.html'); tabBar.on('eventName', null); tabBar.once('eventName', null); diff --git a/onsenui/onsenui.d.ts b/onsenui/onsenui.d.ts index 287c8e2f5..9eed8c020 100644 --- a/onsenui/onsenui.d.ts +++ b/onsenui/onsenui.d.ts @@ -634,7 +634,7 @@ interface TabbarView { * @return {Number} The index of the currently active tab * @description Returns tab index on current active tab. If active tab is not found, returns -1 */ - getActiveTab(): number; + getActiveTabIndex(): number; /** * @param {String} url Page URL. Can be either an HTML document or an <ons-template> * @description Displays a new page without changing the active index From 34034aaf69c018354769b0cf68d02f51d580920f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alain=20B=C3=A9arez?= Date: Thu, 17 Dec 2015 18:24:38 +0100 Subject: [PATCH 139/353] Add beforeClose option and isOpened() function --- drop/drop.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drop/drop.d.ts b/drop/drop.d.ts index a48cb8fb3..1b994c9a1 100644 --- a/drop/drop.d.ts +++ b/drop/drop.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Drop v0.5.7 +// Type definitions for Drop v1.3.0 // Project: http://github.hubspot.com/drop/ // Definitions by: Adi Dahiya // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -26,6 +26,7 @@ declare module drop { constrainToWindow?: boolean; constrainToScrollParent?: boolean; remove?: boolean; + beforeClose?: () => boolean; tetherOptions?: tether.ITetherOptions; } @@ -37,6 +38,7 @@ declare module drop { close(): void; remove(): void; toggle(): void; + isOpened(): boolean; position(): void; destroy(): void; /* From f83d1a72867c72e1a1b38f11727fed41cb11222e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Dec 2015 10:25:55 -0800 Subject: [PATCH 140/353] 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 eddf870a4..be25d357b 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 3d37bf0c5..7cd51d2be 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; From 5b31421af0081615210b2fda42582c933b484733 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 17 Dec 2015 20:17:01 +0100 Subject: [PATCH 141/353] Add create-error.js, see https://github.com/tgriesser/create-error --- create-error/create-error-tests.ts | 149 +++++++++++++++++++++++++++++ create-error/create-error.d.ts | 21 ++++ 2 files changed, 170 insertions(+) create mode 100644 create-error/create-error-tests.ts create mode 100644 create-error/create-error.d.ts diff --git a/create-error/create-error-tests.ts b/create-error/create-error-tests.ts new file mode 100644 index 000000000..76b66adf2 --- /dev/null +++ b/create-error/create-error-tests.ts @@ -0,0 +1,149 @@ +/// +/// +/// + +import * as createError from 'create-error'; +import * as assert from 'assert'; + +// Example taken from https://github.com/tgriesser/create-error/blob/0.3.1/README.md#use + +interface MyCustomError extends createError.Error { + messages: string[]; + someVal: string; +} +var MyCustomError = createError('MyCustomError'); + +interface SubCustomError extends MyCustomError { +} +var SubCustomError = createError(MyCustomError, 'CoolSubError', {messages: []}); + +var sub = new SubCustomError('My Message', {someVal: 'value'}); + +sub instanceof SubCustomError // true +sub instanceof MyCustomError // true +sub instanceof Error // true + +assert.deepEqual(sub.messages, []) // true +assert.equal(sub.someVal, 'value') // true + + +// Taken and adapted from https://github.com/tgriesser/create-error/blob/0.3.1/test/index.js + +var equal = assert.equal; +var deepEqual = assert.deepEqual; + +describe('create-error', function() { + + describe('error creation', function() { + + it('should create a new error', function() { + var TestingError = createError('TestingError'); + var a = new TestingError('msgA'); + var b = new TestingError('msgB'); + equal((a instanceof TestingError), true); + equal((a instanceof Error), true); + equal(a.message, 'msgA'); + equal(b.message, 'msgB'); + equal((a.stack.length > 0), true); + }); + + it('should attach properties in the second argument', function() { + interface TestingError extends createError.Error { + anArray: string[]; + } + var TestingError = createError('TestingError', {anArray: []}); + var a = new TestingError('Test the array'); + deepEqual(a.anArray, []); + }); + + it('should give the name "CustomError" if the name is omitted', function() { + var TestingError = createError(); + var a = new TestingError("msg"); + equal(a.name, 'CustomError'); + }); + + it('should not reference the same property in subsequent errors', function() { + interface TestingError extends createError.Error { + anArray: string[]; + } + var TestingError = createError('TestingError', {anArray: []}); + var a = new TestingError('Test the array'); + a.anArray.push('a'); + var b = new TestingError(''); + deepEqual(b.anArray, []); + }); + + it('should allow for empty objects on the cloned hash', function() { + interface TestingError extends createError.Error { + anEmptyObj: Object; + } + var TestingError = createError('TestingError', {anEmptyObj: Object.create(null)}); + var a = new TestingError('Test the array'); + deepEqual(a.anEmptyObj, Object.create(null)); + }); + + it('attaches attrs in the second arg of the error ctor, #3', function() { + interface RequestError extends createError.Error { + status: number; + } + var RequestError = createError('RequestError', {status: 400}); + var reqErr = new RequestError('404 Error', {status: 404}); + equal(reqErr.status, 404); + equal(reqErr.message, '404 Error'); + equal(reqErr.name, 'RequestError'); + }); + + }); + + describe('subclassing errors', function() { + + it('takes an object in the first argument', function() { + var TestingError = createError('TestingError'); + var SubTestingError = createError(TestingError, 'SubTestingError'); + var x = new SubTestingError(); + equal((x instanceof SubTestingError), true); + equal((x instanceof TestingError), true); + equal((x instanceof Error), true); + }); + + it('attaches the properties appropriately.', function() { + interface SubTestingError extends createError.Error { + key: string[]; + } + var TestingError = createError('TestingError'); + var SubTestingError = createError(TestingError, 'SubTestingError', {key: []}); + var x = new SubTestingError(); + deepEqual(x.key, []); + }); + + it('allows for a default message, #4', function() { + var TestingError = createError('TestingError', {message: 'Error with testing'}); + var x = new TestingError(); + equal(x.message, 'Error with testing'); + }); + + }); + + describe('invalid values sent to the second argument', function() { + + it('should ignore falsy values', function() { + var TestingError = createError('TestingError', ''); + var TestingError2 = createError('TestingError', null); + var TestingError3 = createError('TestingError', void 0); + var a = new TestingError('Test the array'); + var b = new TestingError2('Test the array'); + var c = new TestingError3('Test the array'); + }); + + it('should ignore arrays', function() { + interface TestingError extends createError.Error { + anArray: string[]; + } + var TestingError = createError('TestingError', [{anArray: []}]); + var a = new TestingError('Test the array'); + equal(a.anArray, void 0); + }); + + }); + +}); diff --git a/create-error/create-error.d.ts b/create-error/create-error.d.ts new file mode 100644 index 000000000..5db02e474 --- /dev/null +++ b/create-error/create-error.d.ts @@ -0,0 +1,21 @@ +// Type definitions for create-error.js 0.3.1 +// Project: https://github.com/tgriesser/create-error +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'create-error' { + // FIXME See Global type references https://github.com/Microsoft/TypeScript/issues/983 + type Err = Error; + + namespace createError { + interface Error extends Err { + new (message?: string, obj?: any): T; + } + } + + function createError(): createError.Error; + function createError>(name: string, properties?: any): T; + function createError>(Target: createError.Error, name?: string, properties?: any): T; + + export = createError; +} From f05f79fd5836003f29930c96f2a3c6e77bfb81df Mon Sep 17 00:00:00 2001 From: Arthur Cinader Date: Thu, 17 Dec 2015 10:34:51 -0800 Subject: [PATCH 142/353] Add remove() to ionic.modal.IonicModalController Per api: http://ionicframework.com/docs/api/controller/ionicModal/ note the note in the ionic source code: "Be sure to call [remove()](#remove) when you are done with each modal to clean it up and avoid memory leaks." https://github.com/driftyco/ionic/blob/af1bfef327e685585244c6051c4d38b98aa6c62a/js/angular/service/modal.js#L87 --- ionic/ionic-tests.ts | 1 + ionic/ionic.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/ionic/ionic-tests.ts b/ionic/ionic-tests.ts index 9c5cfdad0..bad5f9d9f 100644 --- a/ionic/ionic-tests.ts +++ b/ionic/ionic-tests.ts @@ -149,6 +149,7 @@ class IonicTestController { ionicModalController.initialize(modalOptions); ionicModalController.show().then(() => console.log("shown modal")) ionicModalController.hide().then(() => console.log("hid modal")) + ionicModalController.remove().then(() => console.log("removed modal")) var isShown: boolean = ionicModalController.isShown(); this.$ionicModal.fromTemplateUrl("templateUrl", modalOptions) diff --git a/ionic/ionic.d.ts b/ionic/ionic.d.ts index ce097a226..a3781f26d 100644 --- a/ionic/ionic.d.ts +++ b/ionic/ionic.d.ts @@ -174,6 +174,7 @@ declare module ionic { initialize(options: IonicModalOptions): void; show(): ng.IPromise; hide(): ng.IPromise; + remove(): ng.IPromise; isShown(): boolean; } From 742aa93d860391a1cfe03a2338c3dd45f5dd2a26 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Dec 2015 00:31:05 +0500 Subject: [PATCH 143/353] node: signatures of module "events" have been changed --- node/node-tests.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++++ node/node.d.ts | 14 ++++++++++---- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index aa0f55bb6..741dd3f48 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -32,6 +32,54 @@ assert.doesNotThrow(() => { if (false) { throw "a hammer at your face"; } }, undefined, "What the...*crunch*"); +//////////////////////////////////////////////////// +/// Events tests : http://nodejs.org/api/events.html +//////////////////////////////////////////////////// + +module events_tests { + let emitter: events.EventEmitter; + let event: string; + let listener: Function; + let any: any; + + { + let result: events.EventEmitter; + + result = emitter.addListener(event, listener); + result = emitter.on(event, listener); + result = emitter.once(event, listener); + result = emitter.removeListener(event, listener); + result = emitter.removeAllListeners(); + result = emitter.removeAllListeners(event); + result = emitter.setMaxListeners(42); + } + + { + let result: number; + + result = events.EventEmitter.defaultMaxListeners; + result = events.EventEmitter.listenerCount(emitter, event); // deprecated + + result = emitter.getMaxListeners(); + result = emitter.listenerCount(event); + } + + { + let result: Function[]; + + result = emitter.listeners(event); + } + + { + let result: boolean; + + result = emitter.emit(event); + result = emitter.emit(event, any); + result = emitter.emit(event, any, any); + result = emitter.emit(event, any, any, any); + } +} + //////////////////////////////////////////////////// /// File system tests : http://nodejs.org/api/fs.html //////////////////////////////////////////////////// diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..1d5722496 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -173,9 +173,11 @@ declare module NodeJS { once(event: string, listener: Function): EventEmitter; removeListener(event: string, listener: Function): EventEmitter; removeAllListeners(event?: string): EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; } export interface ReadableStream extends EventEmitter { @@ -423,17 +425,21 @@ declare module "querystring" { declare module "events" { export class EventEmitter implements NodeJS.EventEmitter { - static listenerCount(emitter: EventEmitter, event: string): number; + static EventEmitter: EventEmitter; + static listenerCount(emitter: EventEmitter, event: string): number; // deprecated + static defaultMaxListeners: number; addListener(event: string, listener: Function): EventEmitter; on(event: string, listener: Function): EventEmitter; once(event: string, listener: Function): EventEmitter; removeListener(event: string, listener: Function): EventEmitter; removeAllListeners(event?: string): EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; - } + listenerCount(type: string): number; + } } declare module "http" { From f8b59970de238982359ca96a0f7a548dd94b0c74 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Dec 2015 02:25:57 +0500 Subject: [PATCH 144/353] node: implementations of the interface "EventEmitter" in other modules have been fixed --- eventemitter3/eventemitter3-tests.ts | 5 ++++- github-electron/github-electron.d.ts | 28 +++++++++++++++++++------- imap/imap.d.ts | 4 +++- jake/jake.d.ts | 4 +++- mailparser/mailparser.d.ts | 4 +++- pty.js/pty.js.d.ts | 4 +++- steam/steam.d.ts | 4 +++- stylus/stylus.d.ts | 4 +++- yeoman-generator/yeoman-generator.d.ts | 4 +++- 9 files changed, 46 insertions(+), 15 deletions(-) diff --git a/eventemitter3/eventemitter3-tests.ts b/eventemitter3/eventemitter3-tests.ts index 4fa378bc2..49ae0a24d 100644 --- a/eventemitter3/eventemitter3-tests.ts +++ b/eventemitter3/eventemitter3-tests.ts @@ -35,7 +35,10 @@ class EventEmitterTest { constructor() { this.v = new EventEmitter(); this.v = new EventEmitter3ImportedAsES6Module(); - var n: NodeJS.EventEmitter = this.v; + + // Some methods are missing or incompatible with current implementation (v4.2.x) of NodeJS.EventEmitter + // (e.g. getMaxListenters or listeners) + // var n: NodeJS.EventEmitter = this.v; } listeners() { diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index a9b83b7dc..ae59a7538 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -70,9 +70,11 @@ declare module GitHubElectron { once(event: string, listener: Function): Screen; removeListener(event: string, listener: Function): Screen; removeAllListeners(event?: string): Screen; - setMaxListeners(n: number): void; + setMaxListeners(n: number): Screen; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * @returns The current absolute position of the mouse pointer. */ @@ -108,9 +110,11 @@ declare module GitHubElectron { once(event: string, listener: Function): WebContents; removeListener(event: string, listener: Function): WebContents; removeAllListeners(event?: string): WebContents; - setMaxListeners(n: number): void; + setMaxListeners(n: number): WebContents; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; constructor(options?: BrowserWindowOptions); /** * @returns All opened browser windows. @@ -522,9 +526,11 @@ declare module GitHubElectron { once(event: string, listener: Function): WebContents; removeListener(event: string, listener: Function): WebContents; removeAllListeners(event?: string): WebContents; - setMaxListeners(n: number): void; + setMaxListeners(n: number): WebContents; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * Loads the url in the window. * @param url Must contain the protocol prefix (e.g., the http:// or file://). @@ -930,9 +936,11 @@ declare module GitHubElectron { once(event: string, listener: Function): App; removeListener(event: string, listener: Function): App; removeAllListeners(event?: string): App; - setMaxListeners(n: number): void; + setMaxListeners(n: number): App; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * Try to close all windows. The before-quit event will first be emitted. * If all windows are successfully closed, the will-quit event will be emitted @@ -1122,9 +1130,11 @@ declare module GitHubElectron { once(event: string, listener: Function): AutoUpdater; removeListener(event: string, listener: Function): AutoUpdater; removeAllListeners(event?: string): AutoUpdater; - setMaxListeners(n: number): void; + setMaxListeners(n: number): AutoUpdater; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * Set the url and initialize the auto updater. * The url cannot be changed once it is set. @@ -1232,9 +1242,11 @@ declare module GitHubElectron { once(event: string, listener: Function): Tray; removeListener(event: string, listener: Function): Tray; removeAllListeners(event?: string): Tray; - setMaxListeners(n: number): void; + setMaxListeners(n: number): Tray; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * Creates a new tray icon associated with the image. */ @@ -1426,9 +1438,11 @@ declare module GitHubElectron { once(event: string, listener: Function): IpcRenderer; removeListener(event: string, listener: Function): IpcRenderer; removeAllListeners(event?: string): IpcRenderer; - setMaxListeners(n: number): void; + setMaxListeners(n: number): IpcRenderer; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * Send ...args to the renderer via channel in asynchronous message, the main * process can handle it by listening to the channel event of ipc module. diff --git a/imap/imap.d.ts b/imap/imap.d.ts index 105e64c85..4b88279ae 100644 --- a/imap/imap.d.ts +++ b/imap/imap.d.ts @@ -246,9 +246,11 @@ declare module IMAP { once(event: string, listener: Function): this; removeListener(event: string, listener: Function): this; removeAllListeners(event?: string): this; - setMaxListeners(n: number): void; + setMaxListeners(n: number): this; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; // 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. */ diff --git a/jake/jake.d.ts b/jake/jake.d.ts index 95614374c..84d5c5079 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -231,9 +231,11 @@ declare module jake{ once(event: string, listener: Function): NodeJS.EventEmitter; removeListener(event: string, listener: Function): NodeJS.EventEmitter; removeAllListeners(event?: string): NodeJS.EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): NodeJS.EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; value: any; } diff --git a/mailparser/mailparser.d.ts b/mailparser/mailparser.d.ts index 9e67cc78a..b45ce05d9 100644 --- a/mailparser/mailparser.d.ts +++ b/mailparser/mailparser.d.ts @@ -78,9 +78,11 @@ declare module 'mailparser' { once(event: string, listener: Function): EventEmitter; removeListener(event: string, listener: Function): EventEmitter; removeAllListeners(event?: string): EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; } } diff --git a/pty.js/pty.js.d.ts b/pty.js/pty.js.d.ts index 937dff0c0..ab874a574 100644 --- a/pty.js/pty.js.d.ts +++ b/pty.js/pty.js.d.ts @@ -85,9 +85,11 @@ declare module 'pty.js' { removeListener(event: string, listener: Function): NodeJS.EventEmitter; removeAllListeners(event?: string): NodeJS.EventEmitter; // NOTE: this method is not actually defined in pty.js - setMaxListeners(n: number): void; + setMaxListeners(n: number): NodeJS.EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; } /** diff --git a/steam/steam.d.ts b/steam/steam.d.ts index 3f31aef3f..5f9773512 100644 --- a/steam/steam.d.ts +++ b/steam/steam.d.ts @@ -52,9 +52,11 @@ declare module Steam { once(event: string, listener: Function): NodeJS.EventEmitter; removeListener(event: string, listener: Function): NodeJS.EventEmitter; removeAllListeners(event?: string): NodeJS.EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): NodeJS.EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; } } diff --git a/stylus/stylus.d.ts b/stylus/stylus.d.ts index 5809570b9..b0c8db62f 100644 --- a/stylus/stylus.d.ts +++ b/stylus/stylus.d.ts @@ -698,9 +698,11 @@ declare module Stylus { once(event: string, listener: Function): Renderer; removeListener(event: string, listener: Function): Renderer; removeAllListeners(event?: string): Renderer; - setMaxListeners(n: number): void; + setMaxListeners(n: number): Renderer; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; //#endregion } diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 4ccd98e44..760450952 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -42,9 +42,11 @@ declare module yo { once(event: string, listener: Function): NodeJS.EventEmitter; removeListener(event: string, listener: Function): NodeJS.EventEmitter; removeAllListeners(event?: string): NodeJS.EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): NodeJS.EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; async(): any; prompt(opt?:IPromptOptions, callback?:(answers:any)=>void) :void; From a78ed230cdd65f906696480288b7350ffdb1332e Mon Sep 17 00:00:00 2001 From: patrick-mackay Date: Thu, 17 Dec 2015 20:04:14 -0300 Subject: [PATCH 145/353] New definition for ngWYSIWYG Interface definitions for an AngularJS wysiwyg component, developed by https://github.com/psergus. I'm not sure what kind of tests can be created for interface definitions. Let me know if more is needed. --- ngwysiwyg/ngwysiwyg-tests.ts | 16 ++++++++++++++++ ngwysiwyg/ngwysiwyg.d.ts | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 ngwysiwyg/ngwysiwyg-tests.ts create mode 100644 ngwysiwyg/ngwysiwyg.d.ts diff --git a/ngwysiwyg/ngwysiwyg-tests.ts b/ngwysiwyg/ngwysiwyg-tests.ts new file mode 100644 index 000000000..92f33c87f --- /dev/null +++ b/ngwysiwyg/ngwysiwyg-tests.ts @@ -0,0 +1,16 @@ +/// + +//import ngWYSIWYG = require("ngWYSIWYG"); + +var options: ngWYSIWYGConfig = { + sanitize: false, + toolbar: [ + { name: "basicStyling", items: ["bold", "italic", "underline", "strikethrough", "subscript", "superscript", "-", "leftAlign", "centerAlign", "rightAlign", "blockJustify", "-"] }, + { name: "paragraph", items: ["orderedList", "unorderedList", "outdent", "indent", "-"] }, + { name: "doers", items: ["removeFormatting", "undo", "redo", "-"] }, + { name: "colors", items: ["fontColor", "backgroundColor", "-"] }, + { name: "links", items: ["image", "hr", "symbols", "link", "unlink", "-"] }, + { name: "tools", items: ["print", "-"] }, + { name: "styling", items: ["font", "size", "format"] }, + ] +}; diff --git a/ngwysiwyg/ngwysiwyg.d.ts b/ngwysiwyg/ngwysiwyg.d.ts new file mode 100644 index 000000000..0289df60e --- /dev/null +++ b/ngwysiwyg/ngwysiwyg.d.ts @@ -0,0 +1,14 @@ +// Type definitions for Marked +// Project: https://github.com/psergus/ngWYSIWYG +// Definitions by: Patrick Mac Kay +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface ngWYSIWYGToolbar { + name: string; + items: string[]; +} + +interface ngWYSIWYGConfig { + sanitize: boolean; + toolbar: ngWYSIWYGToolbar[] +} From 7ca98f443216e1de7fca8d49f2602e1b6b7affbb Mon Sep 17 00:00:00 2001 From: patrick-mackay Date: Thu, 17 Dec 2015 20:36:32 -0300 Subject: [PATCH 146/353] Organization and minor fix Added a module to organize the interfaces. Fix a problem with an optional parameter. Previously was marked as required. --- ngwysiwyg/ngwysiwyg-tests.ts | 6 +++++- ngwysiwyg/ngwysiwyg.d.ts | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ngwysiwyg/ngwysiwyg-tests.ts b/ngwysiwyg/ngwysiwyg-tests.ts index 92f33c87f..c779e918e 100644 --- a/ngwysiwyg/ngwysiwyg-tests.ts +++ b/ngwysiwyg/ngwysiwyg-tests.ts @@ -2,7 +2,7 @@ //import ngWYSIWYG = require("ngWYSIWYG"); -var options: ngWYSIWYGConfig = { +var complete: ngWYSIWYG.Config = { sanitize: false, toolbar: [ { name: "basicStyling", items: ["bold", "italic", "underline", "strikethrough", "subscript", "superscript", "-", "leftAlign", "centerAlign", "rightAlign", "blockJustify", "-"] }, @@ -14,3 +14,7 @@ var options: ngWYSIWYGConfig = { { name: "styling", items: ["font", "size", "format"] }, ] }; + +var partial: ngWYSIWYG.Config = { + sanitize: false +}; diff --git a/ngwysiwyg/ngwysiwyg.d.ts b/ngwysiwyg/ngwysiwyg.d.ts index 0289df60e..9f5ba18ca 100644 --- a/ngwysiwyg/ngwysiwyg.d.ts +++ b/ngwysiwyg/ngwysiwyg.d.ts @@ -3,12 +3,14 @@ // Definitions by: Patrick Mac Kay // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface ngWYSIWYGToolbar { - name: string; - items: string[]; -} +declare module ngWYSIWYG { + export interface Toolbar { + name: string; + items: string[]; + } -interface ngWYSIWYGConfig { - sanitize: boolean; - toolbar: ngWYSIWYGToolbar[] -} + export interface Config { + sanitize: boolean; + toolbar?: Toolbar[]; + } +} \ No newline at end of file From d2dd0dbfc70f5bd50aab635156620b3a2578a48d Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 18 Dec 2015 05:09:35 +0100 Subject: [PATCH 147/353] Improve jasmine.d.ts - Remove toContainHtml() and toContainText(): they are not part of Jasmine API - Avoid the use of any for toMatch(), toBeLessThan(), toBeGreaterThan(), toBeCloseTo() and toThrowError() --- jasmine-jquery/jasmine-jquery.d.ts | 8 ++++---- jasmine/jasmine.d.ts | 13 ++++++------- knockout/tests/jasmine.extensions.d.ts | 10 ++++++++++ .../tests/knockout-templatingBehaviors-tests.ts | 1 + 4 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 knockout/tests/jasmine.extensions.d.ts diff --git a/jasmine-jquery/jasmine-jquery.d.ts b/jasmine-jquery/jasmine-jquery.d.ts index 903e3f7e2..0e1f2b82b 100644 --- a/jasmine-jquery/jasmine-jquery.d.ts +++ b/jasmine-jquery/jasmine-jquery.d.ts @@ -195,8 +195,8 @@ declare module jasmine { * // returns true * expect($('

    header

    ')).toContainHtml('
      ') */ - //toContainHtml(html: string): boolean; - + toContainHtml(html: string): boolean; + /** * Check if DOM element has the given Text. * @param text Accepts a string or regular expression @@ -213,8 +213,8 @@ declare module jasmine { * // returns true * expect($('

        header

        ')).toContainText('header') */ - //toContainText(text: string): boolean; - + toContainText(text: string): boolean; + /** * Check if DOM element has the given value. * This can only be applied for element on with jQuery val() can be called. diff --git a/jasmine/jasmine.d.ts b/jasmine/jasmine.d.ts index ed8591488..46a1937f4 100644 --- a/jasmine/jasmine.d.ts +++ b/jasmine/jasmine.d.ts @@ -281,7 +281,7 @@ declare module jasmine { toBe(expected: any, expectationFailOutput?: any): boolean; toEqual(expected: any, expectationFailOutput?: any): boolean; - toMatch(expected: any, expectationFailOutput?: any): boolean; + toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean; toBeDefined(expectationFailOutput?: any): boolean; toBeUndefined(expectationFailOutput?: any): boolean; toBeNull(expectationFailOutput?: any): boolean; @@ -291,13 +291,12 @@ declare module jasmine { toHaveBeenCalled(): boolean; toHaveBeenCalledWith(...params: any[]): boolean; toContain(expected: any, expectationFailOutput?: any): boolean; - toBeLessThan(expected: any, expectationFailOutput?: any): boolean; - toBeGreaterThan(expected: any, expectationFailOutput?: any): boolean; - toBeCloseTo(expected: any, precision: any, expectationFailOutput?: any): boolean; - toContainHtml(expected: string): boolean; - toContainText(expected: string): boolean; + toBeLessThan(expected: number, expectationFailOutput?: any): boolean; + toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean; + toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean; toThrow(expected?: any): boolean; - toThrowError(expected?: any, message?: string): boolean; + toThrowError(message?: string | RegExp): boolean; + toThrowError(expected?: Error, message?: string | RegExp): boolean; not: Matchers; Any: Any; diff --git a/knockout/tests/jasmine.extensions.d.ts b/knockout/tests/jasmine.extensions.d.ts new file mode 100644 index 000000000..c3b12213f --- /dev/null +++ b/knockout/tests/jasmine.extensions.d.ts @@ -0,0 +1,10 @@ +// Knockout specs depend on custom Jasmine matchers +// See https://github.com/knockout/knockout/blob/v3.4.0/spec/lib/jasmine.extensions.js +// FYI jasmine-jquery.d.ts (https://github.com/velesin/jasmine-jquery) also defines toContainHtml() and toContainText() + +declare module jasmine { + interface Matchers { + toContainHtml(expected: string): boolean; + toContainText(expected: string): boolean; + } +} diff --git a/knockout/tests/knockout-templatingBehaviors-tests.ts b/knockout/tests/knockout-templatingBehaviors-tests.ts index 50ec27572..cd86465b2 100644 --- a/knockout/tests/knockout-templatingBehaviors-tests.ts +++ b/knockout/tests/knockout-templatingBehaviors-tests.ts @@ -1,4 +1,5 @@ /// +/// /// /// From 35801ddb4a4f058eb1611164b91d053993bb175e Mon Sep 17 00:00:00 2001 From: PSHollenberg Date: Fri, 18 Dec 2015 13:26:00 +0100 Subject: [PATCH 148/353] Missing axisOptions mode and monthNames --- flot/jquery.flot.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flot/jquery.flot.d.ts b/flot/jquery.flot.d.ts index 027330eee..c45558b87 100644 --- a/flot/jquery.flot.d.ts +++ b/flot/jquery.flot.d.ts @@ -92,6 +92,8 @@ declare module jquery.flot { interface axisOptions { show?: boolean; // null or true/false position?: string; // "bottom" or "top" or "left" or "right" + mode?: string; // "time" + monthNames?: string[]; // array of month names color?: any; // null or color spec tickColor?: any; // null or color spec From fec3ea4268b1853f2555f9a018593a79eb9229c5 Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Fri, 18 Dec 2015 13:28:36 +0100 Subject: [PATCH 149/353] Add some missing yeoman methods and fix some wrong ones --- yeoman-generator/yeoman-generator.d.ts | 36 ++++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 4ccd98e44..8ebc4da89 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -28,6 +28,7 @@ declare module yo { composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; defaultFor(name: string): void; destinationRoot(rootPath: string): string; + destinationPath(file: string): string; determineAppname(): void; getCollisionFilter(): (output: any) => void; hookFor(name: string, config: IHookConfig): void; @@ -37,6 +38,7 @@ declare module yo { run(args: any, callback?: Function): void; runHooks(callback?: Function): void; sourceRoot(rootPath: string): string; + templatePath(file: string): string; addListener(event: string, listener: Function): NodeJS.EventEmitter; on(event: string, listener: Function): NodeJS.EventEmitter; once(event: string, listener: Function): NodeJS.EventEmitter; @@ -49,18 +51,30 @@ declare module yo { async(): any; prompt(opt?:IPromptOptions, callback?:(answers:any)=>void) :void; log(message: string) : void; - npmInstall(packages: string[], options?:any) :void; + npmInstall(packages: string[], options?: any, cb?: Function) :void; + installDependencies(): void; + spawnCommand(name: string, args?: string[]): void; appname: string; gruntfile: IGruntFileStatic; + options: { [key: string]: any }; } + + export interface IChoice { + name: string; + value: string; + short?: string; + } + export interface IPromptOptions{ - type:string; - name:string; - message:string; - default:string; + type: string; + name: string; + message: string; + choices?: string[] | Function | IChoice[]; + default?: string; + store?: boolean; } - + export interface IGruntFileStatic { loadNpmTasks(pluginName: string): void; insertConfig(name:string, config:any):void; @@ -70,11 +84,11 @@ declare module yo { } export interface IArgumentConfig { - desc: string; - required: boolean; - optional: boolean; - type: any; - defaults: any; + desc?: string; + required?: boolean; + optional?: boolean; + type?: any; + defaults?: any; } export interface IComposeSetting { From 818e6cf2ff8a7b0458fd9f50054ffb37778a93ed Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Fri, 18 Dec 2015 15:07:14 +0100 Subject: [PATCH 150/353] More typing corrections and added tests --- yeoman-generator/yeoman-generator-tests.ts | 64 ++++++++++++++++++++++ yeoman-generator/yeoman-generator.d.ts | 43 ++++++++++----- 2 files changed, 94 insertions(+), 13 deletions(-) diff --git a/yeoman-generator/yeoman-generator-tests.ts b/yeoman-generator/yeoman-generator-tests.ts index 84f007206..f72dff4e3 100644 --- a/yeoman-generator/yeoman-generator-tests.ts +++ b/yeoman-generator/yeoman-generator-tests.ts @@ -112,3 +112,67 @@ runContext.inDir('dirPath') .withGenerators(['deps', 'deps']) .withOptions('opts') .withPrompts('answers'); + +// http://yeoman.io/generator/Base.html#destinationPath +generator.destinationPath() === 'string'; +generator.destinationPath('path1') === 'string'; +generator.destinationPath('path1', 'path2') === 'string'; +generator.destinationPath('path1', 'path2', 'path3') === 'string'; + +// http://yeoman.io/generator/Base.html#templatePath +generator.templatePath() === 'string'; +generator.templatePath('path1') === 'string'; +generator.templatePath('path1', 'path2') === 'string'; +generator.templatePath('path1', 'path2', 'path3') === 'string'; + +// http://yeoman.io/generator/Base.html#npmInstall +generator.npmInstall(); +generator.npmInstall('pkg'); +generator.npmInstall([ 'pkg1', 'pkg2' ]); +generator.npmInstall('pkg', {}); +generator.npmInstall('pkg', {}, () => {}); + +// http://yeoman.io/generator/Base.html#installDependencies +generator.installDependencies(); +generator.installDependencies({}); +generator.installDependencies({ npm: true }); +generator.installDependencies({ bower: true }); +generator.installDependencies({ skipMessage: true }); +generator.installDependencies({ callback: () => {} }); + +// http://yeoman.io/generator/Base.html#spawnCommand +generator.spawnCommand('command', []); +generator.spawnCommand('command', [ '-arg' ]); +generator.spawnCommand('command', [], {}); + +// http://yeoman.io/generator/Base.html#spawnCommandSync +generator.spawnCommandSync('command', []); +generator.spawnCommandSync('command', [ '-arg' ]); +generator.spawnCommandSync('command', [], {}); + +// http://yeoman.io/generator/Base.html#option +generator.options['opt'] === 'string'; + +// http://yeoman.io/generator/Base.html#prompt +// https://github.com/SBoudrias/Inquirer.js +generator.prompt({ name: 'Name', message: 'Message' }, (answer) => {}); +generator.prompt({ name: 'Name', message: (answers) => 'Message' }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', choices: [ 'c1', 'c2' ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', choices: [ { name: 'Choice 1', value: 'c1' } ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', choices: (answers) => [ 'c1', 'c2' ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', choices: (answers) => [ { name: 'Choice 1', value: 'c1' } ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', choices: (answers) => [ { name: 'Choice 1', value: 'c1', short: '1' } ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: 'string' }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: 10 }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: [ 'string' ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: [ 10 ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: (answers) => [ 'string' ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: (answers) => [ 10 ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: (answers) => 'string' }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: (answers) => 10 }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', type: "list" }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', validate: (input) => true }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', validate: (input) => "Error" }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', filter: (input) => input }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', when: (answers) => true }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', when: true }, (answer) => {}); diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 8ebc4da89..b73037ea5 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -10,6 +10,7 @@ declare module yo { composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; defaultFor(name: string): void; destinationRoot(rootPath: string): string; + destinationPath(...path: string[]): string; determineAppname(): void; getCollisionFilter(): (output: any) => void; hookFor(name: string, config: IHookConfig): void; @@ -19,8 +20,13 @@ declare module yo { run(args: any, callback?: Function): void; runHooks(callback?: Function): void; sourceRoot(rootPath: string): string; - - + templatePath(...path: string[]): string; + prompt(opt: IPromptOptions | IPromptOptions[], callback: (answers: any) => void): void; + npmInstall(packages?: string[] | string, options?: any, cb?: Function): void; + installDependencies(options?: IInstallDependencyOptions): void; + spawnCommand(name: string, args?: string[], options?: Object): void; + spawnCommandSync(name: string, args?: string[], options?: Object): void; + options: { [key: string]: any }; } export class YeomanGeneratorBase implements IYeomanGenerator, NodeJS.EventEmitter { @@ -28,7 +34,7 @@ declare module yo { composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; defaultFor(name: string): void; destinationRoot(rootPath: string): string; - destinationPath(file: string): string; + destinationPath(...path: string[]): string; determineAppname(): void; getCollisionFilter(): (output: any) => void; hookFor(name: string, config: IHookConfig): void; @@ -38,7 +44,7 @@ declare module yo { run(args: any, callback?: Function): void; runHooks(callback?: Function): void; sourceRoot(rootPath: string): string; - templatePath(file: string): string; + templatePath(...path: string[]): string; addListener(event: string, listener: Function): NodeJS.EventEmitter; on(event: string, listener: Function): NodeJS.EventEmitter; once(event: string, listener: Function): NodeJS.EventEmitter; @@ -49,17 +55,25 @@ declare module yo { emit(event: string, ...args: any[]): boolean; async(): any; - prompt(opt?:IPromptOptions, callback?:(answers:any)=>void) :void; + prompt(opt: IPromptOptions | IPromptOptions[], callback: (answers: any) => void): void; log(message: string) : void; npmInstall(packages: string[], options?: any, cb?: Function) :void; - installDependencies(): void; - spawnCommand(name: string, args?: string[]): void; + installDependencies(options?: IInstallDependencyOptions): void; + spawnCommand(name: string, args?: string[], options?: Object): void; + spawnCommandSync(name: string, args?: string[], options?: Object): void; appname: string; gruntfile: IGruntFileStatic; options: { [key: string]: any }; } + export interface IInstallDependencyOptions { + npm?: boolean; + bower?: boolean; + skipMessage?: boolean; + callback?: Function; + } + export interface IChoice { name: string; value: string; @@ -67,11 +81,14 @@ declare module yo { } export interface IPromptOptions{ - type: string; + type?: string; name: string; - message: string; - choices?: string[] | Function | IChoice[]; - default?: string; + message: string | ((answers: Object) => string); + choices?: string[] | IChoice[] | ((answers: Object) => (string[] | IChoice[])); + default?: string | number | string[] | number[] | ((answers: Object) => (string | number | string[] | number[])); + validate?: ((input: any) => boolean | string); + filter?: ((input: any) => any); + when?: ((answers: Object) => boolean) | boolean; store?: boolean; } @@ -84,10 +101,10 @@ declare module yo { } export interface IArgumentConfig { - desc?: string; + desc: string; required?: boolean; optional?: boolean; - type?: any; + type: any; defaults?: any; } From 185f8c594d8517f3ed7390c04a20ac5271071e1c Mon Sep 17 00:00:00 2001 From: Marian Palkus Date: Thu, 17 Dec 2015 12:39:09 +0100 Subject: [PATCH 151/353] Added type definitions for enzyme. --- enzyme/enzyme-tests.tsx | 574 ++++++++++++++++++++++++++++++++++++++++ enzyme/enzyme.d.ts | 340 ++++++++++++++++++++++++ 2 files changed, 914 insertions(+) create mode 100644 enzyme/enzyme-tests.tsx create mode 100644 enzyme/enzyme.d.ts diff --git a/enzyme/enzyme-tests.tsx b/enzyme/enzyme-tests.tsx new file mode 100644 index 000000000..71e82351f --- /dev/null +++ b/enzyme/enzyme-tests.tsx @@ -0,0 +1,574 @@ +/// +/// + +import { shallow, mount, render, describeWithDOM, spyLifecycle } from "enzyme"; +import * as React from "react"; +import {Component, ReactElement} from "react"; +import {ShallowWrapper, ReactWrapper, CheerioWrapper} from "enzyme"; + + +// Help classes/interfaces +interface MyComponentProps { + propsProperty: any; +} + +interface MyComponentState { + stateProperty: any; +} + +class MyComponent extends Component { + setState(...args: any[]) { + } +} + +// API +module SpyLifecycleTest { + spyLifecycle(MyComponent); +} + +// ShallowWrapper +module ShallowWrapperTest { + var shallowWrapper: ShallowWrapper = + shallow(); + + var reactElement: ReactElement, + objectVal: Object, + boolVal: Boolean, + stringVal: String; + + function test_find() { + shallowWrapper = shallowWrapper.find('.selector'); + shallowWrapper = shallowWrapper.find(MyComponent); + } + + function test_findWhere() { + shallowWrapper = + shallowWrapper.findWhere((aShallowWrapper: ShallowWrapper) => true); + } + + function test_filter() { + shallowWrapper = shallowWrapper.filter('.selector'); + shallowWrapper = shallowWrapper.filter(MyComponent); + } + + function test_filterWhere() { + shallowWrapper = + shallowWrapper.filterWhere((aShallowWrapper: ShallowWrapper) => true); + } + + function test_contains() { + boolVal = shallowWrapper.contains(
        ); + } + + function test_hasClass() { + boolVal = shallowWrapper.find('.my-button').hasClass('disabled'); + } + + function test_is() { + boolVal = shallowWrapper.is('.some-class'); + } + + function test_not() { + shallowWrapper = shallowWrapper.find('.foo').not('.bar'); + } + + function test_children() { + shallowWrapper = shallowWrapper.children(); + } + + function test_parents() { + shallowWrapper = shallowWrapper.parents(); + } + + function test_parent() { + shallowWrapper = shallowWrapper.parent(); + } + + function test_closest() { + shallowWrapper = shallowWrapper.closest('.selector'); + shallowWrapper = shallowWrapper.closest(MyComponent); + } + + function test_shallow() { + shallowWrapper = shallowWrapper.shallow(); + } + + function test_render() { + var cheerioWrapper: CheerioWrapper = shallowWrapper.render(); + } + + function test_text() { + stringVal = shallowWrapper.text(); + } + + + function test_html() { + stringVal = shallowWrapper.html(); + } + + function test_get() { + reactElement = shallowWrapper.get(1); + } + + function test_at() { + shallowWrapper = shallowWrapper.at(1); + } + + function test_first() { + shallowWrapper = shallowWrapper.first(); + } + + function test_last() { + shallowWrapper = shallowWrapper.last(); + } + + function test_state() { + shallowWrapper.state(); + shallowWrapper.state('key'); + } + + function test_props() { + objectVal = shallowWrapper.props(); + } + + function test_prop() { + shallowWrapper.prop('key'); + } + + + function test_simulate(...args: any[]) { + shallowWrapper.simulate('click'); + shallowWrapper.simulate('click', args); + } + + function test_setState() { + shallowWrapper = shallowWrapper.setState({stateProperty: 'state'}); + } + + function test_setProps() { + shallowWrapper = shallowWrapper.setProps({propsProperty: 'foo'}); + } + + function test_setContext() { + shallowWrapper = shallowWrapper.setContext({name: 'baz'}); + } + + function test_instance() { + var myComponent: MyComponent = shallowWrapper.instance(); + } + + function test_update() { + shallowWrapper = shallowWrapper.update(); + } + + function test_debug() { + stringVal = shallowWrapper.debug(); + } + + function test_type() { + var stringOrFunction: String|Function = shallowWrapper.type(); + } + + function test_forEach() { + shallowWrapper = + shallowWrapper.forEach((aShallowWrapper: ShallowWrapper)=> { + }); + } + + function test_map() { + var arrayVal: Array = + shallowWrapper.map((aShallowWrapper: ShallowWrapper)=> { + }); + } + + function test_reduce() { + const total: number[] = + shallowWrapper.reduce( + (amount: number, n: ShallowWrapper) => amount + n.prop('amount') + ); + } + + function test_reduceRight() { + const total: number[] = + shallowWrapper.reduceRight( + (amount: number, n: ShallowWrapper) => amount + n.prop('amount') + ); + } + + function test_some() { + boolVal = shallowWrapper.some('.selector'); + boolVal = shallowWrapper.some(MyComponent); + } + + function test_someWhere() { + boolVal = shallowWrapper.someWhere((aShallowWrapper: ShallowWrapper) => true); + } + + function test_every() { + boolVal = shallowWrapper.every('.selector'); + boolVal = shallowWrapper.every(MyComponent); + } + + function test_everyWhere() { + boolVal = shallowWrapper.everyWhere((aShallowWrapper: ShallowWrapper) => true); + } +} + + +// ReactWrapper +module ReactWrapperTest { + var reactWrapper: ReactWrapper = + mount(); + + var reactElement: ReactElement, + objectVal: Object, + boolVal: Boolean, + stringVal: String; + + function test_find() { + reactWrapper = reactWrapper.find('.selector'); + reactWrapper = reactWrapper.find(MyComponent); + } + + function test_findWhere() { + reactWrapper = + reactWrapper.findWhere((aReactWrapper: ReactWrapper) => true); + } + + function test_filter() { + reactWrapper = reactWrapper.filter('.selector'); + reactWrapper = reactWrapper.filter(MyComponent); + } + + function test_filterWhere() { + reactWrapper = + reactWrapper.filterWhere((aReactWrapper: ReactWrapper) => true); + } + + function test_contains() { + boolVal = reactWrapper.contains(
        ); + } + + function test_hasClass() { + boolVal = reactWrapper.find('.my-button').hasClass('disabled'); + } + + function test_is() { + boolVal = reactWrapper.is('.some-class'); + } + + function test_not() { + reactWrapper = reactWrapper.find('.foo').not('.bar'); + } + + function test_children() { + reactWrapper = reactWrapper.children(); + } + + function test_parents() { + reactWrapper = reactWrapper.parents(); + } + + function test_parent() { + reactWrapper = reactWrapper.parent(); + } + + function test_closest() { + reactWrapper = reactWrapper.closest('.selector'); + reactWrapper = reactWrapper.closest(MyComponent); + } + + function test_text() { + stringVal = reactWrapper.text(); + } + + function test_html() { + stringVal = reactWrapper.html(); + } + + function test_get() { + reactElement = reactWrapper.get(1); + } + + function test_at() { + reactWrapper = reactWrapper.at(1); + } + + function test_first() { + reactWrapper = reactWrapper.first(); + } + + function test_last() { + reactWrapper = reactWrapper.last(); + } + + function test_state() { + reactWrapper.state(); + reactWrapper.state('key'); + } + + function test_props() { + objectVal = reactWrapper.props(); + } + + function test_prop() { + reactWrapper.prop('key'); + } + + + function test_simulate(...args: any[]) { + reactWrapper.simulate('click'); + reactWrapper.simulate('click', args); + } + + function test_setState() { + reactWrapper = reactWrapper.setState({stateProperty: 'state'}); + } + + function test_setProps() { + reactWrapper = reactWrapper.setProps({propsProperty: 'foo'}); + } + + function test_setContext() { + reactWrapper = reactWrapper.setContext({name: 'baz'}); + } + + function test_instance() { + var myComponent: MyComponent = reactWrapper.instance(); + } + + function test_update() { + reactWrapper = reactWrapper.update(); + } + + function test_debug() { + stringVal = reactWrapper.debug(); + } + + function test_type() { + var stringOrFunction: String|Function = reactWrapper.type(); + } + + function test_forEach() { + reactWrapper = + reactWrapper.forEach((aReactWrapper: ReactWrapper)=> { + }); + } + + function test_map() { + var arrayVal: Array = + reactWrapper.map((aReactWrapper: ReactWrapper)=> { + }); + } + + function test_reduce() { + const total: number[] = + reactWrapper.reduce( + (amount: number, n: ReactWrapper) => amount + n.prop('amount') + ); + } + + function test_reduceRight() { + const total: number[] = + reactWrapper.reduceRight( + (amount: number, n: ReactWrapper) => amount + n.prop('amount') + ); + } + + function test_some() { + boolVal = reactWrapper.some('.selector'); + boolVal = reactWrapper.some(MyComponent); + } + + function test_someWhere() { + boolVal = reactWrapper.someWhere((aReactWrapper: ReactWrapper) => true); + } + + function test_every() { + boolVal = reactWrapper.every('.selector'); + boolVal = reactWrapper.every(MyComponent); + } + + function test_everyWhere() { + boolVal = reactWrapper.everyWhere((aReactWrapper: ReactWrapper) => true); + } +} + +// CheerioWrapper +module CheerioWrapperTest { + var cheerioWrapper: CheerioWrapper = + render(); + + var reactElement: ReactElement, + objectVal: Object, + boolVal: Boolean, + stringVal: String; + + function test_find() { + cheerioWrapper = cheerioWrapper.find('.selector'); + cheerioWrapper = cheerioWrapper.find(MyComponent); + } + + function test_findWhere() { + cheerioWrapper = + cheerioWrapper.findWhere((aCheerioWrapper: CheerioWrapper) => true); + } + + function test_filter() { + cheerioWrapper = cheerioWrapper.filter('.selector'); + cheerioWrapper = cheerioWrapper.filter(MyComponent); + } + + function test_filterWhere() { + cheerioWrapper = + cheerioWrapper.filterWhere((aCheerioWrapper: CheerioWrapper) => true); + } + + function test_contains() { + boolVal = cheerioWrapper.contains(
        ); + } + + function test_hasClass() { + boolVal = cheerioWrapper.find('.my-button').hasClass('disabled'); + } + + function test_is() { + boolVal = cheerioWrapper.is('.some-class'); + } + + function test_not() { + cheerioWrapper = cheerioWrapper.find('.foo').not('.bar'); + } + + function test_children() { + cheerioWrapper = cheerioWrapper.children(); + } + + function test_parents() { + cheerioWrapper = cheerioWrapper.parents(); + } + + function test_parent() { + cheerioWrapper = cheerioWrapper.parent(); + } + + function test_closest() { + cheerioWrapper = cheerioWrapper.closest('.selector'); + cheerioWrapper = cheerioWrapper.closest(MyComponent); + } + + function test_text() { + stringVal = cheerioWrapper.text(); + } + + function test_html() { + stringVal = cheerioWrapper.html(); + } + + function test_get() { + reactElement = cheerioWrapper.get(1); + } + + function test_at() { + cheerioWrapper = cheerioWrapper.at(1); + } + + function test_first() { + cheerioWrapper = cheerioWrapper.first(); + } + + function test_last() { + cheerioWrapper = cheerioWrapper.last(); + } + + function test_state() { + cheerioWrapper.state(); + cheerioWrapper.state('key'); + } + + function test_props() { + objectVal = cheerioWrapper.props(); + } + + function test_prop() { + cheerioWrapper.prop('key'); + } + + + function test_simulate(...args: any[]) { + cheerioWrapper.simulate('click'); + cheerioWrapper.simulate('click', args); + } + + function test_setState() { + cheerioWrapper = cheerioWrapper.setState({stateProperty: 'state'}); + } + + function test_setProps() { + cheerioWrapper = cheerioWrapper.setProps({propsProperty: 'foo'}); + } + + function test_setContext() { + cheerioWrapper = cheerioWrapper.setContext({name: 'baz'}); + } + + function test_instance() { + var myComponent: MyComponent = cheerioWrapper.instance(); + } + + function test_update() { + cheerioWrapper = cheerioWrapper.update(); + } + + function test_debug() { + stringVal = cheerioWrapper.debug(); + } + + function test_type() { + var stringOrFunction: String|Function = cheerioWrapper.type(); + } + + function test_forEach() { + cheerioWrapper = + cheerioWrapper.forEach((aCheerioWrapper: CheerioWrapper)=> { + }); + } + + function test_map() { + var arrayVal: Array = + cheerioWrapper.map((aCheerioWrapper: CheerioWrapper)=> { + }); + } + + function test_reduce() { + const total: number[] = + cheerioWrapper.reduce( + (amount: number, n: CheerioWrapper) => amount + n.prop('amount') + ); + } + + function test_reduceRight() { + const total: number[] = + cheerioWrapper.reduceRight( + (amount: number, n: CheerioWrapper) => amount + n.prop('amount') + ); + } + + function test_some() { + boolVal = cheerioWrapper.some('.selector'); + boolVal = cheerioWrapper.some(MyComponent); + } + + function test_someWhere() { + boolVal = cheerioWrapper.someWhere((aCheerioWrapper: CheerioWrapper) => true); + } + + function test_every() { + boolVal = cheerioWrapper.every('.selector'); + boolVal = cheerioWrapper.every(MyComponent); + } + + function test_everyWhere() { + boolVal = cheerioWrapper.everyWhere((aCheerioWrapper: CheerioWrapper) => true); + } +} diff --git a/enzyme/enzyme.d.ts b/enzyme/enzyme.d.ts new file mode 100644 index 000000000..dd0c996a7 --- /dev/null +++ b/enzyme/enzyme.d.ts @@ -0,0 +1,340 @@ +// Type definitions for Enzyme v1.2.0 +// Project: https://github.com/airbnb/enzyme +// Definitions by: Marian Palkus , Cap3 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "enzyme" { + + import {ReactElement, Component} from "react"; + + export class ElementClass extends Component { + } + + /** + * Many methods in Enzyme's API accept a selector as an argument. Selectors in Enzyme can fall into one of the + * following three categories: + * + * 1. A Valid CSS Selector + * 2. A React Component Constructor + * 3. A React Component's displayName + */ + export type EnzymeSelector = String | typeof ElementClass; + + interface CommonWrapper { + /** + * Find every node in the render tree that matches the provided selector. + * @param selector The selector to match. + */ + find(selector: EnzymeSelector): T; + + /** + * Finds every node in the render tree that returns true for the provided predicate function. + * @param predicate + */ + findWhere(predicate: (shallowWrapper: ShallowWrapper) => Boolean): T; + + /** + * Removes nodes in the current wrapper that do not match the provided selector. + * @param selector The selector to match. + */ + filter(selector: EnzymeSelector): T; + + /** + * Returns a new wrapper with only the nodes of the current wrapper that, when passed into the provided predicate function, return true. + * @param predicate + */ + filterWhere(predicate: (shallowWrapper: ShallowWrapper) => Boolean): T; + + /** + * Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like the one passed in. + * @param node + */ + contains(node: ReactElement): Boolean; + + /** + * Returns whether or not the current node has a className prop including the passed in class name. + * @param className + */ + hasClass(className: String): Boolean; + + /** + * Returns whether or not the current node matches a provided selector. + * @param selector + */ + is(selector: EnzymeSelector): Boolean; + + /** + * Returns a new wrapper with only the nodes of the current wrapper that don't match the provided selector. + * This method is effectively the negation or inverse of filter. + * @param selector + */ + not(selector: EnzymeSelector): T; + + /** + * Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector + * can be provided and it will filter the children by this selector. + * @param [selector] + */ + children(selector?: EnzymeSelector): T; + + /** + * Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the + * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector. + * + * Note: can only be called on a wrapper of a single node. + * @param [selector] + */ + parents(selector?: EnzymeSelector): T; + + /** + * Returns a wrapper with the direct parent of the node in the current wrapper. + */ + parent(): T; + + /** + * Returns a wrapper of the first element that matches the selector by traversing up through the current node's + * ancestors in the tree, starting with itself. + * + * Note: can only be called on a wrapper of a single node. + * @param selector + */ + closest(selector: EnzymeSelector): T; + + /** + * Returns a string of the rendered text of the current render tree. This function should be looked at with + * skepticism if being used to test what the actual HTML output of the component will be. If that is what you + * would like to test, use enzyme's render function instead. + * + * Note: can only be called on a wrapper of a single node. + */ + text(): String; + + /** + * Returns a string of the rendered HTML markup of the current render tree. + * + * Note: can only be called on a wrapper of a single node. + */ + html(): String; + + /** + * Returns the node at a given index of the current wrapper. + * @param index + */ + get(index: number): ReactElement; + + /** + * Returns a wrapper around the node at a given index of the current wrapper. + * @param index + */ + at(index: number): T; + + /** + * Reduce the set of matched nodes to the first in the set. + */ + first(): T; + + /** + * Reduce the set of matched nodes to the last in the set. + */ + last(): T; + + /** + * Returns the state hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value. + * @param [key] + */ + state(key?: String): any; + + /** + * Returns the props hash for the current node of the wrapper. + * + * NOTE: can only be called on a wrapper of a single node. + */ + props(): Object; + + /** + * Returns the prop value for the node of the current wrapper with the provided key. + * + * NOTE: can only be called on a wrapper of a single node. + * @param key + */ + prop(key: String): any; + + /** + * Simulate events. + * Returns itself. + * @param event + * @param args? + */ + simulate(event: String, ...args: any[]): T; + + /** + * A method to invoke setState() on the root component instance similar to how you might in the definition of + * the component, and re-renders. This method is useful for testing your component in hard to achieve states, + * however should be used sparingly. If possible, you should utilize your component's external API in order to + * get it into whatever state you want to test, in order to be as accurate of a test as possible. This is not + * always practical, however. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + * @param state + */ + setState(state: S): T; + + /** + * A method that sets the props of the root component, and re-renders. Useful for when you are wanting to test + * how the component behaves over time with changing props. Calling this, for instance, will call the + * componentWillReceiveProps lifecycle method. + * + * Similar to setState, this method accepts a props object and will merge it in with the already existing props. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + * @param state + */ + setProps(state: Object): T; + + /** + * A method that sets the context of the root component, and re-renders. Useful for when you are wanting to + * test how the component behaves over time with changing contexts. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + * @param state + */ + setContext(state: Object): T; + + /** + * Gets the instance of the component being rendered as the root node passed into shallow(). + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + */ + instance(): Component; + + /** + * Forces a re-render. Useful to run before checking the render output if something external may be updating + * the state of the component somewhere. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + */ + update(): T; + + /** + * Returns an html-like string of the wrapper for debugging purposes. Useful to print out to the console when + * tests are not passing when you expect them to. + */ + debug(): String; + + /** + * Returns the type of the current node of this wrapper. If it's a composite component, this will be the + * component constructor. If it's native DOM node, it will be a string of the tag name. + * + * Note: can only be called on a wrapper of a single node. + */ + type(): String | Function; + + /** + * Iterates through each node of the current wrapper and executes the provided function with a wrapper around + * the corresponding node passed in as the first argument. + * + * Returns itself. + * @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first + * argument, and will be run with a context of the original instance. + */ + forEach(fn: (wrapper: ShallowWrapper) => void): T; + + /** + * Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map + * function. + * Returns an array of the returned values from the mapping function.. + * @param fn A mapping function to be run for every node in the collection, the results of which will be mapped + * to the returned array. Should expect a ShallowWrapper as the first argument, and will be run + * with a context of the original instance. + */ + map(fn: (wrapper: ShallowWrapper) => any): Array; + + /** + * Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node + * is passed in as a ShallowWrapper, and is processed from left to right. + * @param fn + * @param initialValue + */ + reduce(fn: (prevVal: R, wrapper: ShallowWrapper, index: number) => R, initialValue?: R): R[]; + + /** + * Applies the provided reducing function to every node in the wrapper to reduce to a single value. + * Each node is passed in as a ShallowWrapper, and is processed from right to left. + * @param fn + * @param initialValue + */ + reduceRight(fn: (prevVal: R, wrapper: ShallowWrapper, index: number) => R, initialValue?: R): R[]; + + /** + * Returns whether or not any of the nodes in the wrapper match the provided selector. + * @param selector + */ + some(selector: EnzymeSelector): Boolean; + + /** + * Returns whether or not any of the nodes in the wrapper pass the provided predicate function. + * @param fn + */ + someWhere(fn: (wrapper: ShallowWrapper) => Boolean): Boolean; + + /** + * Returns whether or not all of the nodes in the wrapper match the provided selector. + * @param selector + */ + every(selector: EnzymeSelector): Boolean; + + /** + * Returns whether or not any of the nodes in the wrapper pass the provided predicate function. + * @param fn + */ + everyWhere(fn: (wrapper: ShallowWrapper) => Boolean): Boolean; + + length: number; + } + + export interface ShallowWrapper extends CommonWrapper, P, S> { + shallow(): ShallowWrapper; + + render(): CheerioWrapper; + } + + export interface ReactWrapper extends CommonWrapper, P, S> { + + } + + export interface CheerioWrapper extends CommonWrapper, P, S> { + + } + + /** + * Shallow rendering is useful to constrain yourself to testing a component as a unit, and to ensure that + * your tests aren't indirectly asserting on behavior of child components. + * @param node + * @param [options] + */ + export function shallow(node: ReactElement

        , options?: any): ShallowWrapper; + + /** + * Mounts and renders a react component into the document and provides a testing wrapper around it. + * @param node + * @param [options] + */ + export function mount(node: ReactElement

        , options?: any): ReactWrapper; + + /** + * Render react components to static HTML and analyze the resulting HTML structure. + * @param node + * @param [options] + */ + export function render(node: ReactElement

        , options?: any): CheerioWrapper; + + export function describeWithDOM(description: String, fn: Function): void; + + export function spyLifecycle(component: typeof Component): void; +} \ No newline at end of file From b0170d98761af9f6b66743c36723497ea75d0633 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 18 Dec 2015 19:30:50 +0500 Subject: [PATCH 152/353] lodash: signatures of _.isObject have been changed --- lodash/lodash-tests.ts | 22 ++++++++++++++++++---- lodash/lodash.d.ts | 10 +++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d661839d5..f29c10e4f 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5657,10 +5657,24 @@ result = _({}).isNumber(); } // _.isObject -result = _.isObject(any); -result = _(1).isObject(); -result = _([]).isObject(); -result = _({}).isObject(); +module TestIsObject { + { + let result: boolean; + + result = _.isObject(any); + result = _(1).isObject(); + result = _([]).isObject(); + result = _({}).isObject(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().isObject(); + result = _([]).chain().isObject(); + result = _({}).chain().isObject(); + } +} // _.isPlainObject result = _.isPlainObject(any); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 4e86afb66..bd2955462 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9582,9 +9582,10 @@ declare module _ { /** * Checks if value is the language type of Object. (e.g. arrays, functions, objects, regexes, new Number(0), * and new String('')) + * * @param value The value to check. * @return Returns true if value is an object, else false. - **/ + */ isObject(value?: any): boolean; } @@ -9595,6 +9596,13 @@ declare module _ { isObject(): boolean; } + interface LoDashExplicitWrapperBase { + /** + * see _.isObject + */ + isObject(): LoDashExplicitWrapper; + } + //_.isPlainObject interface LoDashStatic { /** From 3a25247cd52c5814253a24b620344e9ec33c6109 Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Fri, 18 Dec 2015 15:44:58 +0100 Subject: [PATCH 153/353] Definition for prettyjson package added --- prettyjson/prettyjson-tests.ts | 18 +++++++++++ prettyjson/prettyjson.d.ts | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 prettyjson/prettyjson-tests.ts create mode 100644 prettyjson/prettyjson.d.ts diff --git a/prettyjson/prettyjson-tests.ts b/prettyjson/prettyjson-tests.ts new file mode 100644 index 000000000..da82686e1 --- /dev/null +++ b/prettyjson/prettyjson-tests.ts @@ -0,0 +1,18 @@ +/// + +var options: prettyjson.IOptions, + input: string, + output: string; + + +input = 'This is a string'; +output = prettyjson.render(input); + +output = prettyjson.render(input, {}, 4); + +output = prettyjson.render(['first string', ['nested 1', 'nested 2'], 'second string']); + +output = prettyjson.render({param1: 'first string', param2: 'second string'}); + +output = prettyjson.render({first_param: {subparam: 'first string', subparam2: 'another string'}, second_param: 'second string'}); + diff --git a/prettyjson/prettyjson.d.ts b/prettyjson/prettyjson.d.ts new file mode 100644 index 000000000..43dbf133c --- /dev/null +++ b/prettyjson/prettyjson.d.ts @@ -0,0 +1,55 @@ +// Type definitions for prettyjson +// Project: https://github.com/rafeca/prettyjson +// Definitions by: Wael BEN ZID EL GUEBSI +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +declare module "prettyjson" { + + /** + * Defines prettyjson version + */ + export var version: string; + + /** + * Render pretty json. + * + * @param data {Object} Data to prettify. + * @param options {IOptions} Hash with different options to configure the renderer. + * @param indentation {number} Indentation size. + * + * @return {string} pretty serialized json data ready to display. + */ + export function render(data: Object, options?: IOptions, indentation?: number): string; + + /** + * Render pretty json from a string. + * + * @param data {string} Serialized JSON data to prettify. + * @param options {IOptions} Hash with different options to configure the renderer. + * @param indentation {number} Indentation size. + * + * @return {string} pretty serialized json data ready to display. + */ + export function renderString(data: string, options?: IOptions, indentation?: number): string; + + export interface IOptions { + + /** + * Define behavior for Array objects + */ + emptyArrayMsg ?: string; // default: (empty) + inlineArrays ?: boolean; + + /** + * Color definition + */ + noColor ?: boolean; + keysColor ?: string; + dashColor ?: string; + numberColor ?: string; + stringColor ?: string; + + defaultIndentation ?: number; + } +} From 1a7703a16ced73453adf4b1e5f858af3a399d610 Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Fri, 18 Dec 2015 15:50:24 +0100 Subject: [PATCH 154/353] Files published in the wrong branch removed --- prettyjson/prettyjson-tests.ts | 18 ----------- prettyjson/prettyjson.d.ts | 55 ---------------------------------- 2 files changed, 73 deletions(-) delete mode 100644 prettyjson/prettyjson-tests.ts delete mode 100644 prettyjson/prettyjson.d.ts diff --git a/prettyjson/prettyjson-tests.ts b/prettyjson/prettyjson-tests.ts deleted file mode 100644 index da82686e1..000000000 --- a/prettyjson/prettyjson-tests.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -var options: prettyjson.IOptions, - input: string, - output: string; - - -input = 'This is a string'; -output = prettyjson.render(input); - -output = prettyjson.render(input, {}, 4); - -output = prettyjson.render(['first string', ['nested 1', 'nested 2'], 'second string']); - -output = prettyjson.render({param1: 'first string', param2: 'second string'}); - -output = prettyjson.render({first_param: {subparam: 'first string', subparam2: 'another string'}, second_param: 'second string'}); - diff --git a/prettyjson/prettyjson.d.ts b/prettyjson/prettyjson.d.ts deleted file mode 100644 index 43dbf133c..000000000 --- a/prettyjson/prettyjson.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -// Type definitions for prettyjson -// Project: https://github.com/rafeca/prettyjson -// Definitions by: Wael BEN ZID EL GUEBSI -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - -declare module "prettyjson" { - - /** - * Defines prettyjson version - */ - export var version: string; - - /** - * Render pretty json. - * - * @param data {Object} Data to prettify. - * @param options {IOptions} Hash with different options to configure the renderer. - * @param indentation {number} Indentation size. - * - * @return {string} pretty serialized json data ready to display. - */ - export function render(data: Object, options?: IOptions, indentation?: number): string; - - /** - * Render pretty json from a string. - * - * @param data {string} Serialized JSON data to prettify. - * @param options {IOptions} Hash with different options to configure the renderer. - * @param indentation {number} Indentation size. - * - * @return {string} pretty serialized json data ready to display. - */ - export function renderString(data: string, options?: IOptions, indentation?: number): string; - - export interface IOptions { - - /** - * Define behavior for Array objects - */ - emptyArrayMsg ?: string; // default: (empty) - inlineArrays ?: boolean; - - /** - * Color definition - */ - noColor ?: boolean; - keysColor ?: string; - dashColor ?: string; - numberColor ?: string; - stringColor ?: string; - - defaultIndentation ?: number; - } -} From 33e3ab99b09c3c4b159868ed66db602792aecdec Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Fri, 18 Dec 2015 16:10:09 +0100 Subject: [PATCH 155/353] "generators" is deprecated now. Use "Base" and "NamedBase" directly. --- yeoman-generator/yeoman-generator.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index b73037ea5..48fbd835c 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -205,6 +205,8 @@ declare module yo { var file: any; var assert: IAssert; var test: ITestHelper; + + // "generators" is deprecated module generators { export class NamedBase extends YeomanGeneratorBase implements INamedBase { @@ -215,6 +217,14 @@ declare module yo { static extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; } } + + export class NamedBase extends YeomanGeneratorBase implements INamedBase { + constructor(args: string | string[], options: any); + } + + export class Base extends NamedBase implements IBase { + static extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; + } } declare module "yeoman-generator" { From b967242e17899029877c57e81f6e11b423ab6a2b Mon Sep 17 00:00:00 2001 From: Arthur Xavier Date: Fri, 18 Dec 2015 11:41:14 -0200 Subject: [PATCH 156/353] Add type definitions for lime-js Fix indentation and callback types --- lime-js/lime-js-tests.ts | 35 +++++++ lime-js/lime-js.d.ts | 200 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 lime-js/lime-js-tests.ts create mode 100644 lime-js/lime-js.d.ts diff --git a/lime-js/lime-js-tests.ts b/lime-js/lime-js-tests.ts new file mode 100644 index 000000000..aa73444b1 --- /dev/null +++ b/lime-js/lime-js-tests.ts @@ -0,0 +1,35 @@ +/// + +var transport = new Lime.WebSocketTransport(true); +var clientChannel = new Lime.ClientChannel(transport, true, true); + +clientChannel.onMessage = (m) => { + // message received callback +}; +clientChannel.onNotification = (n) => { + // notification received callback +}; +clientChannel.onCommand = (c) => { + // command received callback +}; + +transport.onOpen = () => { + var authentication: Lime.Authentication = new Lime.GuestAuthentication(); + Lime.ClientChannelExtensions.establishSession(clientChannel, "none", "none", "test@msging.net", authentication, "test", (err, session) => { + var message: Lime.Message = { + id: "123", + to: "someone@test.net", + type: "text/plain", + content: "Hello, world!" + }; + clientChannel.sendMessage(message); + }); +}; +transport.onClose = () => { + // transport closed callback +}; +transport.onError = (err) => { + // transport error callback +}; + +transport.open("ws://test.net"); diff --git a/lime-js/lime-js.d.ts b/lime-js/lime-js.d.ts new file mode 100644 index 000000000..7e26733d3 --- /dev/null +++ b/lime-js/lime-js.d.ts @@ -0,0 +1,200 @@ +// Type definitions for lime-js 0.0.3 +// Project: https://github.com/takenet/lime-js +// Definitions by: Arthur Xavier +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare namespace Lime { + + interface Envelope { + id?: string; + from?: string; + to?: string; + pp?: string; + metadata?: any; + } + interface Reason { + code: number; + description?: string; + } + + interface Message extends Envelope { + type: string; + content: any; + } + + interface Notification extends Envelope { + event: string; + reason?: Reason; + } + class NotificationEvent { + static accepted: string; + static validated: string; + static authorized: string; + static dispatched: string; + static received: string; + static consumed: string; + } + + interface Command extends Envelope { + uri?: string; + type?: string; + resource?: any; + method: string; + status?: string; + reason?: Reason; + } + class CommandMethod { + static get: string; + static set: string; + static delete: string; + static observe: string; + static subscribe: string; + } + class CommandStatus { + static success: string; + static failure: string; + } + + interface Session extends Envelope { + state: string; + encryptionOptions?: string[]; + encryption?: string; + compressionOptions?: string[]; + compression?: string; + scheme?: string; + authentication?: any; + reason?: Reason; + } + class SessionState { + static new: string; + static negotiating: string; + static authenticating: string; + static established: string; + static finishing: string; + static finished: string; + static failed: string; + } + class SessionEncryption { + static none: string; + static tls: string; + } + class SessionCompression { + static none: string; + static gzip: string; + } + + class Authentication { + scheme: string; + static guest: string; + static plain: string; + static transport: string; + static key: string; + } + class GuestAuthentication extends Authentication { + scheme: string; + } + class TransportAuthentication extends Authentication { + scheme: string; + } + class PlainAuthentication extends Authentication { + scheme: string; + password: string; + } + class KeyAuthentication extends Authentication { + scheme: string; + key: string; + } + + class Channel { + constructor(transport: Transport, autoReplyPings: boolean, autoNotifyReceipt: boolean); + sendMessage(message: Message): void; + onMessage(message: Message): void; + sendCommand(command: Command): void; + onCommand(command: Command): void; + sendNotification(notification: Notification): void; + onNotification(notification: Notification): void; + sendSession(session: Session): void; + onSession(session: Session): void; + transport: Transport; + remoteNode: string; + localNode: string; + sessionId: string; + state: string; + } + + class ClientChannel extends Channel { + constructor(transport: Transport, autoReplyPings?: boolean, autoNotifyReceipt?: boolean); + startNewSession(): void; + negotiateSession(sessionCompression: string, sessionEncryption: string): void; + authenticateSession(identity: string, authentication: Authentication, instance: string): void; + sendFinishingSession(): void; + onSessionNegotiating(session: Session): void; + onSessionAuthenticating(session: Session): void; + onSessionEstablished(session: Session): void; + onSessionFinished(session: Session): void; + onSessionFailed(session: Session): void; + } + + class ClientChannelExtensions { + static establishSession(clientChannel: ClientChannel, compression: string, encryption: string, identity: string, authentication: Authentication, instance: string, callback: (error: Error, session: Session) => any): void; + } + + interface IMessageChannel { + sendMessage(message: Message): void; + onMessage: (message: Message) => any; + } + interface ICommandChannel { + sendCommand(command: Command): void; + onCommand: (command: Command) => any; + } + interface INotificationChannel { + sendNotification(notification: Notification): void; + onNotification: (notification: Notification) => any; + } + interface ISessionChannel { + sendSession(session: Session): void; + onSession: (session: Session) => any; + } + interface ISessionListener { + (session: Session): void; + } + + interface Transport extends ITransportStateListener { + send(envelope: Envelope): void; + onEnvelope: (envelope: Envelope) => any; + open(uri: string): void; + close(): void; + getSupportedCompression(): string[]; + setCompression(compression: string): void; + compression: string; + getSupportedEncryption(): string[]; + setEncryption(encryption: string): void; + encryption: string; + } + interface ITransportEnvelopeListener { + (envelope: Envelope): void; + } + interface ITransportStateListener { + onOpen: () => void; + onClose: () => void; + onError: (error: string) => void; + } + + class WebSocketTransport implements Transport { + webSocket: WebSocket; + constructor(traceEnabled?: boolean); + send(envelope: Envelope): void; + onEnvelope(envelope: Envelope): void; + open(uri: string): void; + close(): void; + getSupportedCompression(): string[]; + setCompression(compression: string): void; + compression: string; + getSupportedEncryption(): string[]; + setEncryption(encryption: string): void; + encryption: string; + onOpen(): void; + onClose(): void; + onError(error: string): void; + } +} From d47ea42665b7131741e7a16b7c6affd690043818 Mon Sep 17 00:00:00 2001 From: lucyhe Date: Fri, 18 Dec 2015 10:37:09 -0500 Subject: [PATCH 157/353] Add optional status to UserProfile in freedom.d.ts User's can have a status, e.g. "FRIEND" or "LOCAL_INVITED_BY_REMOTE" --- freedom/freedom.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/freedom/freedom.d.ts b/freedom/freedom.d.ts index fa80a530c..c69b800e9 100644 --- a/freedom/freedom.d.ts +++ b/freedom/freedom.d.ts @@ -497,6 +497,7 @@ declare module freedom.Social { interface UserProfile { userId: string; name: string; + status?: number; url?: string; // Image URI (e.g. data:image/png;base64,adkwe329...) imageData?: string; From 2321f2da7738733f71a24ca5e9ec1b8153ced3e3 Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Fri, 18 Dec 2015 17:05:26 +0100 Subject: [PATCH 158/353] Just use `any` instead of explicit types Inquirer also supports some other stuff like separator objects as choices. It gets too complicated to properly type it because its unclear what other stuff can be used as choices so I just use `any` now. --- yeoman-generator/yeoman-generator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 48fbd835c..27e79943c 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -84,7 +84,7 @@ declare module yo { type?: string; name: string; message: string | ((answers: Object) => string); - choices?: string[] | IChoice[] | ((answers: Object) => (string[] | IChoice[])); + choices?: any[] | ((answers: Object) => any); default?: string | number | string[] | number[] | ((answers: Object) => (string | number | string[] | number[])); validate?: ((input: any) => boolean | string); filter?: ((input: any) => any); From 4676585cf173721c4df3602e00dc188b8bbf27f7 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 18 Dec 2015 17:22:35 +0100 Subject: [PATCH 159/353] Remove trailing spaces --- errorhandler/errorhandler-tests.ts | 2 +- errorhandler/errorhandler.d.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/errorhandler/errorhandler-tests.ts b/errorhandler/errorhandler-tests.ts index 0ba9edb56..3b847f87f 100644 --- a/errorhandler/errorhandler-tests.ts +++ b/errorhandler/errorhandler-tests.ts @@ -14,4 +14,4 @@ app.use(errorhandler({ log: (err, str, req, res) => { const requestWasFresh = req && req.fresh; const responseContentType = res && res.contentType -}})) \ No newline at end of file +}})) diff --git a/errorhandler/errorhandler.d.ts b/errorhandler/errorhandler.d.ts index 8ae5e924c..f021f96c5 100644 --- a/errorhandler/errorhandler.d.ts +++ b/errorhandler/errorhandler.d.ts @@ -7,18 +7,18 @@ declare module "errorhandler" { import express = require('express'); - + function errorHandler(options?: errorHandler.Options): express.ErrorRequestHandler; - + namespace errorHandler { interface LoggingCallback { (err: Error, str: string, req: express.Request, res: express.Response): void; } - + interface Options { /** * Defaults to true. - * + * * Possible values: * true : Log errors using console.error(str). * false : Only send the error back in the response. @@ -27,6 +27,6 @@ declare module "errorhandler" { log: boolean | LoggingCallback; } } - + export = errorHandler; } From 7e47928c4d7717a576243c4ac4a2c0f66d80b07e Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 18 Dec 2015 19:49:13 +0100 Subject: [PATCH 160/353] Switch to "import * as": more standard way to do --- api-error-handler/api-error-handler-tests.ts | 4 ++-- api-error-handler/api-error-handler.d.ts | 2 +- errorhandler/errorhandler-tests.ts | 5 +++-- errorhandler/errorhandler.d.ts | 2 +- http-errors/http-errors-tests.ts | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/api-error-handler/api-error-handler-tests.ts b/api-error-handler/api-error-handler-tests.ts index 83df91e86..0d0ca85d9 100644 --- a/api-error-handler/api-error-handler-tests.ts +++ b/api-error-handler/api-error-handler-tests.ts @@ -1,7 +1,7 @@ /// -import errorHandler = require('api-error-handler'); -import express = require('express'); +import * as errorHandler from 'api-error-handler'; +import * as express from 'express'; var api = express.Router(); api.get('/users/:userid', function (req, res, next) { diff --git a/api-error-handler/api-error-handler.d.ts b/api-error-handler/api-error-handler.d.ts index 61a63825d..d66aabf9b 100644 --- a/api-error-handler/api-error-handler.d.ts +++ b/api-error-handler/api-error-handler.d.ts @@ -6,7 +6,7 @@ /// declare module 'api-error-handler' { - import express = require('express'); + import * as express from 'express'; function apiErrorHandler(options?: any): express.ErrorRequestHandler; diff --git a/errorhandler/errorhandler-tests.ts b/errorhandler/errorhandler-tests.ts index 3b847f87f..1316888e3 100644 --- a/errorhandler/errorhandler-tests.ts +++ b/errorhandler/errorhandler-tests.ts @@ -1,7 +1,8 @@ /// -import express = require('express'); -import errorhandler = require('errorhandler'); +import * as express from 'express'; +import * as errorhandler from 'errorhandler'; + var app = express(); app.use(errorhandler()); diff --git a/errorhandler/errorhandler.d.ts b/errorhandler/errorhandler.d.ts index f021f96c5..37d5c3c41 100644 --- a/errorhandler/errorhandler.d.ts +++ b/errorhandler/errorhandler.d.ts @@ -6,7 +6,7 @@ /// declare module "errorhandler" { - import express = require('express'); + import * as express from 'express'; function errorHandler(options?: errorHandler.Options): express.ErrorRequestHandler; diff --git a/http-errors/http-errors-tests.ts b/http-errors/http-errors-tests.ts index 06b91f13b..9ee89d6a6 100644 --- a/http-errors/http-errors-tests.ts +++ b/http-errors/http-errors-tests.ts @@ -1,8 +1,8 @@ /// /// -import createError = require('http-errors'); -import express = require('express'); +import * as createError from 'http-errors'; +import * as express from 'express'; var app = express(); From 9c25433c84251bfe72bf0030a95edbbb2c81c9d5 Mon Sep 17 00:00:00 2001 From: Matt Wistrand Date: Fri, 18 Dec 2015 16:00:21 -0600 Subject: [PATCH 161/353] Update Chai typings to v3.4.0. v3.3.0 introduces the following methods: * isNotTrue * isNotFalse * isAtLeast * isAtMost v3.4.0 introduces: * oneOf assertion. * approximately alias for closeTo. --- chai/chai-3.2.0.d.ts | 388 +++++++++++++++++++++++++++++++++++++++++++ chai/chai-tests.ts | 98 +++++++++++ chai/chai.d.ts | 23 ++- 3 files changed, 504 insertions(+), 5 deletions(-) create mode 100644 chai/chai-3.2.0.d.ts diff --git a/chai/chai-3.2.0.d.ts b/chai/chai-3.2.0.d.ts new file mode 100644 index 000000000..e68e6fa3b --- /dev/null +++ b/chai/chai-3.2.0.d.ts @@ -0,0 +1,388 @@ +// Type definitions for chai 3.2.0 +// Project: http://chaijs.com/ +// Definitions by: Jed Mao , +// Bart van der Schoor , +// Andrew Brown , +// Olivier Chevet +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// + +declare module Chai { + + interface ChaiStatic { + expect: ExpectStatic; + should(): Should; + /** + * Provides a way to extend the internals of Chai + */ + use(fn: (chai: any, utils: any) => void): any; + assert: AssertStatic; + config: Config; + AssertionError: typeof AssertionError; + } + + export interface ExpectStatic extends AssertionStatic { + fail(actual?: any, expected?: any, message?: string, operator?: string): void; + } + + export interface AssertStatic extends Assert { + } + + export interface AssertionStatic { + (target: any, message?: string): Assertion; + } + + interface ShouldAssertion { + equal(value1: any, value2: any, message?: string): void; + Throw: ShouldThrow; + throw: ShouldThrow; + exist(value: any, message?: string): void; + } + + interface Should extends ShouldAssertion { + not: ShouldAssertion; + fail(actual: any, expected: any, message?: string, operator?: string): void; + } + + interface ShouldThrow { + (actual: Function): void; + (actual: Function, expected: string|RegExp, message?: string): void; + (actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void; + } + + interface Assertion extends LanguageChains, NumericComparison, TypeComparison { + not: Assertion; + deep: Deep; + any: KeyFilter; + all: KeyFilter; + a: TypeComparison; + an: TypeComparison; + include: Include; + includes: Include; + contain: Include; + contains: Include; + ok: Assertion; + true: Assertion; + false: Assertion; + null: Assertion; + undefined: Assertion; + NaN: Assertion; + exist: Assertion; + empty: Assertion; + arguments: Assertion; + Arguments: Assertion; + equal: Equal; + equals: Equal; + eq: Equal; + eql: Equal; + eqls: Equal; + property: Property; + ownProperty: OwnProperty; + haveOwnProperty: OwnProperty; + ownPropertyDescriptor: OwnPropertyDescriptor; + haveOwnPropertyDescriptor: OwnPropertyDescriptor; + length: Length; + lengthOf: Length; + match: Match; + matches: Match; + string(string: string, message?: string): Assertion; + keys: Keys; + key(string: string): Assertion; + throw: Throw; + throws: Throw; + Throw: Throw; + respondTo: RespondTo; + respondsTo: RespondTo; + itself: Assertion; + satisfy: Satisfy; + satisfies: Satisfy; + closeTo(expected: number, delta: number, message?: string): Assertion; + members: Members; + increase: PropertyChange; + increases: PropertyChange; + decrease: PropertyChange; + decreases: PropertyChange; + change: PropertyChange; + changes: PropertyChange; + extensible: Assertion; + sealed: Assertion; + frozen: Assertion; + + } + + interface LanguageChains { + to: Assertion; + be: Assertion; + been: Assertion; + is: Assertion; + that: Assertion; + which: Assertion; + and: Assertion; + has: Assertion; + have: Assertion; + with: Assertion; + at: Assertion; + of: Assertion; + same: Assertion; + } + + interface NumericComparison { + above: NumberComparer; + gt: NumberComparer; + greaterThan: NumberComparer; + least: NumberComparer; + gte: NumberComparer; + below: NumberComparer; + lt: NumberComparer; + lessThan: NumberComparer; + most: NumberComparer; + lte: NumberComparer; + within(start: number, finish: number, message?: string): Assertion; + } + + interface NumberComparer { + (value: number, message?: string): Assertion; + } + + interface TypeComparison { + (type: string, message?: string): Assertion; + instanceof: InstanceOf; + instanceOf: InstanceOf; + } + + interface InstanceOf { + (constructor: Object, message?: string): Assertion; + } + + interface Deep { + equal: Equal; + include: Include; + property: Property; + members: Members; + } + + interface KeyFilter { + keys: Keys; + } + + interface Equal { + (value: any, message?: string): Assertion; + } + + interface Property { + (name: string, value?: any, message?: string): Assertion; + } + + interface OwnProperty { + (name: string, message?: string): Assertion; + } + + interface OwnPropertyDescriptor { + (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; + (name: string, message?: string): Assertion; + } + + interface Length extends LanguageChains, NumericComparison { + (length: number, message?: string): Assertion; + } + + interface Include { + (value: Object, message?: string): Assertion; + (value: string, message?: string): Assertion; + (value: number, message?: string): Assertion; + keys: Keys; + members: Members; + any: KeyFilter; + all: KeyFilter; + } + + interface Match { + (regexp: RegExp|string, message?: string): Assertion; + } + + interface Keys { + (...keys: string[]): Assertion; + (keys: any[]): Assertion; + (keys: Object): Assertion; + } + + interface Throw { + (): Assertion; + (expected: string, message?: string): Assertion; + (expected: RegExp, message?: string): Assertion; + (constructor: Error, expected?: string, message?: string): Assertion; + (constructor: Error, expected?: RegExp, message?: string): Assertion; + (constructor: Function, expected?: string, message?: string): Assertion; + (constructor: Function, expected?: RegExp, message?: string): Assertion; + } + + interface RespondTo { + (method: string, message?: string): Assertion; + } + + interface Satisfy { + (matcher: Function, message?: string): Assertion; + } + + interface Members { + (set: any[], message?: string): Assertion; + } + + interface PropertyChange { + (object: Object, prop: string, msg?: string): Assertion; + } + + export interface Assert { + /** + * @param expression Expression to test for truthiness. + * @param message Message to display on error. + */ + (expression: any, message?: string): void; + + fail(actual?: any, expected?: any, msg?: string, operator?: string): void; + + ok(val: any, msg?: string): void; + isOk(val: any, msg?: string): void; + notOk(val: any, msg?: string): void; + isNotOk(val: any, msg?: string): void; + + equal(act: any, exp: any, msg?: string): void; + notEqual(act: any, exp: any, msg?: string): void; + + strictEqual(act: any, exp: any, msg?: string): void; + notStrictEqual(act: any, exp: any, msg?: string): void; + + deepEqual(act: any, exp: any, msg?: string): void; + notDeepEqual(act: any, exp: any, msg?: string): void; + + isTrue(val: any, msg?: string): void; + isFalse(val: any, msg?: string): void; + + isNull(val: any, msg?: string): void; + isNotNull(val: any, msg?: string): void; + + isUndefined(val: any, msg?: string): void; + isDefined(val: any, msg?: string): void; + + isNaN(val: any, msg?: string): void; + isNotNaN(val: any, msg?: string): void; + + isAbove(val: number, abv: number, msg?: string): void; + isBelow(val: number, blw: number, msg?: string): void; + + isFunction(val: any, msg?: string): void; + isNotFunction(val: any, msg?: string): void; + + isObject(val: any, msg?: string): void; + isNotObject(val: any, msg?: string): void; + + isArray(val: any, msg?: string): void; + isNotArray(val: any, msg?: string): void; + + isString(val: any, msg?: string): void; + isNotString(val: any, msg?: string): void; + + isNumber(val: any, msg?: string): void; + isNotNumber(val: any, msg?: string): void; + + isBoolean(val: any, msg?: string): void; + isNotBoolean(val: any, msg?: string): void; + + typeOf(val: any, type: string, msg?: string): void; + notTypeOf(val: any, type: string, msg?: string): void; + + instanceOf(val: any, type: Function, msg?: string): void; + notInstanceOf(val: any, type: Function, msg?: string): void; + + include(exp: string, inc: any, msg?: string): void; + include(exp: any[], inc: any, msg?: string): void; + + notInclude(exp: string, inc: any, msg?: string): void; + notInclude(exp: any[], inc: any, msg?: string): void; + + match(exp: any, re: RegExp, msg?: string): void; + notMatch(exp: any, re: RegExp, msg?: string): void; + + property(obj: Object, prop: string, msg?: string): void; + notProperty(obj: Object, prop: string, msg?: string): void; + deepProperty(obj: Object, prop: string, msg?: string): void; + notDeepProperty(obj: Object, prop: string, msg?: string): void; + + propertyVal(obj: Object, prop: string, val: any, msg?: string): void; + propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; + + deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void; + deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; + + lengthOf(exp: any, len: number, msg?: string): void; + //alias frenzy + throw(fn: Function, msg?: string): void; + throw(fn: Function, regExp: RegExp): void; + throw(fn: Function, errType: Function, msg?: string): void; + throw(fn: Function, errType: Function, regExp: RegExp): void; + + throws(fn: Function, msg?: string): void; + throws(fn: Function, regExp: RegExp): void; + throws(fn: Function, errType: Function, msg?: string): void; + throws(fn: Function, errType: Function, regExp: RegExp): void; + + Throw(fn: Function, msg?: string): void; + Throw(fn: Function, regExp: RegExp): void; + Throw(fn: Function, errType: Function, msg?: string): void; + Throw(fn: Function, errType: Function, regExp: RegExp): void; + + doesNotThrow(fn: Function, msg?: string): void; + doesNotThrow(fn: Function, regExp: RegExp): void; + doesNotThrow(fn: Function, errType: Function, msg?: string): void; + doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; + + operator(val: any, operator: string, val2: any, msg?: string): void; + closeTo(act: number, exp: number, delta: number, msg?: string): void; + + sameMembers(set1: any[], set2: any[], msg?: string): void; + sameDeepMembers(set1: any[], set2: any[], msg?: string): void; + includeMembers(superset: any[], subset: any[], msg?: string): void; + + ifError(val: any, msg?: string): void; + + isExtensible(obj: {}, msg?: string): void; + extensible(obj: {}, msg?: string): void; + isNotExtensible(obj: {}, msg?: string): void; + notExtensible(obj: {}, msg?: string): void; + + isSealed(obj: {}, msg?: string): void; + sealed(obj: {}, msg?: string): void; + isNotSealed(obj: {}, msg?: string): void; + notSealed(obj: {}, msg?: string): void; + + isFrozen(obj: Object, msg?: string): void; + frozen(obj: Object, msg?: string): void; + isNotFrozen(obj: Object, msg?: string): void; + notFrozen(obj: Object, msg?: string): void; + + + } + + export interface Config { + includeStack: boolean; + } + + export class AssertionError { + constructor(message: string, _props?: any, ssf?: Function); + name: string; + message: string; + showDiff: boolean; + stack: string; + } +} + +declare var chai: Chai.ChaiStatic; + +declare module "chai" { + export = chai; +} + +interface Object { + should: Chai.Assertion; +} diff --git a/chai/chai-tests.ts b/chai/chai-tests.ts index 9b646b152..df09aea3e 100644 --- a/chai/chai-tests.ts +++ b/chai/chai-tests.ts @@ -1166,6 +1166,25 @@ function closeTo() { }, 'blah: expected -10 to be close to 20 +/- 29'); } +function approximately() { + expect(1.5).to.be.approximately(1.0, 0.5); + (1.5).should.be.approximately(1.0, 0.5); + expect(10).to.be.approximately(20, 20); + (10).should.be.approximately(20, 20); + expect(-10).to.be.approximately(20, 30); + (-10).should.be.approximately(20, 30); + + err(() => { + expect(2).to.be.approximately(1.0, 0.5, 'blah'); + (2).should.be.approximately(1.0, 0.5, 'blah'); + }, 'blah: expected 2 to be close to 1 +/- 0.5'); + + err(() => { + expect(-10).to.be.approximately(20, 29, 'blah'); + (-10).should.be.approximately(20, 29, 'blah'); + }, 'blah: expected -10 to be close to 20 +/- 29'); +} + function includeMembers() { expect([1, 2, 3]).to.include.members([]); [1, 2, 3].should.include.members([]); @@ -1255,6 +1274,20 @@ function increaseDecreaseChange() { same.should.not.change(obj, "val"); } +function oneOf() { + var obj = { z: 3 }; + + expect(5).to.be.oneOf([1, 5, 4]); + expect('z').to.be.oneOf(['x', 'y', 'z']); + expect(obj).to.be.oneOf([obj]); + + expect(5).to.not.be.oneOf([1, -12, 4]); + expect(5).to.not.be.oneOf([1, [5], 4]); + expect('z').to.not.be.oneOf(['w', 'x', 'y']); + expect('z').to.not.be.oneOf(['x', 'y', ['z']]); + expect(obj).to.not.be.oneOf([{ z: 3 }]); +} + //tdd declare function suite(description: string, action: Function): void; declare function test(description: string, action: Function): void; @@ -1879,6 +1912,20 @@ suite('assert', () => { }, 'expected -10 to be close to 20 +/- 29'); }); + test('approximately', () => { + assert.approximately(1.5, 1.0, 0.5); + assert.approximately(10, 20, 20); + assert.approximately(-10, 20, 30); + + err(() => { + assert.approximately(2, 1.0, 0.5); + }, 'expected 2 to be close to 1 +/- 0.5'); + + err(() => { + assert.approximately(-10, 20, 29); + }, 'expected -10 to be close to 20 +/- 29'); + }); + test('members', () => { assert.includeMembers([1, 2, 3], [2, 3]); assert.includeMembers([1, 2, 3], []); @@ -1945,4 +1992,55 @@ suite('assert', () => { test('notFrozen', () => { assert.notFrozen({}); }); test('isNotFrozen', () => { assert.isNotFrozen({}); }); + test('isNotTrue', () => { + assert.isNotTrue(false); + + err(() => { + assert.isNotTrue(true); + }, 'expected true to not be true'); + }); + + test('isNotFalse', () => { + assert.isNotFalse(true); + + err(() => { + assert.isNotFalse(false); + }, 'expected false to not be false'); + }); + + test('isAtLeast', () => { + assert.isAtLeast(5, 3); + assert.isAtLeast(5, 5); + + err(() => { + assert.isAtLeast(3, 5); + }, 'expected 3 to be greater than or equal to 5'); + }); + + test('isAtMost', () => { + assert.isAtMost(3, 5); + assert.isAtMost(5, 5); + + err(() => { + assert.isAtMost(5, 3); + }, 'expected 5 to be less than or equal to 3'); + }); + + test('oneOf', () => { + var obj = { z: 3 }; + + assert.oneOf(5, [1, 5, 4]); + assert.oneOf('z', ['x', 'y', 'z']); + assert.oneOf(obj, [obj]); + + err(() => { + assert.oneOf(5, [1, [5], 4]); + }, 'expected 5 to be one of [1, [5], 4]'); + err(() => { + assert.oneOf('z', ['w', 'x', 'y']); + }, 'expected "z" to be one of [w, x, y]'); + err(() => { + assert.oneOf(obj, [{ z: 3 }]); + }, 'expected { z: 3 } to be one of [{ z: 3 }]'); + }); }); diff --git a/chai/chai.d.ts b/chai/chai.d.ts index e68e6fa3b..074827b65 100644 --- a/chai/chai.d.ts +++ b/chai/chai.d.ts @@ -1,9 +1,10 @@ -// Type definitions for chai 3.2.0 +// Type definitions for chai 3.4.0 // Project: http://chaijs.com/ // Definitions by: Jed Mao , // Bart van der Schoor , // Andrew Brown , -// Olivier Chevet +// Olivier Chevet , +// Matt Wistrand // Definitions: https://github.com/borisyankov/DefinitelyTyped // @@ -97,7 +98,8 @@ declare module Chai { itself: Assertion; satisfy: Satisfy; satisfies: Satisfy; - closeTo(expected: number, delta: number, message?: string): Assertion; + closeTo: CloseTo; + approximately: CloseTo; members: Members; increase: PropertyChange; increases: PropertyChange; @@ -108,7 +110,7 @@ declare module Chai { extensible: Assertion; sealed: Assertion; frozen: Assertion; - + oneOf(list: any[], message?: string): Assertion; } interface LanguageChains { @@ -155,6 +157,10 @@ declare module Chai { (constructor: Object, message?: string): Assertion; } + interface CloseTo { + (expected: number, delta: number, message?: string): Assertion; + } + interface Deep { equal: Equal; include: Include; @@ -259,6 +265,9 @@ declare module Chai { isTrue(val: any, msg?: string): void; isFalse(val: any, msg?: string): void; + isNotTrue(val: any, msg?: string): void; + isNotFalse(val: any, msg?: string): void; + isNull(val: any, msg?: string): void; isNotNull(val: any, msg?: string): void; @@ -271,6 +280,9 @@ declare module Chai { isAbove(val: number, abv: number, msg?: string): void; isBelow(val: number, blw: number, msg?: string): void; + isAtLeast(val: number, atlst: number, msg?: string): void; + isAtMost(val: number, atmst: number, msg?: string): void; + isFunction(val: any, msg?: string): void; isNotFunction(val: any, msg?: string): void; @@ -339,6 +351,7 @@ declare module Chai { operator(val: any, operator: string, val2: any, msg?: string): void; closeTo(act: number, exp: number, delta: number, msg?: string): void; + approximately(act: number, exp: number, delta: number, msg?: string): void; sameMembers(set1: any[], set2: any[], msg?: string): void; sameDeepMembers(set1: any[], set2: any[], msg?: string): void; @@ -361,7 +374,7 @@ declare module Chai { isNotFrozen(obj: Object, msg?: string): void; notFrozen(obj: Object, msg?: string): void; - + oneOf(inList: any, list: any[], msg?: string): void; } export interface Config { From c6190204d5ae6aab5ac1744bf3cefb270e4cdf52 Mon Sep 17 00:00:00 2001 From: Tim Slatcher Date: Fri, 18 Dec 2015 22:45:39 +0000 Subject: [PATCH 162/353] Fix fixed-data-table typings, Column extends from React.Props so you can supply a key --- fixed-data-table/fixed-data-table-tests.tsx | 34 +++++++++------------ fixed-data-table/fixed-data-table.d.ts | 4 +-- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/fixed-data-table/fixed-data-table-tests.tsx b/fixed-data-table/fixed-data-table-tests.tsx index 916c0e64a..1f10a9fdb 100644 --- a/fixed-data-table/fixed-data-table-tests.tsx +++ b/fixed-data-table/fixed-data-table-tests.tsx @@ -143,26 +143,20 @@ class MyTable4 extends React.Component<{}, MyTable4State> { headerHeight={50} width={1000} height={500}> - Name} - cell={ - - } - width={200}/> - - Email} - cell={ - - } - width={200} - /> + { + ["name", "email"].map(field => + {field}} + cell={ + + } + width={200}/> + ) + } ); } diff --git a/fixed-data-table/fixed-data-table.d.ts b/fixed-data-table/fixed-data-table.d.ts index 5fb0438a0..219b7e39f 100644 --- a/fixed-data-table/fixed-data-table.d.ts +++ b/fixed-data-table/fixed-data-table.d.ts @@ -249,7 +249,7 @@ declare module FixedDataTable { /** * Component that defines the attributes of table column. */ - interface ColumnProps { + interface ColumnProps extends __React.Props { /** * The horizontal alignment of the table cell content. * @@ -498,4 +498,4 @@ declare module FixedDataTable { declare module "fixed-data-table" { export = FixedDataTable; -} \ No newline at end of file +} From 4b4c41fbb4a87a3721668f30040ada0a6e6ec3d3 Mon Sep 17 00:00:00 2001 From: Matt Wistrand Date: Fri, 18 Dec 2015 17:33:35 -0600 Subject: [PATCH 163/353] Add test file for chai-3.2.0.d.ts. --- chai/chai-3.2.0-tests.ts | 1948 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 1948 insertions(+) create mode 100644 chai/chai-3.2.0-tests.ts diff --git a/chai/chai-3.2.0-tests.ts b/chai/chai-3.2.0-tests.ts new file mode 100644 index 000000000..9b646b152 --- /dev/null +++ b/chai/chai-3.2.0-tests.ts @@ -0,0 +1,1948 @@ +/// +import chai = require('chai'); + +// ReSharper disable WrongExpressionStatement + +var expect = chai.expect; +var assert = chai.assert; +var should = chai.should(); +declare var err: Function; + +function chaiVersion() { + expect(chai).to.have.property('version'); + (<{}>chai).should.have.property('version'); +} + +function assertion() { + expect('test').to.be.a('string'); + 'test'.should.be.a('string'); + expect('foo').to.equal('foo'); + 'foo'.should.equal('foo'); + should.equal('foo', 'foo'); +} + +function fail() { + err(() => { + should.fail('foo', 'bar'); + }, 'expected fail to throw an AssertionError'); + err(() => { + should.fail('foo', 'bar', 'should fail'); + }, 'expected fail to throw an AssertionError'); + err(() => { + should.fail('foo', 'bar', 'should fail', 'equal'); + }, 'expected fail to throw an AssertionError'); + + err(() => { + expect.fail('foo', 'bar'); + }, 'expected fail to throw an AssertionError'); + err(() => { + expect.fail('foo', 'bar', 'should fail'); + }, 'expected fail to throw an AssertionError'); + err(() => { + expect.fail('foo', 'bar', 'should fail', 'equal'); + }, 'expected fail to throw an AssertionError'); +} + +// ReSharper disable once InconsistentNaming +function _true() { + expect(true).to.be.true; + true.should.be.true; + expect(false).to.not.be.true; + false.should.not.be.true; + expect(1).to.not.be.true; + (1).should.not.be.true; + + err(() => { + expect('test').to.be.true; + 'test'.should.be.true; + }, 'expected \'test\' to be true'); +} + +function ok() { + expect(true).to.be.ok; + true.should.be.ok; + expect(false).to.not.be.ok; + false.should.not.be.ok; + expect(1).to.be.ok; + (1).should.be.ok; + expect(0).to.not.be.ok; + (0).should.not.be.ok; + + err(() => { + expect('').to.be.ok; + ''.should.be.ok; + }, 'expected \'\' to be truthy'); + + err(() => { + expect('test').to.not.be.ok; + 'test'.should.not.be.ok; + }, 'expected \'test\' to be falsy'); +} + +function _false() { + expect(false).to.be.false; + false.should.be.false; + expect(true).to.not.be.false; + true.should.not.be.false; + expect(0).to.not.be.false; + (0).should.not.be.false; + + err(() => { + expect('').to.be.false; + ''.should.be.false; + }, 'expected \'\' to be false'); +} + +function _null() { + expect(null).to.be.null; + should.equal(null, null); + expect(false).to.not.be.null; + false.should.not.be.null; + + err(() => { + expect('').to.be.null; + ''.should.be.null; + }, 'expected \'\' to be null'); +} + +function _undefined() { + expect(undefined).to.be.undefined; + should.equal(undefined, undefined); + expect(null).to.not.be.undefined; + should.not.equal(null, undefined); + + err(() => { + expect('').to.be.undefined; + ''.should.be.undefined; + }, 'expected \'\' to be undefined'); +} + +function _NaN() { + expect(NaN).to.be.NaN; + expect(12).to.be.not.NaN; + expect("NaN").to.be.not.NaN; + (NaN).should.be.NaN; + (12).should.be.not.NaN; + ("NaN").should.be.not.NaN; +} + +function exist() { + var foo = 'bar'; + expect(foo).to.exist; + should.exist(foo); + expect(void (0)).to.not.exist; + should.not.exist(void (0)); +} + +function argumentsTest() { + var args = arguments; + expect(args).to.be.arguments; + args.should.be.arguments; + expect([]).to.not.be.arguments; + [].should.not.be.arguments; + expect(args).to.be.an('arguments').and.be.arguments; + args.should.be.an('arguments').and.be.arguments; + expect([]).to.be.an('array').and.not.be.Arguments; + [].should.be.an('array').and.not.be.Arguments; +} + +function equal() { + expect(undefined).to.equal(void (0)); + should.equal(undefined, void (0)); +} + +function _typeof() { + expect('test').to.be.a('string'); + 'test'.should.be.a('string'); + + err(() => { + expect('test').to.not.be.a('string'); + 'test'.should.not.be.a('string'); + }, 'expected \'test\' not to be a string'); + + expect(arguments).to.be.an('arguments'); + arguments.should.be.an('arguments'); + + expect(5).to.be.a('number'); + (5).should.be.a('number'); + + expect(new Number(1)).to.be.a('number'); + (new Number(1)).should.be.a('number'); + expect(Number(1)).to.be.a('number'); + Number(1).should.be.a('number'); + expect(true).to.be.a('boolean'); + true.should.be.a('boolean'); + expect(new Array()).to.be.a('array'); + (new Array()).should.be.a('array'); + expect(new Object()).to.be.a('object'); + (new Object()).should.be.a('object'); + expect({}).to.be.a('object'); + ({}).should.be.a('object'); + expect([]).to.be.a('array'); + [].should.be.a('array'); + expect(() => { }).to.be.a('function'); + (() => { }).should.be.a('function'); + expect(null).to.be.a('null'); + // N.B. previous line has no should equivalent + + err(() => { + expect(5).to.not.be.a('number', 'blah'); + (5).should.not.be.a('number', 'blah'); + }, 'blah: expected 5 not to be a number'); +} + +class Foo { } +function _instanceof() { + expect(new Foo()).to.be.an.instanceof(Foo); + (new Foo()).should.be.an.instanceof(Foo); + + err(() => { + expect(3).to.an.instanceof(Foo, 'blah'); + (3).should.an.instanceof(Foo, 'blah'); + }, 'blah: expected 3 to be an instance of Foo'); +} + +function within() { + expect(5).to.be.within(5, 10); + (5).should.be.within(5, 10); + expect(5).to.be.within(3, 6); + (5).should.be.within(3, 6); + expect(5).to.be.within(3, 5); + (5).should.be.within(3, 5); + expect(5).to.not.be.within(1, 3); + (5).should.not.be.within(1, 3); + expect('foo').to.have.length.within(2, 4); + 'foo'.should.have.length.within(2, 4); + expect([1, 2, 3]).to.have.length.within(2, 4); + [1, 2, 3].should.have.length.within(2, 4); + + err(() => { + expect(5).to.not.be.within(4, 6, 'blah'); + (5).should.not.be.within(4, 6, 'blah'); + }, 'blah: expected 5 to not be within 4..6', 'blah'); + + err(() => { + expect(10).to.be.within(50, 100, 'blah'); + (10).should.be.within(50, 100, 'blah'); + }, 'blah: expected 10 to be within 50..100'); + + err(() => { + expect('foo').to.have.length.within(5, 7, 'blah'); + 'foo'.should.have.length.within(5, 7, 'blah'); + }, 'blah: expected \'foo\' to have a length within 5..7'); + + err(() => { + expect([1, 2, 3]).to.have.length.within(5, 7, 'blah'); + [1, 2, 3].should.have.length.within(5, 7, 'blah'); + }, 'blah: expected [ 1, 2, 3 ] to have a length within 5..7'); +} + +function above() { + expect(5).to.be.above(2); + (5).should.be.above(2); + expect(5).to.be.greaterThan(2); + (5).should.be.greaterThan(2); + expect(5).to.not.be.above(5); + (5).should.not.be.above(5); + expect(5).to.not.be.above(6); + (5).should.not.be.above(6); + expect('foo').to.have.length.above(2); + 'foo'.should.have.length.above(2); + expect([1, 2, 3]).to.have.length.above(2); + [1, 2, 3].should.have.length.above(2); + + err(() => { + expect(5).to.be.above(6, 'blah'); + (5).should.be.above(6, 'blah'); + }, 'blah: expected 5 to be above 6', 'blah'); + + err(() => { + expect(10).to.not.be.above(6, 'blah'); + (10).should.not.be.above(6, 'blah'); + }, 'blah: expected 10 to be at most 6'); + + err(() => { + expect('foo').to.have.length.above(4, 'blah'); + 'foo'.should.have.length.above(4, 'blah'); + }, 'blah: expected \'foo\' to have a length above 4 but got 3'); + + err(() => { + expect([1, 2, 3]).to.have.length.above(4, 'blah'); + [1, 2, 3].should.have.length.above(4, 'blah'); + }, 'blah: expected [ 1, 2, 3 ] to have a length above 4 but got 3'); +} + +function least() { + expect(5).to.be.at.least(2); + (5).should.be.at.least(2); + expect(5).to.be.at.least(5); + (5).should.be.at.least(5); + expect(5).to.not.be.at.least(6); + (5).should.not.be.at.least(6); + expect('foo').to.have.length.of.at.least(2); + 'foo'.should.have.length.of.at.least(2); + expect([1, 2, 3]).to.have.length.of.at.least(2); + [1, 2, 3].should.have.length.of.at.least(2); + + err(() => { + expect(5).to.be.at.least(6, 'blah'); + (5).should.be.at.least(6, 'blah'); + }, 'blah: expected 5 to be at least 6', 'blah'); + + err(() => { + expect(10).to.not.be.at.least(6, 'blah'); + (10).should.not.be.at.least(6, 'blah'); + }, 'blah: expected 10 to be below 6'); + + err(() => { + expect('foo').to.have.length.of.at.least(4, 'blah'); + 'foo'.should.have.length.of.at.least(4, 'blah'); + }, 'blah: expected \'foo\' to have a length at least 4 but got 3'); + + err(() => { + expect([1, 2, 3]).to.have.length.of.at.least(4, 'blah'); + [1, 2, 3].should.have.length.of.at.least(4, 'blah'); + }, 'blah: expected [ 1, 2, 3 ] to have a length at least 4 but got 3'); + + err(() => { + expect([1, 2, 3, 4]).to.not.have.length.of.at.least(4, 'blah'); + [1, 2, 3, 4].should.not.have.length.of.at.least(4, 'blah'); + }, 'blah: expected [ 1, 2, 3, 4 ] to have a length below 4'); +} + +function below() { + expect(2).to.be.below(5); + (2).should.be.below(5); + expect(2).to.be.lessThan(5); + (2).should.be.lessThan(5); + expect(2).to.not.be.below(2); + (2).should.not.be.below(2); + expect(2).to.not.be.below(1); + (2).should.not.be.below(1); + expect('foo').to.have.length.below(4); + 'foo'.should.have.length.below(4); + expect([1, 2, 3]).to.have.length.below(4); + [1, 2, 3].should.have.length.below(4); + + err(() => { + expect(6).to.be.below(5, 'blah'); + (6).should.be.below(5, 'blah'); + }, 'blah: expected 6 to be below 5'); + + err(() => { + expect(6).to.not.be.below(10, 'blah'); + (6).should.not.be.below(10, 'blah'); + }, 'blah: expected 6 to be at least 10'); + + err(() => { + expect('foo').to.have.length.below(2, 'blah'); + 'foo'.should.have.length.below(2, 'blah'); + }, 'blah: expected \'foo\' to have a length below 2 but got 3'); + + err(() => { + expect([1, 2, 3]).to.have.length.below(2, 'blah'); + [1, 2, 3].should.have.length.below(2, 'blah'); + }, 'blah: expected [ 1, 2, 3 ] to have a length below 2 but got 3'); +} + +function most() { + expect(2).to.be.at.most(5); + (2).should.be.at.most(5); + expect(2).to.be.at.most(2); + (2).should.be.at.most(2); + expect(2).to.not.be.at.most(1); + (2).should.not.be.at.most(1); + expect(2).to.not.be.at.most(1); + (2).should.not.be.at.most(1); + expect('foo').to.have.length.of.at.most(4); + 'foo'.should.have.length.of.at.most(4); + expect([1, 2, 3]).to.have.length.of.at.most(4); + [1, 2, 3].should.have.length.of.at.most(4); + + err(() => { + expect(6).to.be.at.most(5, 'blah'); + (6).should.be.at.most(5, 'blah'); + }, 'blah: expected 6 to be at most 5'); + + err(() => { + expect(6).to.not.be.at.most(10, 'blah'); + (6).should.not.be.at.most(10, 'blah'); + }, 'blah: expected 6 to be above 10'); + + err(() => { + expect('foo').to.have.length.of.at.most(2, 'blah'); + 'foo'.should.have.length.of.at.most(2, 'blah'); + }, 'blah: expected \'foo\' to have a length at most 2 but got 3'); + + err(() => { + expect([1, 2, 3]).to.have.length.of.at.most(2, 'blah'); + [1, 2, 3].should.have.length.of.at.most(2, 'blah'); + }, 'blah: expected [ 1, 2, 3 ] to have a length at most 2 but got 3'); + + err(() => { + expect([1, 2]).to.not.have.length.of.at.most(2, 'blah'); + [1, 2].should.not.have.length.of.at.most(2, 'blah'); + }, 'blah: expected [ 1, 2 ] to have a length above 2'); +} + +function match() { + expect('foobar').to.match(/^foo/); + 'foobar'.should.match(/^foo/); + expect('foobar').to.not.match(/^bar/); + 'foobar'.should.not.match(/^bar/); + + expect('foobar').matches(/^foo/); + 'foobar'.should.not.matches(/^bar/); + + err(() => { + expect('foobar').to.match(/^bar/i, 'blah'); + 'foobar'.should.match(/^bar/i, 'blah'); + }, 'blah: expected \'foobar\' to match /^bar/i'); + + err(() => { + expect('foobar').to.not.match(/^foo/i, 'blah'); + 'foobar'.should.not.match(/^foo/i, 'blah'); + }, 'blah: expected \'foobar\' not to match /^foo/i'); +} + +function length2() { + expect('test').to.have.length(4); + 'test'.should.have.length(4); + expect('test').to.not.have.length(3); + 'test'.should.not.have.length(3); + expect([1, 2, 3]).to.have.length(3); + [1, 2, 3].should.have.length(3); + + err(() => { + expect(4).to.have.length(3, 'blah'); + (4).should.have.length(3, 'blah'); + }, 'blah: expected 4 to have a property \'length\''); + + err(() => { + expect('asd').to.not.have.length(3, 'blah'); + 'asd'.should.not.have.length(3, 'blah'); + }, 'blah: expected \'asd\' to not have a length of 3'); +} + +function eql() { + expect('test').to.eql('test'); + 'test'.should.eql('test'); + expect({ foo: 'bar' }).to.eql({ foo: 'bar' }); + ({ foo: 'bar' }).should.eql({ foo: 'bar' }); + expect(1).to.eql(1); + (1).should.eql(1); + expect('4').to.not.eql(4); + '4'.should.not.eql(4); + + err(() => { + expect(4).to.eql(3, 'blah'); + (4).should.eql(3, 'blah'); + }, 'blah: expected 4 to deeply equal 3'); +} + +class Buffer { + constructor(arr: number[]) { + } +} +function buffer() { + expect(new Buffer([1])).to.eql(new Buffer([1])); + (new Buffer([1])).should.eql(new Buffer([1])); + + err(() => { + expect(new Buffer([0])).to.eql(new Buffer([1])); + (new Buffer([0])).should.eql(new Buffer([1])); + }, 'expected to deeply equal '); +} + +function equal2() { + expect('test').to.equal('test'); + 'test'.should.equal('test'); + should.equal('test', 'test'); + expect(1).to.equal(1); + (1).should.equal(1); + should.equal(1, 1); + + err(() => { + expect(4).to.equal(3, 'blah'); + (4).should.equal(3, 'blah'); + should.equal(4, 3, 'blah'); + }, 'blah: expected 4 to equal 3'); + + err(() => { + expect('4').to.equal(4, 'blah'); + '4'.should.equal(4, 'blah'); + should.equal(4, 4, 'blah'); + }, 'blah: expected \'4\' to equal 4'); +} + +function deepEqual() { + expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' }); + ({ foo: 'bar' }).should.deep.equal({ foo: 'bar' }); + expect({ foo: 'bar' }).not.to.deep.equal({ foo: 'baz' }); +} + +function deepEqual2() { + expect(/a/).to.deep.equal(/a/); + /a/.should.deep.equal(/a/); + expect(/a/).not.to.deep.equal(/b/); + expect(/a/).not.to.deep.equal({}); + expect(/a/g).to.deep.equal(/a/g); + /a/g.should.deep.equal(/a/g); + expect(/a/g).not.to.deep.equal(/b/g); + expect(/a/i).to.deep.equal(/a/i); + /a/i.should.deep.equal(/a/i); + expect(/a/i).not.to.deep.equal(/b/i); + expect(/a/m).to.deep.equal(/a/m); + /a/m.should.deep.equal(/a/m); + expect(/a/m).not.to.deep.equal(/b/m); +} + +// ReSharper disable once InconsistentNaming +function deepEqual3() { + var a = new Date(1, 2, 3); + var b = new Date(4, 5, 6); + expect(a).to.deep.equal(a); + a.should.deep.equal(a); + expect(a).not.to.deep.equal(b); + a.should.not.deep.equal(b); + expect(a).not.to.deep.equal({}); + a.should.not.deep.equal({}); +} + +function deepInclude() { + expect(['foo', 'bar']).to.deep.include(['bar', 'foo']); + ['foo', 'bar'].should.deep.include(['bar', 'foo']); + expect(['foo', 'bar']).not.to.deep.equal(['foo', 'baz']); + ['foo', 'bar'].should.not.deep.equal(['foo', 'baz']); +} + +class FakeArgs { + length: number; +} + +function empty() { + FakeArgs.prototype.length = 0; + + expect('').to.be.empty; + + ''.should.be.empty; + expect('foo').not.to.be.empty; + 'foo'.should.not.be.empty; + expect([]).to.be.empty; + [].should.be.empty; + expect(['foo']).not.to.be.empty; + ['foo'].should.not.be.empty; + expect(new FakeArgs).to.be.empty; + (new FakeArgs).should.be.empty; + expect({ arguments: 0 }).not.to.be.empty; + ({ arguments: 0 }).should.not.be.empty; + expect({}).to.be.empty; + ({}).should.be.empty; + expect({ foo: 'bar' }).not.to.be.empty; + ({ foo: 'bar' }).should.not.be.empty; + + err(() => { + expect('').not.to.be.empty; + ''.should.not.be.empty; + }, 'expected \'\' not to be empty'); + + err(() => { + expect('foo').to.be.empty; + 'foo'.should.be.empty; + 'foo'.should.be.empty; + }, 'expected \'foo\' to be empty'); + + err(() => { + expect([]).not.to.be.empty; + [].should.not.be.empty; + }, 'expected [] not to be empty'); + + err(() => { + expect(['foo']).to.be.empty; + ['foo'].should.be.empty; + }, 'expected [ \'foo\' ] to be empty'); + + err(() => { + expect(new FakeArgs).not.to.be.empty; + (new FakeArgs).should.not.be.empty; + }, 'expected { length: 0 } not to be empty'); + + err(() => { + expect({ arguments: 0 }).to.be.empty; + ({ arguments: 0 }).should.be.empty; + }, 'expected { arguments: 0 } to be empty'); + + err(() => { + expect({}).not.to.be.empty; + ({}).should.not.be.empty; + }, 'expected {} not to be empty'); + + err(() => { + expect({ foo: 'bar' }).to.be.empty; + ({ foo: 'bar' }).should.be.empty; + }, 'expected { foo: \'bar\' } to be empty'); +} + +function property() { + expect('test').to.have.property('length'); + 'test'.should.have.property('length'); + expect(4).to.not.have.property('length'); + (4).should.not.have.property('length'); + + expect({ 'foo.bar': 'baz' }) + .to.have.property('foo.bar'); + ({ 'foo.bar': 'baz' }).should.have.property('foo.bar'); + expect({ foo: { bar: 'baz' } }) + .to.not.have.property('foo.bar'); + ({ foo: { bar: 'baz' } }).should.not.have.property('foo.bar'); + + err(() => { + expect('asd').to.have.property('foo'); + 'asd'.should.have.property('foo'); + }, 'expected \'asd\' to have a property \'foo\''); + err(() => { + expect({ foo: { bar: 'baz' } }) + .to.have.property('foo.bar'); + ({ foo: { bar: 'baz' } }).should.have.property('foo.bar'); + }, 'expected { foo: { bar: \'baz\' } } to have a property \'foo.bar\''); +} + +function deepProperty() { + expect({ 'foo.bar': 'baz' }) + .to.not.have.deep.property('foo.bar'); + ({ 'foo.bar': 'baz' }).should + .not.have.deep.property('foo.bar'); + expect({ foo: { bar: 'baz' } }) + .to.have.deep.property('foo.bar'); + ({ foo: { bar: 'baz' } }).should + .have.deep.property('foo.bar'); + + err(() => { + expect({ 'foo.bar': 'baz' }) + .to.have.deep.property('foo.bar'); + ({ 'foo.bar': 'baz' }).should + .have.deep.property('foo.bar'); + }, 'expected { \'foo.bar\': \'baz\' } to have a deep property \'foo.bar\''); +} + +function property2() { + expect('test').to.have.property('length', 4); + 'test'.should.have.property('length', 4); + expect('asd').to.have.property('constructor', String); + 'asd'.should.have.property('constructor', String); + + err(() => { + expect('asd').to.have.property('length', 4, 'blah'); + 'asd'.should.have.property('length', 4, 'blah'); + }, 'blah: expected \'asd\' to have a property \'length\' of 4, but got 3'); + + err(() => { + expect('asd').to.not.have.property('length', 3, 'blah'); + 'asd'.should.not.have.property('length', 3, 'blah'); + }, 'blah: expected \'asd\' to not have a property \'length\' of 3'); + + err(() => { + expect('asd').to.not.have.property('foo', 3, 'blah'); + 'asd'.should.not.have.property('foo', 3, 'blah'); + }, 'blah: \'asd\' has no property \'foo\''); + + err(() => { + expect('asd').to.have.property('constructor', Number, 'blah'); + 'asd'.should.have.property('constructor', Number, 'blah'); + }, 'blah: expected \'asd\' to have a property \'constructor\' of [Function: Number], but got [Function: String]'); +} + +function deepProperty2() { + expect({ foo: { bar: 'baz' } }) + .to.have.deep.property('foo.bar', 'baz'); + ({ foo: { bar: 'baz' } }).should + .have.deep.property('foo.bar', 'baz'); + + err(() => { + expect({ foo: { bar: 'baz' } }) + .to.have.deep.property('foo.bar', 'quux', 'blah'); + ({ foo: { bar: 'baz' } }).should + .have.deep.property('foo.bar', 'quux', 'blah'); + }, 'blah: expected { foo: { bar: \'baz\' } } to have a deep property \'foo.bar\' of \'quux\', but got \'baz\''); + err(() => { + expect({ foo: { bar: 'baz' } }) + .to.not.have.deep.property('foo.bar', 'baz', 'blah'); + ({ foo: { bar: 'baz' } }).should + .not.have.deep.property('foo.bar', 'baz', 'blah'); + }, 'blah: expected { foo: { bar: \'baz\' } } to not have a deep property \'foo.bar\' of \'baz\''); + err(() => { + expect({ foo: 5 }) + .to.not.have.deep.property('foo.bar', 'baz', 'blah'); + ({ foo: 5 }).should + .not.have.deep.property('foo.bar', 'baz', 'blah'); + }, 'blah: { foo: 5 } has no deep property \'foo.bar\''); +} + +function ownProperty() { + expect('test').to.have.ownProperty('length'); + 'test'.should.have.ownProperty('length'); + expect('test').to.haveOwnProperty('length'); + 'test'.should.haveOwnProperty('length'); + expect({ length: 12 }).to.have.ownProperty('length'); + ({ length: 12 }).should.have.ownProperty('length'); + + err(() => { + expect({ length: 12 }).to.not.have.ownProperty('length', 'blah'); + ({ length: 12 }).should.not.have.ownProperty('length', 'blah'); + }, 'blah: expected { length: 12 } to not have own property \'length\''); +} + +function ownPropertyDescriptor() { + expect('test').to.have.ownPropertyDescriptor('length'); + expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 }); + expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 }); + expect('test').to.haveOwnPropertyDescriptor('length').to.have.property('enumerable', false); + expect('test').to.haveOwnPropertyDescriptor('length').to.contain.keys('value'); + + 'test'.should.have.ownPropertyDescriptor('length'); + 'test'.should.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 }); + 'test'.should.not.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 }); + 'test'.should.haveOwnPropertyDescriptor('length').to.have.property('enumerable', false); + 'test'.should.haveOwnPropertyDescriptor('length').to.contain.keys('value'); +} + +function string() { + expect('foobar').to.have.string('bar'); + 'foobar'.should.have.string('bar'); + expect('foobar').to.have.string('foo'); + 'foobar'.should.have.string('foo'); + expect('foobar').to.not.have.string('baz'); + 'foobar'.should.not.have.string('baz'); + + err(() => { + expect(3).to.have.string('baz'); + (3).should.have.string('baz'); + }, 'expected 3 to be a string'); + + err(() => { + expect('foobar').to.have.string('baz', 'blah'); + 'foobar'.should.have.string('baz', 'blah'); + }, 'blah: expected \'foobar\' to contain \'baz\''); + + err(() => { + expect('foobar').to.not.have.string('bar', 'blah'); + 'foobar'.should.not.have.string('bar', 'blah'); + }, 'blah: expected \'foobar\' to not contain \'bar\''); +} + +function include() { + expect(['foo', 'bar']).to.include('foo'); + ['foo', 'bar'].should.include('foo'); + expect(['foo', 'bar']).to.include('foo'); + ['foo', 'bar'].should.include('foo'); + expect(['foo', 'bar']).to.include('bar'); + ['foo', 'bar'].should.include('bar'); + expect([1, 2]).to.include(1); + [1, 2].should.include(1); + expect(['foo', 'bar']).to.not.include('baz'); + ['foo', 'bar'].should.not.include('baz'); + expect(['foo', 'bar']).to.not.include(1); + ['foo', 'bar'].should.not.include(1); + // alias + + expect(['foo', 'bar']).includes('foo'); + ['foo', 'bar'].should.includes('foo'); + + err(() => { + expect(['foo']).to.include('bar', 'blah'); + ['foo'].should.include('bar', 'blah'); + }, 'blah: expected [ \'foo\' ] to include \'bar\''); + + err(() => { + expect(['bar', 'foo']).to.not.include('foo', 'blah'); + ['bar', 'foo'].should.not.include('foo', 'blah'); + }, 'blah: expected [ \'bar\', \'foo\' ] to not include \'foo\''); +} + +function keys() { + expect({ foo: 1 }).to.have.keys(['foo']); + ({ foo: 1 }).should.have.keys(['foo']); + expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']); + ({ foo: 1, bar: 2 }).should.have.keys(['foo', 'bar']); + expect({ foo: 1, bar: 2 }).to.have.keys('foo', 'bar'); + ({ foo: 1, bar: 2 }).should.have.keys('foo', 'bar'); + expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar'); + ({ foo: 1, bar: 2, baz: 3 }).should.contain.keys('foo', 'bar'); + expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('bar', 'foo'); + ({ foo: 1, bar: 2, baz: 3 }).should.contain.keys('bar', 'foo'); + expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('baz'); + ({ foo: 1, bar: 2, baz: 3 }).should.contain.keys('baz'); + // alias + + expect({ foo: 1, bar: 2, baz: 3 }).contains.keys('baz'); + + expect({ foo: 1, bar: 2 }).to.have.all.keys(['foo', 'bar']); + expect({ foo: 1, bar: 2 }).to.have.any.keys(['foo', 'bar']); + ({ foo: 1, bar: 2, baz: 3 }).should.contain.all.keys('baz'); + ({ foo: 1, bar: 2, baz: 3 }).should.contain.any.keys('baz'); + + expect({ foo: 1, bar: 2 }).to.contain.keys('foo'); + ({ foo: 1, bar: 2 }).should.contain.keys('foo'); + expect({ foo: 1, bar: 2 }).to.contain.keys('bar', 'foo'); + ({ foo: 1, bar: 2 }).should.contain.keys('bar', 'foo'); + expect({ foo: 1, bar: 2 }).to.contain.keys(['foo']); + ({ foo: 1, bar: 2 }).should.contain.keys(['foo']); + expect({ foo: 1, bar: 2 }).to.contain.keys(['bar']); + ({ foo: 1, bar: 2 }).should.contain.keys(['bar']); + expect({ foo: 1, bar: 2 }).to.contain.keys(['bar', 'foo']); + ({ foo: 1, bar: 2 }).should.contain.keys(['bar', 'foo']); + + expect({ foo: 1, bar: 2 }).to.not.have.keys('baz'); + ({ foo: 1, bar: 2 }).should.not.have.keys('baz'); + expect({ foo: 1, bar: 2 }).to.not.have.keys('foo', 'baz'); + ({ foo: 1, bar: 2 }).should.not.have.keys('foo', 'baz'); + expect({ foo: 1, bar: 2 }).to.not.contain.keys('baz'); + ({ foo: 1, bar: 2 }).should.not.contain.keys('baz'); + expect({ foo: 1, bar: 2 }).to.not.contain.keys('foo', 'baz'); + ({ foo: 1, bar: 2 }).should.not.contain.keys('foo', 'baz'); + expect({ foo: 1, bar: 2 }).to.not.contain.keys('baz', 'foo'); + ({ foo: 1, bar: 2 }).should.not.contain.keys('baz', 'foo'); + + err(() => { + expect({ foo: 1 }).to.have.keys(); + ({ foo: 1 }).should.have.keys(); + }, 'keys required'); + + err(() => { + expect({ foo: 1 }).to.have.keys([]); + ({ foo: 1 }).should.have.keys([]); + }, 'keys required'); + + err(() => { + expect({ foo: 1 }).to.not.have.keys([]); + ({ foo: 1 }).should.not.have.keys([]); + }, 'keys required'); + + err(() => { + expect({ foo: 1 }).to.contain.keys([]); + ({ foo: 1 }).should.contain.keys([]); + }, 'keys required'); + + err(() => { + expect({ foo: 1 }).to.have.keys(['bar']); + ({ foo: 1 }).should.have.keys(['bar']); + }, 'expected { foo: 1 } to have key \'bar\''); + + err(() => { + expect({ foo: 1 }).to.have.keys(['bar', 'baz']); + ({ foo: 1 }).should.have.keys(['bar', 'baz']); + }, 'expected { foo: 1 } to have keys \'bar\', and \'baz\''); + + err(() => { + expect({ foo: 1 }).to.have.keys(['foo', 'bar', 'baz']); + ({ foo: 1 }).should.have.keys(['foo', 'bar', 'baz']); + }, 'expected { foo: 1 } to have keys \'foo\', \'bar\', and \'baz\''); + + err(() => { + expect({ foo: 1 }).to.not.have.keys(['foo']); + ({ foo: 1 }).should.not.have.keys(['foo']); + }, 'expected { foo: 1 } to not have key \'foo\''); + + err(() => { + expect({ foo: 1 }).to.not.have.keys(['foo']); + ({ foo: 1 }).should.not.have.keys(['foo']); + }, 'expected { foo: 1 } to not have key \'foo\''); + + err(() => { + expect({ foo: 1, bar: 2 }).to.not.have.keys(['foo', 'bar']); + ({ foo: 1, bar: 2 }).should.not.have.keys(['foo', 'bar']); + }, 'expected { foo: 1, bar: 2 } to not have keys \'foo\', and \'bar\''); + + err(() => { + expect({ foo: 1 }).to.not.contain.keys(['foo']); + ({ foo: 1 }).should.not.contain.keys(['foo']); + }, 'expected { foo: 1 } to not contain key \'foo\''); + + err(() => { + expect({ foo: 1 }).to.contain.keys('foo', 'bar'); + ({ foo: 1 }).should.contain.keys('foo', 'bar'); + }, 'expected { foo: 1 } to contain keys \'foo\', and \'bar\''); +} + +function chaining() { + var tea = { name: 'chai', extras: ['milk', 'sugar', 'smile'] }; + expect(tea).to.have.property('extras').with.lengthOf(3); + tea.should.have.property('extras').with.lengthOf(3); + + err(() => { + expect(tea).to.have.property('extras').with.lengthOf(4); + tea.should.have.property('extras').with.lengthOf(4); + }, 'expected [ \'milk\', \'sugar\', \'smile\' ] to have a length of 4 but got 3'); + + expect(tea).to.be.a('object').and.have.property('name', 'chai'); + tea.should.be.a('object').and.have.property('name', 'chai'); +} + +function exxtensible() { + expect({}).to.be.extensible; + expect(Object.preventExtensions({})).to.be.not.extensible; + ({}).should.be.extensible; + Object.preventExtensions({}).should.not.be.extensible; +} +function sealed() { + expect({}).to.be.not.sealed; + expect(Object.seal({})).to.be.sealed; + ({}).should.be.not.sealed; + Object.seal({}).should.be.sealed; +} + +function frozen() { + expect({}).to.be.not.frozen; + expect(Object.freeze({})).to.be.frozen; + ({}).should.be.not.frozen; + Object.freeze({}).should.be.frozen; +} + + +class PoorlyConstructedError { } +function _throw() { + // See GH-45: some poorly-constructed custom errors don't have useful names + // on either their constructor or their constructor prototype, but instead + // only set the name inside the constructor itself. + PoorlyConstructedError.prototype = Object.create(Error.prototype); + + var specificError = new RangeError('boo'); + + var goodFn = () => { } + , badFn = () => { throw new Error('testing'); } + , refErrFn = () => { throw new ReferenceError('hello'); } + , ickyErrFn = () => { throw new PoorlyConstructedError(); } + , specificErrFn = () => { throw specificError; }; + + expect(goodFn).to.not.throw(); + goodFn.should.not.throw(); + should.not.throw(goodFn); + expect(goodFn).to.not.throw(Error); + goodFn.should.not.throw(Error); + should.not.throw(goodFn, Error); + expect(goodFn).to.not.throw(specificError); + goodFn.should.not.throw(specificError); + should.not.throw(goodFn, specificError); + + expect(badFn).to.throw(); + badFn.should.throw(); + should.throw(badFn); + expect(badFn).to.throw(Error); + badFn.should.throw(Error); + should.throw(badFn, Error); + expect(badFn).to.not.throw(ReferenceError); + badFn.should.not.throw(ReferenceError); + should.not.throw(badFn, ReferenceError); + expect(badFn).to.not.throw(specificError); + badFn.should.not.throw(specificError); + should.not.throw(badFn, specificError); + + expect(refErrFn).to.throw(); + refErrFn.should.throw(); + should.throw(refErrFn); + expect(refErrFn).to.throw(ReferenceError); + refErrFn.should.throw(ReferenceError); + should.throw(refErrFn, ReferenceError); + expect(refErrFn).to.throw(Error); + refErrFn.should.throw(Error); + should.throw(refErrFn, Error); + expect(refErrFn).to.not.throw(TypeError); + refErrFn.should.not.throw(TypeError); + should.not.throw(refErrFn, TypeError); + expect(refErrFn).to.not.throw(specificError); + refErrFn.should.not.throw(specificError); + should.not.throw(refErrFn, specificError); + + expect(ickyErrFn).to.throw(); + ickyErrFn.should.throw(); + should.throw(ickyErrFn); + expect(ickyErrFn).to.throw(PoorlyConstructedError); + ickyErrFn.should.throw(PoorlyConstructedError); + should.throw(ickyErrFn, PoorlyConstructedError); + expect(ickyErrFn).to.throw(Error); + ickyErrFn.should.throw(Error); + should.throw(ickyErrFn, Error); + expect(ickyErrFn).to.not.throw(specificError); + ickyErrFn.should.not.throw(specificError); + should.not.throw(ickyErrFn, specificError); + expect(specificErrFn).to.throw(specificError); + specificErrFn.should.throw(specificError); + should.throw(ickyErrFn, specificError); + + expect(badFn).to.throw(/testing/); + badFn.should.throw(/testing/); + should.throw(badFn, /testing/); + expect(badFn).to.not.throw(/hello/); + badFn.should.not.throw(/hello/); + should.not.throw(badFn, /hello/); + expect(badFn).to.throw('testing'); + badFn.should.throw('testing'); + should.throw(badFn, 'testing'); + expect(badFn).to.not.throw('hello'); + badFn.should.not.throw('hello'); + should.not.throw(badFn, 'hello'); + + expect(badFn).to.throw(Error, /testing/); + badFn.should.throw(Error, /testing/); + should.throw(badFn, Error, /testing/); + expect(badFn).to.throw(Error, 'testing'); + badFn.should.throw(Error, 'testing'); + should.throw(badFn, Error, 'testing'); + + err(() => { + expect(goodFn).to.throw(); + goodFn.should.throw(); + should.throw(goodFn); + }, 'expected [Function] to throw an error'); + + err(() => { + expect(goodFn).to.throw(ReferenceError); + goodFn.should.throw(ReferenceError); + should.throw(goodFn, ReferenceError); + }, 'expected [Function] to throw ReferenceError'); + + err(() => { + expect(goodFn).to.throw(specificError); + goodFn.should.throw(specificError); + should.throw(goodFn, specificError); + }, 'expected [Function] to throw [RangeError: boo]'); + + err(() => { + expect(badFn).to.not.throw(); + badFn.should.not.throw(); + should.not.throw(badFn); + }, 'expected [Function] to not throw an error but [Error: testing] was thrown'); + + err(() => { + expect(badFn).to.throw(ReferenceError); + badFn.should.throw(ReferenceError); + should.throw(badFn, ReferenceError); + }, 'expected [Function] to throw \'ReferenceError\' but [Error: testing] was thrown'); + + err(() => { + expect(badFn).to.throw(specificError); + badFn.should.throw(specificError); + should.throw(badFn, specificError); + }, 'expected [Function] to throw [RangeError: boo] but [Error: testing] was thrown'); + + err(() => { + expect(badFn).to.not.throw(Error); + badFn.should.not.throw(Error); + should.not.throw(badFn, Error); + }, 'expected [Function] to not throw \'Error\' but [Error: testing] was thrown'); + + err(() => { + expect(refErrFn).to.not.throw(ReferenceError); + refErrFn.should.not.throw(ReferenceError); + should.not.throw(refErrFn, ReferenceError); + }, 'expected [Function] to not throw \'ReferenceError\' but [ReferenceError: hello] was thrown'); + + err(() => { + expect(badFn).to.throw(PoorlyConstructedError); + badFn.should.throw(PoorlyConstructedError); + should.throw(badFn, PoorlyConstructedError); + }, 'expected [Function] to throw \'PoorlyConstructedError\' but [Error: testing] was thrown'); + + err(() => { + expect(ickyErrFn).to.not.throw(PoorlyConstructedError); + ickyErrFn.should.not.throw(PoorlyConstructedError); + should.not.throw(ickyErrFn, PoorlyConstructedError); + }, /^(expected \[Function\] to not throw 'PoorlyConstructedError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/); + + err(() => { + expect(ickyErrFn).to.throw(ReferenceError); + ickyErrFn.should.throw(ReferenceError); + should.throw(ickyErrFn, ReferenceError); + }, /^(expected \[Function\] to throw 'ReferenceError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/); + + err(() => { + expect(specificErrFn).to.throw(new ReferenceError('eek')); + specificErrFn.should.throw(new ReferenceError('eek')); + should.throw(specificErrFn, new ReferenceError('eek')); + }, 'expected [Function] to throw [ReferenceError: eek] but [RangeError: boo] was thrown'); + + err(() => { + expect(specificErrFn).to.not.throw(specificError); + specificErrFn.should.not.throw(specificError); + should.not.throw(specificErrFn, specificError); + }, 'expected [Function] to not throw [RangeError: boo]'); + + err(() => { + expect(badFn).to.not.throw(/testing/); + badFn.should.not.throw(/testing/); + should.not.throw(badFn, /testing/); + }, 'expected [Function] to throw error not matching /testing/'); + + err(() => { + expect(badFn).to.throw(/hello/); + badFn.should.throw(/hello/); + should.throw(badFn, /hello/); + }, 'expected [Function] to throw error matching /hello/ but got \'testing\''); + + err(() => { + expect(badFn).to.throw(Error, /hello/, 'blah'); + badFn.should.throw(Error, /hello/, 'blah'); + should.throw(badFn, Error, /hello/, 'blah'); + }, 'blah: expected [Function] to throw error matching /hello/ but got \'testing\''); + + err(() => { + expect(badFn).to.throw(Error, 'hello', 'blah'); + badFn.should.throw(Error, 'hello', 'blah'); + should.throw(badFn, Error, 'hello', 'blah'); + }, 'blah: expected [Function] to throw error including \'hello\' but got \'testing\''); +} + +function use() { + // ReSharper disable once InconsistentNaming + chai.use((_chai) => { + _chai.can.use.any(); + }); +} + +class Klass { + val: number; + constructor() { this.val = 0; } + bar() { } + + static baz() { } +} + +function respondTo() { + var obj = new Klass(); + + expect(Klass).to.respondTo('bar'); + expect(obj).respondsTo('bar'); + Klass.should.respondTo('bar'); + Klass.should.respondsTo('bar'); + expect(Klass).to.not.respondTo('foo'); + Klass.should.not.respondTo('foo'); + expect(Klass).itself.to.respondTo('func'); + expect(Klass).itself.not.to.respondTo('bar'); + + expect(obj).not.to.respondTo('foo'); + obj.should.not.respondTo('foo'); + + err(() => { + expect(Klass).to.respondTo('baz', 'constructor'); + Klass.should.respondTo('baz', 'constructor'); + }, /^(constructor: expected)(.*)(\[Function: Klass\])(.*)(to respond to \'baz\')$/); + + err(() => { + expect(obj).to.respondTo('baz', 'object'); + obj.should.respondTo('baz', 'object'); + }, /^(object: expected)(.*)(\{ foo: \[Function\] \}|\{ Object \()(.*)(to respond to \'baz\')$/); +} + +function satisfy() { + function matcher(num: number) { + return num === 1; + } + + expect(1).to.satisfy(matcher); + (1).should.satisfy(matcher); + + err(() => { + expect(2).to.satisfy(matcher, 'blah'); + (2).should.satisfy(matcher, 'blah'); + }, 'blah: expected 2 to satisfy [Function: matcher]'); +} + +function closeTo() { + expect(1.5).to.be.closeTo(1.0, 0.5); + (1.5).should.be.closeTo(1.0, 0.5); + expect(10).to.be.closeTo(20, 20); + (10).should.be.closeTo(20, 20); + expect(-10).to.be.closeTo(20, 30); + (-10).should.be.closeTo(20, 30); + + err(() => { + expect(2).to.be.closeTo(1.0, 0.5, 'blah'); + (2).should.be.closeTo(1.0, 0.5, 'blah'); + }, 'blah: expected 2 to be close to 1 +/- 0.5'); + + err(() => { + expect(-10).to.be.closeTo(20, 29, 'blah'); + (-10).should.be.closeTo(20, 29, 'blah'); + }, 'blah: expected -10 to be close to 20 +/- 29'); +} + +function includeMembers() { + expect([1, 2, 3]).to.include.members([]); + [1, 2, 3].should.include.members([]); + + expect([1, 2, 3]).to.include.members([3, 2]); + + [1, 2, 3].should.include.members([3, 2]); + + expect([1, 2, 3]).to.not.include.members([8, 4]); + + [1, 2, 3].should.not.include.members([8, 4]); + + expect([1, 2, 3]).to.not.include.members([1, 2, 3, 4]); + + [1, 2, 3].should.not.include.members([1, 2, 3, 4]); +} + +function sameMembers() { + expect([5, 4]).to.have.same.members([4, 5]); + [5, 4].should.have.same.members([4, 5]); + expect([5, 4]).to.have.same.members([5, 4]); + [5, 4].should.have.same.members([5, 4]); + + expect([5, 4]).to.not.have.same.members([]); + [5, 4].should.not.have.same.members([]); + expect([5, 4]).to.not.have.same.members([6, 3]); + [5, 4].should.not.have.same.members([6, 3]); + expect([5, 4]).to.not.have.same.members([5, 4, 2]); + [5, 4].should.not.have.same.members([5, 4, 2]); + + assert.sameMembers([5, 4], [4, 5]); +} +function sameDeepMembers() { + expect([{ id: 5 }, { id: 4 }]).to.have.same.deep.members([{ id: 4 }, { id: 5 }]); + [{ id: 5 }, { id: 4 }].should.have.same.deep.members([{ id: 4 }, { id: 5 }]); + expect([{ id: 5 }, { id: 4 }]).to.have.same.members([{ id: 5 }, { id: 4 }]); + [{ id: 5 }, { id: 4 }].should.have.same.members([{ id: 5 }, { id: 4 }]); + + expect([{ id: 5 }, { id: 4 }]).to.not.have.same.members([]); + [{ id: 5 }, { id: 4 }].should.not.have.same.members([]); + expect([{ id: 5 }, { id: 4 }]).to.not.have.same.members([{ id: 6 }, { id: 3 }]); + [{ id: 5 }, { id: 4 }].should.not.have.same.members([{ id: 6 }, { id: 3 }]); + expect([{ id: 5 }, { id: 4 }]).to.not.have.same.members([{ id: 5 }, { id: 4 }, { id: 2 }]); + [{ id: 5 }, { id: 4 }].should.not.have.same.members([{ id: 5 }, { id: 4 }, { id: 2 }]); + + assert.sameDeepMembers([{ id: 5 }, { id: 4 }], [{ id: 4 }, { id: 5 }]); +} + +function members() { + expect([5, 4]).members([4, 5]); + expect([5, 4]).members([5, 4]); + + expect([5, 4]).not.members([]); + expect([5, 4]).not.members([6, 3]); + expect([5, 4]).not.members([5, 4, 2]); +} + +function increaseDecreaseChange() { + var obj = { val: 10 }; + var inc = () => { obj.val++; }; + var dec = () => { obj.val--; }; + var same = () => { }; + + expect(inc).to.increase(obj, "val"); + expect(inc).increases(obj, "val"); + expect(inc).to.change(obj, "val"); + + expect(dec).to.decrease(obj, "val"); + expect(dec).decreases(obj, "val"); + expect(dec).to.change(obj, "val"); + expect(dec).changes(obj, "val"); + + expect(inc).to.not.decrease(obj, "val"); + expect(dec).to.not.increase(obj, "val"); + expect(same).to.not.increase(obj, "val"); + expect(same).to.not.decrease(obj, "val"); + expect(same).to.not.change(obj, "val"); + + inc.should.increase(obj, "val"); + inc.should.change(obj, "val"); + + dec.should.decrease(obj, "val"); + dec.should.change(obj, "val"); + + inc.should.not.decrease(obj, "val"); + dec.should.not.increase(obj, "val"); + same.should.not.change(obj, "val"); +} + +//tdd +declare function suite(description: string, action: Function): void; +declare function test(description: string, action: Function): void; + +interface FieldObj { + field: any; +} + +class CrashyObject { + inspect(): void { + throw new Error('Arg\'s inspect() called even though the test passed'); + } +} + +suite('assert', () => { + + test('assert', () => { + var foo = 'bar'; + assert(foo === 'bar', 'expected foo to equal `bar`'); + + err(() => { + assert(foo === 'baz', 'expected foo to equal `bar`'); + }, 'expected foo to equal `bar`'); + }); + + test('isTrue', () => { + assert.isTrue(true); + + err(() => { + assert.isTrue(false); + }, 'expected false to be true'); + + err(() => { + assert.isTrue(1); + }, 'expected 1 to be true'); + + err(() => { + assert.isTrue('test'); + }, 'expected \'test\' to be true'); + }); + + test('ok', () => { + assert.ok(true); + assert.ok(1); + assert.ok('test'); + assert.isOk(true); + assert.isOk(1); + assert.isOk('test'); + + err(() => { + assert.ok(false); + }, 'expected false to be truthy'); + + err(() => { + assert.ok(0); + }, 'expected 0 to be truthy'); + + err(() => { + assert.ok(''); + }, 'expected \'\' to be truthy'); + }); + + test('notOk', () => { + assert.notOk(false); + assert.notOk(0); + assert.notOk(''); + assert.isNotOk(false); + assert.isNotOk(0); + assert.isNotOk(''); + + err(() => { + assert.notOk(true); + }, 'expected true to be falsy'); + + err(() => { + assert.notOk(1); + }, 'expected 1 to be falsy'); + + err(() => { + assert.notOk('test'); + }, 'expected \'test\' to be falsy'); + }); + + test('isFalse', () => { + assert.isFalse(false); + + err(() => { + assert.isFalse(true); + }, 'expected true to be false'); + + err(() => { + assert.isFalse(0); + }, 'expected 0 to be false'); + }); + + test('equal', () => { + assert.equal(void (0), undefined); + }); + + test('typeof / notTypeOf', () => { + assert.typeOf('test', 'string'); + assert.typeOf(true, 'boolean'); + assert.typeOf(5, 'number'); + + err(() => { + assert.typeOf(5, 'string'); + }, 'expected 5 to be a string'); + + }); + + test('notTypeOf', () => { + assert.notTypeOf('test', 'number'); + + err(() => { + assert.notTypeOf(5, 'number'); + }, 'expected 5 not to be a number'); + }); + + test('instanceOf', () => { + assert.instanceOf(new Foo(), Foo); + + err(() => { + assert.instanceOf(5, Foo); + }, 'expected 5 to be an instance of Foo'); + assert.instanceOf(new CrashyObject(), CrashyObject); + }); + + test('notInstanceOf', () => { + assert.notInstanceOf(new Foo(), String); + + err(() => { + assert.notInstanceOf(new Foo(), Foo); + }, 'expected {} to not be an instance of Foo'); + }); + + test('isObject', () => { + assert.isObject({}); + assert.isObject(new Foo()); + + err(() => { + assert.isObject(true); + }, 'expected true to be an object'); + + err(() => { + assert.isObject(Foo); + }, 'expected [Function: Foo] to be an object'); + + err(() => { + assert.isObject('foo'); + }, 'expected \'foo\' to be an object'); + }); + + test('isNotObject', () => { + assert.isNotObject(5); + + err(() => { + assert.isNotObject({}); + }, 'expected {} not to be an object'); + }); + + test('notEqual', () => { + assert.notEqual(3, 4); + + err(() => { + assert.notEqual(5, 5); + }, 'expected 5 to not equal 5'); + }); + + test('strictEqual', () => { + assert.strictEqual('foo', 'foo'); + + err(() => { + assert.strictEqual('5', 5); + }, 'expected \'5\' to equal 5'); + }); + + test('notStrictEqual', () => { + assert.notStrictEqual(5, '5'); + + err(() => { + assert.notStrictEqual(5, 5); + }, 'expected 5 to not equal 5'); + }); + + test('deepEqual', () => { + assert.deepEqual({ tea: 'chai' }, { tea: 'chai' }); + + err(() => { + assert.deepEqual({ tea: 'chai' }, { tea: 'black' }); + }, 'expected { tea: \'chai\' } to deeply equal { tea: \'black\' }'); + + var obja = Object.create({ tea: 'chai' }) + , objb = Object.create({ tea: 'chai' }); + + assert.deepEqual(obja, objb); + + var obj1 = Object.create({ tea: 'chai' }) + , obj2 = Object.create({ tea: 'black' }); + + err(() => { + assert.deepEqual(obj1, obj2); + }, 'expected { tea: \'chai\' } to deeply equal { tea: \'black\' }'); + }); + + test('deepEqual (ordering)', () => { + var a = { a: 'b', c: 'd' } + , b = { c: 'd', a: 'b' }; + assert.deepEqual(a, b); + }); + + test('deepEqual (circular)', () => { + var circularObject: any = {} + , secondCircularObject: any = {}; + circularObject.field = circularObject; + secondCircularObject.field = secondCircularObject; + + assert.deepEqual(circularObject, secondCircularObject); + + err(() => { + secondCircularObject.field2 = secondCircularObject; + assert.deepEqual(circularObject, secondCircularObject); + }, 'expected { field: [Circular] } to deeply equal { Object (field, field2) }'); + }); + + test('notDeepEqual', () => { + assert.notDeepEqual({ tea: 'jasmine' }, { tea: 'chai' }); + err(() => { + assert.notDeepEqual({ tea: 'chai' }, { tea: 'chai' }); + }, 'expected { tea: \'chai\' } to not deeply equal { tea: \'chai\' }'); + }); + + test('notDeepEqual (circular)', () => { + var circularObject: any = {} + , secondCircularObject: any = { tea: 'jasmine' }; + circularObject.field = circularObject; + secondCircularObject.field = secondCircularObject; + + assert.notDeepEqual(circularObject, secondCircularObject); + + err(() => { + delete secondCircularObject.tea; + assert.notDeepEqual(circularObject, secondCircularObject); + }, 'expected { field: [Circular] } to not deeply equal { field: [Circular] }'); + }); + + test('isNull', () => { + assert.isNull(null); + + err(() => { + assert.isNull(undefined); + }, 'expected undefined to equal null'); + }); + + test('isNotNull', () => { + assert.isNotNull(undefined); + + err(() => { + assert.isNotNull(null); + }, 'expected null to not equal null'); + }); + + test('isUndefined', () => { + assert.isUndefined(undefined); + + err(() => { + assert.isUndefined(null); + }, 'expected null to equal undefined'); + }); + + test('isDefined', () => { + assert.isDefined(null); + + err(() => { + assert.isDefined(undefined); + }, 'expected undefined to not equal undefined'); + }); + + test('isNaN', () => { + assert.isNaN(NaN); + + err(() => { + assert.isNaN(12); + }, 'expected 12 to be NaN'); + }); + + test('isNotNaN', () => { + assert.isNotNaN(12); + + err(() => { + assert.isNotNaN(NaN); + }, 'expected NaN to not NaN'); + }); + + test('isFunction', () => { + var func = () => { + }; + assert.isFunction(func); + + err(() => { + assert.isFunction({}); + }, 'expected {} to be a function'); + }); + + test('isNotFunction', () => { + assert.isNotFunction(5); + + err(() => { + assert.isNotFunction(() => { + }); + }, 'expected [Function] not to be a function'); + }); + + test('isArray', () => { + assert.isArray([]); + assert.isArray(new Array()); + + err(() => { + assert.isArray({}); + }, 'expected {} to be an array'); + }); + + test('isNotArray', () => { + assert.isNotArray(3); + + err(() => { + assert.isNotArray([]); + }, 'expected [] not to be an array'); + + err(() => { + assert.isNotArray(new Array()); + }, 'expected [] not to be an array'); + }); + + test('isString', () => { + assert.isString('Foo'); + assert.isString(new String('foo')); + + err(() => { + assert.isString(1); + }, 'expected 1 to be a string'); + }); + + test('isNotString', () => { + assert.isNotString(3); + assert.isNotString(['hello']); + + err(() => { + assert.isNotString('hello'); + }, 'expected \'hello\' not to be a string'); + }); + + test('isNumber', () => { + assert.isNumber(1); + assert.isNumber(Number('3')); + + err(() => { + assert.isNumber('1'); + }, 'expected \'1\' to be a number'); + }); + + test('isNotNumber', () => { + assert.isNotNumber('hello'); + assert.isNotNumber([5]); + + err(() => { + assert.isNotNumber(4); + }, 'expected 4 not to be a number'); + }); + + test('isBoolean', () => { + assert.isBoolean(true); + assert.isBoolean(false); + + err(() => { + assert.isBoolean('1'); + }, 'expected \'1\' to be a boolean'); + }); + + test('isNotBoolean', () => { + assert.isNotBoolean('true'); + + err(() => { + assert.isNotBoolean(true); + }, 'expected true not to be a boolean'); + + err(() => { + assert.isNotBoolean(false); + }, 'expected false not to be a boolean'); + }); + + test('include', () => { + assert.include('foobar', 'bar'); + assert.include([1, 2, 3], 3); + + err(() => { + assert.include('foobar', 'baz'); + }, 'expected \'foobar\' to contain \'baz\''); + + err(() => { + assert.include(undefined, 'bar'); + }, 'expected an array or string'); + }); + + test('notInclude', () => { + assert.notInclude('foobar', 'baz'); + assert.notInclude([1, 2, 3], 4); + + err(() => { + assert.notInclude('foobar', 'bar'); + }, 'expected \'foobar\' to not contain \'bar\''); + + err(() => { + assert.notInclude(undefined, 'bar'); + }, 'expected an array or string'); + }); + + test('lengthOf', () => { + assert.lengthOf([1, 2, 3], 3); + assert.lengthOf('foobar', 6); + + err(() => { + assert.lengthOf('foobar', 5); + }, 'expected \'foobar\' to have a length of 5 but got 6'); + + err(() => { + assert.lengthOf(1, 5); + }, 'expected 1 to have a property \'length\''); + }); + + test('match', () => { + assert.match('foobar', /^foo/); + assert.notMatch('foobar', /^bar/); + + err(() => { + assert.match('foobar', /^bar/i); + }, 'expected \'foobar\' to match /^bar/i'); + + err(() => { + assert.notMatch('foobar', /^foo/i); + }, 'expected \'foobar\' not to match /^foo/i'); + }); + + test('property', () => { + var obj = { foo: { bar: 'baz' } }; + var simpleObj = { foo: 'bar' }; + assert.property(obj, 'foo'); + assert.deepProperty(obj, 'foo.bar'); + assert.notProperty(obj, 'baz'); + assert.notProperty(obj, 'foo.bar'); + assert.notDeepProperty(obj, 'foo.baz'); + assert.deepPropertyVal(obj, 'foo.bar', 'baz'); + assert.deepPropertyNotVal(obj, 'foo.bar', 'flow'); + + err(() => { + assert.property(obj, 'baz'); + }, 'expected { foo: { bar: \'baz\' } } to have a property \'baz\''); + + err(() => { + assert.deepProperty(obj, 'foo.baz'); + }, 'expected { foo: { bar: \'baz\' } } to have a deep property \'foo.baz\''); + + err(() => { + assert.notProperty(obj, 'foo'); + }, 'expected { foo: { bar: \'baz\' } } to not have property \'foo\''); + + err(() => { + assert.notDeepProperty(obj, 'foo.bar'); + }, 'expected { foo: { bar: \'baz\' } } to not have deep property \'foo.bar\''); + + err(() => { + assert.propertyVal(simpleObj, 'foo', 'ball'); + }, 'expected { foo: \'bar\' } to have a property \'foo\' of \'ball\', but got \'bar\''); + + err(() => { + assert.deepPropertyVal(obj, 'foo.bar', 'ball'); + }, 'expected { foo: { bar: \'baz\' } } to have a deep property \'foo.bar\' of \'ball\', but got \'baz\''); + + err(() => { + assert.propertyNotVal(simpleObj, 'foo', 'bar'); + }, 'expected { foo: \'bar\' } to not have a property \'foo\' of \'bar\''); + + err(() => { + assert.deepPropertyNotVal(obj, 'foo.bar', 'baz'); + }, 'expected { foo: { bar: \'baz\' } } to not have a deep property \'foo.bar\' of \'baz\''); + }); + + test('throws', () => { + assert.throws(() => { + throw new Error('foo'); + }); + assert.throws(() => { + throw new Error('bar'); + }, 'bar'); + assert.throws(() => { + throw new Error('bar'); + }, /bar/); + assert.throws(() => { + throw new Error('bar'); + }, Error); + assert.throws(() => { + throw new Error('bar'); + }, Error, 'bar'); + + err(() => { + assert.throws(() => { + throw new Error('foo'); + }, TypeError); + }, 'expected [Function] to throw \'TypeError\' but [Error: foo] was thrown'); + + err(() => { + assert.throws(() => { + throw new Error('foo'); + }, 'bar'); + }, 'expected [Function] to throw error including \'bar\' but got \'foo\''); + + err(() => { + assert.throws(() => { + throw new Error('foo'); + }, Error, 'bar'); + }, 'expected [Function] to throw error including \'bar\' but got \'foo\''); + + err(() => { + assert.throws(() => { + throw new Error('foo'); + }, TypeError, 'bar'); + }, 'expected [Function] to throw \'TypeError\' but [Error: foo] was thrown'); + + err(() => { + assert.throws(() => { + }); + }, 'expected [Function] to throw an error'); + + err(() => { + assert.throws(() => { + throw new Error(''); + }, 'bar'); + }, 'expected [Function] to throw error including \'bar\' but got \'\''); + + err(() => { + assert.throws(() => { + throw new Error(''); + }, /bar/); + }, 'expected [Function] to throw error matching /bar/ but got \'\''); + }); + + test('doesNotThrow', () => { + assert.doesNotThrow(() => { + }); + assert.doesNotThrow(() => { + }, 'foo'); + + err(() => { + assert.doesNotThrow(() => { + throw new Error('foo'); + }); + }, 'expected [Function] to not throw an error but [Error: foo] was thrown'); + }); + + test('ifError', () => { + assert.ifError(false); + assert.ifError(null); + assert.ifError(undefined); + + err(() => { + assert.ifError('foo'); + }, 'expected \'foo\' to be falsy'); + }); + + test('operator', () => { + assert.operator(1, '<', 2); + assert.operator(2, '>', 1); + assert.operator(1, '==', 1); + assert.operator(1, '<=', 1); + assert.operator(1, '>=', 1); + assert.operator(1, '!=', 2); + assert.operator(1, '!==', 2); + + err(() => { + assert.operator(1, '=', 2); + }, 'Invalid operator "="'); + + err(() => { + assert.operator(2, '<', 1); + }, 'expected 2 to be < 1'); + + err(() => { + assert.operator(1, '>', 2); + }, 'expected 1 to be > 2'); + + err(() => { + assert.operator(1, '==', 2); + }, 'expected 1 to be == 2'); + + err(() => { + assert.operator(2, '<=', 1); + }, 'expected 2 to be <= 1'); + + err(() => { + assert.operator(1, '>=', 2); + }, 'expected 1 to be >= 2'); + + err(() => { + assert.operator(1, '!=', 1); + }, 'expected 1 to be != 1'); + + err(() => { + assert.operator(1, '!==', '1'); + }, 'expected 1 to be !== \'1\''); + }); + + test('closeTo', () => { + assert.closeTo(1.5, 1.0, 0.5); + assert.closeTo(10, 20, 20); + assert.closeTo(-10, 20, 30); + + err(() => { + assert.closeTo(2, 1.0, 0.5); + }, 'expected 2 to be close to 1 +/- 0.5'); + + err(() => { + assert.closeTo(-10, 20, 29); + }, 'expected -10 to be close to 20 +/- 29'); + }); + + test('members', () => { + assert.includeMembers([1, 2, 3], [2, 3]); + assert.includeMembers([1, 2, 3], []); + assert.includeMembers([1, 2, 3], [3]); + + err(() => { + assert.includeMembers([5, 6], [7, 8]); + }, 'expected [ 5, 6 ] to be a superset of [ 7, 8 ]'); + + err(() => { + assert.includeMembers([5, 6], [5, 6, 0]); + }, 'expected [ 5, 6 ] to be a superset of [ 5, 6, 0 ]'); + }); + + test('memberEquals', () => { + assert.sameMembers([], []); + assert.sameMembers([1, 2, 3], [3, 2, 1]); + assert.sameMembers([4, 2], [4, 2]); + + err(() => { + assert.sameMembers([], [1, 2]); + }, 'expected [] to have the same members as [ 1, 2 ]'); + + err(() => { + assert.sameMembers([1, 54], [6, 1, 54]); + }, 'expected [ 1, 54 ] to have the same members as [ 6, 1, 54 ]'); + }); + + + test('isAbove', () => { + assert.isAbove(10, 5); + + err(() => { + assert.isAbove(1, 5); + }, 'expected 1 to be above 5'); + err(() => { + assert.isAbove(5, 5); + }, 'expected 5 to be above 5'); + }); + + test('isBelow', () => { + assert.isBelow(5, 10); + + err(() => { + assert.isBelow(5, 1); + }, 'expected 5 to be above 1'); + err(() => { + assert.isBelow(5, 5); + }, 'expected 5 to be below 5'); + }); + + test('extensible', () => { assert.extensible({}); }); + test('isExtensible', () => { assert.isExtensible({}); }); + test('notExtensible', () => { assert.notExtensible(Object.preventExtensions({})); }); + test('isNotExtensible', () => { assert.isNotExtensible(Object.preventExtensions({})); }); + + test('sealed', () => { assert.sealed(Object.seal({})); }); + test('isSealed', () => { assert.isSealed(Object.seal({})); }); + test('notSealed', () => { assert.notSealed({}); }); + test('isNotSealed', () => { assert.isNotSealed({}); }); + + test('frozen', () => { assert.frozen(Object.freeze({})); }); + test('isFrozen', () => { assert.isFrozen(Object.freeze({})); }); + test('notFrozen', () => { assert.notFrozen({}); }); + test('isNotFrozen', () => { assert.isNotFrozen({}); }); + +}); From e16ce4a79a83a6c31e90c8661903dc2c36ae511d Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Sat, 19 Dec 2015 03:25:03 +0100 Subject: [PATCH 164/353] export HttpError thanks to a namespace --- http-errors/http-errors-tests.ts | 2 + http-errors/http-errors.d.ts | 156 ++++++++++++++++--------------- 2 files changed, 82 insertions(+), 76 deletions(-) diff --git a/http-errors/http-errors-tests.ts b/http-errors/http-errors-tests.ts index 9ee89d6a6..440325900 100644 --- a/http-errors/http-errors-tests.ts +++ b/http-errors/http-errors-tests.ts @@ -67,3 +67,5 @@ var err = new createError['404'](); //createError['404'](); // TypeScript should fail with "Did you mean to include 'new'?" //new createError(); // TypeScript should fail with "Only a void function can be called with the 'new' keyword" + +let error: createError.HttpError; diff --git a/http-errors/http-errors.d.ts b/http-errors/http-errors.d.ts index 6f78ff6a7..e15a7cb4e 100644 --- a/http-errors/http-errors.d.ts +++ b/http-errors/http-errors.d.ts @@ -4,82 +4,86 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module 'http-errors' { - interface HttpError extends Error { - status: number; - statusCode: number; - expose: boolean; + namespace createHttpError { + + // See https://github.com/jshttp/http-errors/blob/1.3.1/index.js#L42 + interface HttpError extends Error { + status: number; + statusCode: number; + expose: boolean; + } + + interface CreateHttpError { + // See https://github.com/Microsoft/TypeScript/issues/227#issuecomment-50092674 + [code: string]: new() => HttpError; + + (...args: Array): HttpError; + + Continue: new() => HttpError; + SwitchingProtocols: new() => HttpError; + Processing: new() => HttpError; + OK: new() => HttpError; + Created: new() => HttpError; + Accepted: new() => HttpError; + NonAuthoritativeInformation: new() => HttpError; + NoContent: new() => HttpError; + ResetContent: new() => HttpError; + PartialContent: new() => HttpError; + MultiStatus: new() => HttpError; + AlreadyReported: new() => HttpError; + IMUsed: new() => HttpError; + MultipleChoices: new() => HttpError; + MovedPermanently: new() => HttpError; + Found: new() => HttpError; + SeeOther: new() => HttpError; + NotModified: new() => HttpError; + UseProxy: new() => HttpError; + Unused: new() => HttpError; + TemporaryRedirect: new() => HttpError; + PermanentRedirect: new() => HttpError; + BadRequest: new() => HttpError; + Unauthorized: new() => HttpError; + PaymentRequired: new() => HttpError; + Forbidden: new() => HttpError; + NotFound: new() => HttpError; + MethodNotAllowed: new() => HttpError; + NotAcceptable: new() => HttpError; + ProxyAuthenticationRequired: new() => HttpError; + RequestTimeout: new() => HttpError; + Conflict: new() => HttpError; + Gone: new() => HttpError; + LengthRequired: new() => HttpError; + PreconditionFailed: new() => HttpError; + PayloadTooLarge: new() => HttpError; + URITooLong: new() => HttpError; + UnsupportedMediaType: new() => HttpError; + RangeNotSatisfiable: new() => HttpError; + ExpectationFailed: new() => HttpError; + ImATeapot: new() => HttpError; + UnprocessableEntity: new() => HttpError; + Locked: new() => HttpError; + FailedDependency: new() => HttpError; + UnorderedCollection: new() => HttpError; + UpgradeRequired: new() => HttpError; + PreconditionRequired: new() => HttpError; + TooManyRequests: new() => HttpError; + RequestHeaderFieldsTooLarge: new() => HttpError; + UnavailableForLegalReasons: new() => HttpError; + InternalServerError: new() => HttpError; + NotImplemented: new() => HttpError; + BadGateway: new() => HttpError; + ServiceUnavailable: new() => HttpError; + GatewayTimeout: new() => HttpError; + HTTPVersionNotSupported: new() => HttpError; + VariantAlsoNegotiates: new() => HttpError; + InsufficientStorage: new() => HttpError; + LoopDetected: new() => HttpError; + BandwidthLimitExceeded: new() => HttpError; + NotExtended: new() => HttpError; + NetworkAuthenticationRequired: new() => HttpError; + } } - interface CreateHttpError { - // See https://github.com/Microsoft/TypeScript/issues/227#issuecomment-50092674 - [code: string]: new() => HttpError; - - (...args: Array): HttpError; - - Continue: new() => HttpError; - SwitchingProtocols: new() => HttpError; - Processing: new() => HttpError; - OK: new() => HttpError; - Created: new() => HttpError; - Accepted: new() => HttpError; - NonAuthoritativeInformation: new() => HttpError; - NoContent: new() => HttpError; - ResetContent: new() => HttpError; - PartialContent: new() => HttpError; - MultiStatus: new() => HttpError; - AlreadyReported: new() => HttpError; - IMUsed: new() => HttpError; - MultipleChoices: new() => HttpError; - MovedPermanently: new() => HttpError; - Found: new() => HttpError; - SeeOther: new() => HttpError; - NotModified: new() => HttpError; - UseProxy: new() => HttpError; - Unused: new() => HttpError; - TemporaryRedirect: new() => HttpError; - PermanentRedirect: new() => HttpError; - BadRequest: new() => HttpError; - Unauthorized: new() => HttpError; - PaymentRequired: new() => HttpError; - Forbidden: new() => HttpError; - NotFound: new() => HttpError; - MethodNotAllowed: new() => HttpError; - NotAcceptable: new() => HttpError; - ProxyAuthenticationRequired: new() => HttpError; - RequestTimeout: new() => HttpError; - Conflict: new() => HttpError; - Gone: new() => HttpError; - LengthRequired: new() => HttpError; - PreconditionFailed: new() => HttpError; - PayloadTooLarge: new() => HttpError; - URITooLong: new() => HttpError; - UnsupportedMediaType: new() => HttpError; - RangeNotSatisfiable: new() => HttpError; - ExpectationFailed: new() => HttpError; - ImATeapot: new() => HttpError; - UnprocessableEntity: new() => HttpError; - Locked: new() => HttpError; - FailedDependency: new() => HttpError; - UnorderedCollection: new() => HttpError; - UpgradeRequired: new() => HttpError; - PreconditionRequired: new() => HttpError; - TooManyRequests: new() => HttpError; - RequestHeaderFieldsTooLarge: new() => HttpError; - UnavailableForLegalReasons: new() => HttpError; - InternalServerError: new() => HttpError; - NotImplemented: new() => HttpError; - BadGateway: new() => HttpError; - ServiceUnavailable: new() => HttpError; - GatewayTimeout: new() => HttpError; - HTTPVersionNotSupported: new() => HttpError; - VariantAlsoNegotiates: new() => HttpError; - InsufficientStorage: new() => HttpError; - LoopDetected: new() => HttpError; - BandwidthLimitExceeded: new() => HttpError; - NotExtended: new() => HttpError; - NetworkAuthenticationRequired: new() => HttpError; - } - - var httpError: CreateHttpError; - export = httpError; + var createHttpError: createHttpError.CreateHttpError; + export = createHttpError; } From b42e2a25b6e7f0314b7cc9ddd51638870e80c424 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Sat, 19 Dec 2015 03:26:50 +0100 Subject: [PATCH 165/353] export Response thanks to a namespace --- api-error-handler/api-error-handler-tests.ts | 2 ++ api-error-handler/api-error-handler.d.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/api-error-handler/api-error-handler-tests.ts b/api-error-handler/api-error-handler-tests.ts index 0d0ca85d9..fc92cf9a7 100644 --- a/api-error-handler/api-error-handler-tests.ts +++ b/api-error-handler/api-error-handler-tests.ts @@ -9,3 +9,5 @@ api.get('/users/:userid', function (req, res, next) { }); api.use(errorHandler()); + +let res: errorHandler.Response; diff --git a/api-error-handler/api-error-handler.d.ts b/api-error-handler/api-error-handler.d.ts index d66aabf9b..90318acd0 100644 --- a/api-error-handler/api-error-handler.d.ts +++ b/api-error-handler/api-error-handler.d.ts @@ -8,6 +8,22 @@ declare module 'api-error-handler' { import * as express from 'express'; + namespace apiErrorHandler { + + // Body response: the JSON returned by api-error-handler + // See https://github.com/expressjs/api-error-handler/blob/1.0.0/index.js + interface Response { + status: number; + stack?: string; + message: string; + + // Client errors + code?: any; + name?: string; + type?: any; + } + } + function apiErrorHandler(options?: any): express.ErrorRequestHandler; export = apiErrorHandler; From 95c02169ba8fa58ac1092422efbd2e3174a206f4 Mon Sep 17 00:00:00 2001 From: Jungman Date: Sat, 19 Dec 2015 20:35:43 +0900 Subject: [PATCH 166/353] Add missing properties for webpack --- webpack/webpack-tests.ts | 27 +++++++++++++++++++++++++++ webpack/webpack.d.ts | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 27a4a5385..8d794968f 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -232,6 +232,33 @@ configuration = { configuration = { output: { chunkFilename: "[chunkhash].bundle.js" } }; +// +// https://webpack.github.io/docs/configuration.html +// + +configuration = { + entry: [ + "./entry1", + "./entry2" + ] +}; + +configuration = { + devtool: "#inline-source-map" +}; + +loader = { + test: /\.jsx$/, + include: [ + path.resolve(__dirname, "app/src"), + path.resolve(__dirname, "app/test") + ], + exclude: [ + path.resolve(__dirname, "node_modules") + ], + loader: "babel-loader" +}; + declare var require: any; declare var path: any; configuration = { diff --git a/webpack/webpack.d.ts b/webpack/webpack.d.ts index f2049bbc9..3889446b2 100644 --- a/webpack/webpack.d.ts +++ b/webpack/webpack.d.ts @@ -6,7 +6,8 @@ declare module "webpack" { namespace webpack { interface Configuration { - entry?: string|Entry; + entry?: string|string[]|Entry; + devtool?: string; output?: Output; module?: Module; plugins?: (Plugin|Function)[]; @@ -28,6 +29,8 @@ declare module "webpack" { } interface Loader { + exclude?: string[]; + include?: string[]; test: RegExp; loader?: string; loaders?: string[]; From 86897d7a5c90e73abbf313a38e58797410e9b1f4 Mon Sep 17 00:00:00 2001 From: Hugo ESQUIBET Date: Sat, 19 Dec 2015 16:47:34 +0100 Subject: [PATCH 167/353] adding react-select typings support from https://github.com/JedWatson/react-select --- react-select/react-select.d.ts | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 react-select/react-select.d.ts diff --git a/react-select/react-select.d.ts b/react-select/react-select.d.ts new file mode 100644 index 000000000..b79126345 --- /dev/null +++ b/react-select/react-select.d.ts @@ -0,0 +1,63 @@ +/// + +// Typings for https://github.com/JedWatson/react-select +//***Usage*** +// import ReactSelect = require('react-select'); +// + +declare module "react-select" { + // Import React + import React = require("react"); + + interface Option{ + label : string; + value : any; + } + + interface ReactSelectProps extends React.Props{ + addLabelText? : string; + allowCreate? : boolean; + asyncOptions? : ()=>any; + autoload? : boolean; + backspaceRemoves? : boolean; + cacheAsyncResults? : boolean; + className? : string; + clearable? : boolean; + clearAllText? : string; + clearValueText? : string; + delimiter? : string; + disabled? : boolean; + filterOption? : (option,filterString : string)=>any; + filterOptions? : (options:Array,filterString : string,values : Array)=>any; + ignoreCase? : boolean; // default true whether to perform case-insensitive filtering + inputProps? : any; + isLoading? : boolean; + labelKey? : string; + matchPos? : string; + matchProp? : string; + multi? : boolean; + name? : string; + newOptionCreator? : ()=>any; + noResultsText? : string; + onBlur? : (event)=>void; + onChange? : (newValue)=>void; + onFocus? : (event)=>void; + onInputChange? : (inputValue)=>void; + onOptionLabelClick? : (value, event)=>void; + optionRenderer? : ()=>void; + options? : Array