From e0fdec22052b3d00b7bcfcf2e851731d690fc876 Mon Sep 17 00:00:00 2001 From: Michael McKenzie Date: Tue, 19 Jul 2016 09:57:58 +0100 Subject: [PATCH 01/81] Changing hitch signature to match documentation --- dojo/dojo.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dojo/dojo.d.ts b/dojo/dojo.d.ts index bf3258a14a..687dba4cf7 100644 --- a/dojo/dojo.d.ts +++ b/dojo/dojo.d.ts @@ -5617,7 +5617,7 @@ declare namespace dojo { * @param scope The scope to use when method executes. If method is a string,scope is also the object containing method. * @param method A function to be hitched to scope, or the name of the method inscope to be hitched. */ - hitch(scope: Object, method: Function): any; + hitch(scope: Object, method: (...args: any[]) => any): any; /** * Returns a function that will only ever execute in the a given scope. * This allows for easy use of object member functions @@ -5631,7 +5631,7 @@ declare namespace dojo { * @param scope The scope to use when method executes. If method is a string,scope is also the object containing method. * @param method A function to be hitched to scope, or the name of the method inscope to be hitched. */ - hitch(scope: Object, method: String[]): any; + hitch(scope: Object, method: string): any; /** * Returns true if it is a built-in function or some other kind of * oddball that should report as a function but doesn't From 5cca8b39b92d6d408205edabd827e80caae73282 Mon Sep 17 00:00:00 2001 From: Michael McKenzie Date: Tue, 19 Jul 2016 11:16:55 +0100 Subject: [PATCH 02/81] Changing hitch signature to match documentation --- dojo/dojo.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dojo/dojo.d.ts b/dojo/dojo.d.ts index 687dba4cf7..8a566a46f5 100644 --- a/dojo/dojo.d.ts +++ b/dojo/dojo.d.ts @@ -5617,7 +5617,7 @@ declare namespace dojo { * @param scope The scope to use when method executes. If method is a string,scope is also the object containing method. * @param method A function to be hitched to scope, or the name of the method inscope to be hitched. */ - hitch(scope: Object, method: (...args: any[]) => any): any; + hitch(scope: Object, method: (...args: any[]) => any, ...args: any[]): any; /** * Returns a function that will only ever execute in the a given scope. * This allows for easy use of object member functions @@ -5631,7 +5631,7 @@ declare namespace dojo { * @param scope The scope to use when method executes. If method is a string,scope is also the object containing method. * @param method A function to be hitched to scope, or the name of the method inscope to be hitched. */ - hitch(scope: Object, method: string): any; + hitch(scope: Object, method: string, ...args: any[]): any; /** * Returns true if it is a built-in function or some other kind of * oddball that should report as a function but doesn't From cdfb764333a69c177fa59837d92a98b03f564538 Mon Sep 17 00:00:00 2001 From: Michael McKenzie Date: Tue, 19 Jul 2016 11:40:06 +0100 Subject: [PATCH 03/81] Changing dojo/_base/lang mixin signature to match documentation --- dojo/dojo.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dojo/dojo.d.ts b/dojo/dojo.d.ts index 8a566a46f5..cddc6445bb 100644 --- a/dojo/dojo.d.ts +++ b/dojo/dojo.d.ts @@ -5686,7 +5686,7 @@ declare namespace dojo { * @param dest The object to which to copy/add all properties contained in source. If dest is falsy, thena new object is manufactured before copying/adding properties begins. * @param sources One of more objects from which to draw all properties to copy into dest. sources are processedleft-to-right and if more than one of these objects contain the same property name, the right-mostvalue "wins". */ - mixin(dest: Object, sources: Object[]): Object; + mixin(dest: Object, ...sources: Object[]): Object; /** * similar to hitch() except that the scope object is left to be * whatever the execution context eventually becomes. From 9330e507270fb5e5b70e832bc65821efbf478b7c Mon Sep 17 00:00:00 2001 From: Michael McKenzie Date: Tue, 19 Jul 2016 11:46:37 +0100 Subject: [PATCH 04/81] Revert "Changing dojo/_base/lang mixin signature to match documentation" This reverts commit cdfb764333a69c177fa59837d92a98b03f564538. --- dojo/dojo.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dojo/dojo.d.ts b/dojo/dojo.d.ts index cddc6445bb..8a566a46f5 100644 --- a/dojo/dojo.d.ts +++ b/dojo/dojo.d.ts @@ -5686,7 +5686,7 @@ declare namespace dojo { * @param dest The object to which to copy/add all properties contained in source. If dest is falsy, thena new object is manufactured before copying/adding properties begins. * @param sources One of more objects from which to draw all properties to copy into dest. sources are processedleft-to-right and if more than one of these objects contain the same property name, the right-mostvalue "wins". */ - mixin(dest: Object, ...sources: Object[]): Object; + mixin(dest: Object, sources: Object[]): Object; /** * similar to hitch() except that the scope object is left to be * whatever the execution context eventually becomes. From 4be5e34492bde28df4b2a2569844bd90ae1871a2 Mon Sep 17 00:00:00 2001 From: Michael McKenzie Date: Thu, 21 Jul 2016 14:26:28 +0100 Subject: [PATCH 05/81] Changing djit.Destroyable.own signature to match documentation and implmentation --- dojo/dijit.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dojo/dijit.d.ts b/dojo/dijit.d.ts index 8d3e99b6b5..29abf02211 100644 --- a/dojo/dijit.d.ts +++ b/dojo/dijit.d.ts @@ -1606,7 +1606,7 @@ declare module dijit { * already removed/destroyed manually. * */ - own(): any; + own(...args: any[]): any[]; /** * Place this widget somewhere in the DOM based * on standard domConstruct.place() conventions. From 8de2997128443fbde32d9b04f7af78cd0c8c9593 Mon Sep 17 00:00:00 2001 From: Leon Yu Date: Sat, 23 Jul 2016 22:41:11 -0400 Subject: [PATCH 06/81] Fix form-data for ES6 module (#9892) --- form-data/form-data-tests.ts | 137 +++++++++++++++++++++++++++++++++-- form-data/form-data.d.ts | 27 ++++--- request/request-tests.ts | 22 +++--- request/request.d.ts | 4 +- 4 files changed, 163 insertions(+), 27 deletions(-) diff --git a/form-data/form-data-tests.ts b/form-data/form-data-tests.ts index 641a368749..180986ed99 100644 --- a/form-data/form-data-tests.ts +++ b/form-data/form-data-tests.ts @@ -1,8 +1,135 @@ /// +/// +/// +/// +import FormData = require('form-data'); +import fs = require('fs'); +import http = require('http'); +import request = require('request'); -import formData = require('form-data'); +import * as ImportUsingES6Syntax from 'form-data'; -var value: any; -var fd = new formData.FormData(); -var obj: Object = fd.getHeaders(); -value = fd.pipe(value); +() => { + var form = new FormData(); + form.append('my_field', 'my value'); + form.append('my_buffer', new Buffer(10)); + form.append('my_file', fs.createReadStream('/foo/bar.jpg')); +} + +() => { + var form = new FormData(); + + http.request('http://nodejs.org/images/logo.png', function (response) { + form.append('my_field', 'my value'); + form.append('my_buffer', new Buffer(10)); + form.append('my_logo', response); + }); +} + +() => { + var form = new FormData(); + + form.append('my_field', 'my value'); + form.append('my_buffer', new Buffer(10)); + form.append('my_logo', request('http://nodejs.org/images/logo.png')); +} + +() => { + var form = new FormData(); + form.submit('http://example.org/', function (err, res) { + // res – response object (http.IncomingMessage) // + res.resume(); + }); +} + + +() => { + var form = new FormData(); + var request = http.request({ + method: 'post', + host: 'example.org', + path: '/upload', + headers: form.getHeaders() + }); + + form.pipe(request); + + request.on('response', function (res: any) { + console.log(res.statusCode); + }); +} + + +() => { + var form = new FormData(); + form.submit('example.org/upload', function (err, res) { + console.log(res.statusCode); + }); +} + +() => { + var CRLF = '\r\n'; + var form = new FormData(); + var buffer = new Buffer(''); + + var options = { + header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF, + knownLength: 1 + }; + + form.append('my_buffer', buffer, options); + + form.submit('http://example.com/', function (err, res) { + if (err) throw err; + console.log('Done'); + }); +} + +() => { + var form = new FormData(); + form.submit({ + host: 'example.com', + path: '/probably.php?extra=params', + auth: 'username:password' + }, function (err, res) { + console.log(res.statusCode); + }); +} + +() => { + var form = new FormData(); + form.submit({ + host: 'example.com', + path: '/surelynot.php', + headers: { 'x-test-header': 'test-header-value' } + }, function (err, res) { + console.log(res.statusCode); + }); +} + +() => { + var formData = { + my_field: 'my_value', + my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), + }; + + request.post({ url: 'http://service.com/upload', formData: formData }, function (err, httpResponse, body) { + if (err) { + return console.error('upload failed:', err); + } + console.log('Upload successful! Server responded with:', body); + }); +} + +() => { + var form = new FormData(); + + form.append('a', 1); + + fetch('http://example.com', { method: 'POST', body: form }) + .then(function (res) { + return res.json(); + }).then(function (json) { + console.log(json); + }); +} diff --git a/form-data/form-data.d.ts b/form-data/form-data.d.ts index f3a19b16f7..e285d774af 100644 --- a/form-data/form-data.d.ts +++ b/form-data/form-data.d.ts @@ -1,16 +1,25 @@ // Type definitions for form-data // Project: https://github.com/felixge/node-form-data -// Definitions by: Carlos Ballesteros Velasco +// Definitions by: Carlos Ballesteros Velasco , Leon Yu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Imported from: https://github.com/soywiz/typescript-node-definitions/form-data.d.ts declare module "form-data" { - export class FormData { - append(key: string, value: any, options?: any): FormData; - getHeaders(): Object; - // TODO expand pipe - pipe(to: any): any; - submit(params: string|Object, callback: (error: any, response: any) => void): any; - } -} + class FormData { + append(key: string, value: any, options?: any): void; + getHeaders(): FormData.Dictionary; + // TODO expand pipe + pipe(to: any): any; + submit(params: string | Object, callback: (error: any, response: any) => void): any; + getBoundary(): string; + } + + namespace FormData { + interface Dictionary { + [key: string]: T; + } + } + + export = FormData; +} \ No newline at end of file diff --git a/request/request-tests.ts b/request/request-tests.ts index 6efeb63c54..1deeb1dff9 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -3,8 +3,8 @@ import request = require('request'); import http = require('http'); import stream = require('stream'); -import formData = require('form-data'); import fs = require('fs'); +import FormData = require('form-data'); var value: any; var str: string; @@ -21,7 +21,7 @@ var headers: {[key: string]: string}; var agent: http.Agent; var write: stream.Writable; var req: request.Request; -var form1: formData.FormData; +var form1: FormData; var bodyArr: request.RequestPart[] = [{ body: value @@ -92,7 +92,7 @@ var options: request.Options = { qs: obj, json: value, multipart: value, - agent: new http.Agent(), + agent: new http.Agent(), agentOptions: value, agentClass: value, forever: value, @@ -243,14 +243,14 @@ request console.log(response.headers['content-type']); // 'image/png' }) .pipe(request.put('http://mysite.com/img.png')); - + request .get('http://mysite.com/doodle.png') .on('error', function(err: any) { console.log(err); }) .pipe(fs.createWriteStream('doodle.png')); - + http.createServer(function (req, resp) { if (req.url === '/doodle.png') { if (req.method === 'PUT') { @@ -362,7 +362,7 @@ request({ } console.log('Upload successful! Server responded with:', body); }); - + request.get('http://some.server.com/').auth('username', 'password', false); // or request.get('http://some.server.com/', { @@ -452,8 +452,8 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { , token_secret: perm_data.oauth_token_secret }; var url = 'https://api.twitter.com/1.1/users/show.json'; - var query = { - screen_name: perm_data.screen_name, + var query = { + screen_name: perm_data.screen_name, user_id: perm_data.user_id }; request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) { @@ -540,7 +540,7 @@ request({ } } }); - + //requests using baseRequest() will set the 'x-token' header var baseRequest = request.defaults({ headers: {'x-token': 'my-token'} @@ -593,7 +593,7 @@ var rand = Math.floor(Math.random()*100000000).toString(); } } ); - + request( { method: 'GET' , uri: 'http://www.google.com' @@ -615,7 +615,7 @@ request( console.log('received ' + data.length + ' bytes of compressed data') }) }); - + var requestWithJar = request.defaults({jar: true}) requestWithJar('http://www.google.com', function () { requestWithJar('http://images.google.com'); diff --git a/request/request.d.ts b/request/request.d.ts index 547ee625de..11375b30da 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -12,9 +12,9 @@ declare module 'request' { import stream = require('stream'); import http = require('http'); import https = require('https'); - import FormData = require('form-data'); import url = require('url'); import fs = require('fs'); + import FormData = require('form-data'); namespace request { export interface RequestAPI Date: Sun, 24 Jul 2016 04:42:33 +0200 Subject: [PATCH 07/81] Fixed dozens of errors in the koa v2.x typings (#9920) --- koa/koa.d.ts | 275 +++++++++++++++++++++++++++++---------------------- 1 file changed, 158 insertions(+), 117 deletions(-) diff --git a/koa/koa.d.ts b/koa/koa.d.ts index b005067b1f..1356ffdb0e 100644 --- a/koa/koa.d.ts +++ b/koa/koa.d.ts @@ -13,129 +13,170 @@ } =============================================== */ -/// +/// +/// declare module "koa" { - import { EventEmitter } from "events"; - import * as http from "http"; - import * as net from "net"; + import { EventEmitter } from "events"; + import * as cookies from "cookies"; + import * as http from "http"; + import * as net from "net"; - namespace Koa { - export interface Context extends Request, Response { - body?: any; - request?: Request; - response?: Response; - originalUrl?: string; - state?: any; - name?: string; - cookies?: any; - writable?: Boolean; - respond?: Boolean; - app?: Koa; - req?: http.IncomingMessage; - res?: http.ServerResponse; + namespace Koa { + export interface Context extends Request, Response { + app: Koa; + req: http.IncomingMessage; + res: http.ServerResponse; + request: Request; + response: Response; + + cookies: cookies.ICookies; + originalUrl: string; + state: any; + + name?: string; + respond?: boolean; + + assert(test: any, ...args: any[]): void; + onerror(err?: any): void; + throw(...args: any[]): void; + + toJSON(): any; + inspect(): any; + } + + export interface Request { + app: Koa; + req: http.IncomingMessage; + res: http.ServerResponse; + ctx: Context; + response: Response; + + fresh: boolean; + header: any; + headers: any; + host: string; + hostname: string; + href: string; + idempotent: boolean; + ip: string; + ips: string[]; + method: string; + origin: string; + originalUrl: string; + path: string; + protocol: string; + query: any; + querystring: string; + search: string; + secure: boolean; + socket: net.Socket; + stale: boolean; + subdomains: string[]; + type: string; + url: string; + + charset?: string; + length?: number; + + accepts(): string[]; + accepts(arg: string): void | string; + accepts(arg: string[]): void | string; + accepts(...args: string[]): void | string; + acceptsCharsets(): string[]; + acceptsCharsets(arg: string): void | string; + acceptsCharsets(arg: string[]): void | string; + acceptsCharsets(...args: string[]): void | string; + acceptsEncodings(): string[]; + acceptsEncodings(arg: string): void | string; + acceptsEncodings(arg: string[]): void | string; + acceptsEncodings(...args: string[]): void | string; + acceptsLanguages(): string[]; + acceptsLanguages(arg: string): void | string; + acceptsLanguages(arg: string[]): void | string; + acceptsLanguages(...args: string[]): void | string; + get(field: string): string; + is(): string[]; + is(arg: string): void | string; + is(arg: string[]): void | string; + is(...args: string[]): void | string; + + toJSON(): any; + inspect(): any; + } + + export interface Response { + app: Koa; + req: http.IncomingMessage; + res: http.ServerResponse; + ctx: Context; + request: Request; + + body: any; + etag: string; + header: any; + headers: any; + headerSent: boolean; + lastModified: Date; + message: string; + socket: net.Socket; + status: number; + type: string; + writable: boolean; + + charset?: string; + length?: number; + + append(field: string, val: string | string[]): void; + attachment(filename?: string): void; + get(field: string): string; + is(): string[]; + is(arg: string): void | string; + is(arg: string[]): void | string; + is(...args: string[]): void | string; + redirect(url: string, alt?: string): void; + remove(field: string): void; + set(field: string, val: string | string[]): void; + set(field: any): void; + vary(field: string): void; + + toJSON(): any; + inspect(): any; + } + } + + class Koa extends EventEmitter { + context: Koa.Context; + env: string; + keys: string[]; + proxy: boolean; + request: Koa.Request; + response: Koa.Response; + server: http.Server; + silent: boolean; + subdomainOffset: number; + + constructor(); + + // From node.d.ts + listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): http.Server; + listen(port: number, hostname?: string, listeningListener?: Function): http.Server; + listen(port: number, backlog?: number, listeningListener?: Function): http.Server; + listen(port: number, listeningListener?: Function): http.Server; + listen(path: string, backlog?: number, listeningListener?: Function): http.Server; + listen(path: string, listeningListener?: Function): http.Server; + listen(handle: any, backlog?: number, listeningListener?: Function): http.Server; + listen(handle: any, listeningListener?: Function): http.Server; + listen(options: net.ListenOptions, listeningListener?: Function): http.Server; + + callback(): (req: http.IncomingMessage, res: http.ServerResponse) => void; onerror(err: any): void; + use(middleware: (ctx: Koa.Context, next: () => Promise) => any): Koa; + toJSON(): any; inspect(): any; - throw(code?: any, message?: any): void; - assert(test: any, status: number, message: string): void; } - export interface Request { - _querycache?: string; - app?: Koa; - req?: http.IncomingMessage; - res?: http.ServerResponse; - response?: Response; - ctx?: Context; - headers?: any; - header?: any; - method?: string; - length?: any; - url?: string; - origin?: string; - originalUrl?: string; - href?: string; - path?: string; - querystring?: string; - query?: any; - search?: string; - idempotent?: Boolean; - socket?: net.Socket; - protocol?: string; - host?: string; - hostname?: string; - fresh?: Boolean; - stale?: Boolean; - charset?: string; - secure?: Boolean; - ips?: Array; - ip?: string; - subdomains?: Array; - accept?: any; - type?: string; - accepts?: () => any; - acceptsEncodings?: () => any; - acceptsCharsets?: () => any; - acceptsLanguages?: () => any; - is?: (types: any) => any; - toJSON?: () => any; - inspect?: () => any; - get?: (field: string) => string; - } - - export interface Response { - _body?: any; - _explicitStatus?: Boolean; - app?: Koa; - res?: http.ServerResponse; - req?: http.IncomingMessage; - ctx?: Context; - request?: Request; - socket?: net.Socket; - header?: any; - headers?: any; - status?: number; - message?: string; - type?: string; - body?: any; - length?: any; - headerSent?: Boolean; - lastModified?: Date; - etag?: string; - writable?: Boolean; - is?: (types: any) => any; - redirect?: (url: string, alt: string) => void; - attachment?: (filename?: string) => void; - vary?: (field: string) => void; - get?: (field: string) => string; - set?: (field: any, val: any) => void; - remove?: (field: string) => void; - append?: (field: string, val: any) => void; - toJSON?: () => any; - inspect?: () => any; - } - } - - class Koa extends EventEmitter { - keys: Array; - subdomainOffset: number; - proxy: Boolean; - server: http.Server; - env: string; - context: Koa.Context; - request: Koa.Request; - response: Koa.Response; - silent: Boolean; - constructor(); - use(middleware: (ctx: Koa.Context, next: Function) => any): Koa; - callback(): (req: http.IncomingMessage, res: http.ServerResponse) => void; - listen(port: number, callback?: Function): http.Server; - toJSON(): any; - inspect(): any; - onerror(err: any): void; - } - - namespace Koa {} - export = Koa; + namespace Koa {} + export = Koa; } From 76a755c0077e99fcf189e1d76745ebccec2e42e3 Mon Sep 17 00:00:00 2001 From: Mike Deverell Date: Sat, 23 Jul 2016 22:44:18 -0400 Subject: [PATCH 08/81] Update/fix HammerJS typings (#9968) * clarify and fix 'options' object types; Hammer.Manager requires an EventTarget, not HTMLElement * fix RecognizerTuple type --- hammerjs/hammerjs.d.ts | 71 ++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index bfc6e7cb4f..6b7cc7fb19 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Hammer.js 2.0.4 +// Type definitions for Hammer.js 2.0.8 // Project: http://hammerjs.github.io/ // Definitions by: Philip Bulley , Han Lin Yap // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -11,7 +11,7 @@ declare module "hammerjs" { interface HammerStatic { - new( element:HTMLElement | SVGElement, options?:any ): HammerManager; + new( element:HTMLElement | SVGElement, options?:HammerOptions ): HammerManager; defaults:HammerDefaults; @@ -68,16 +68,22 @@ interface HammerStatic prefixed( obj:any, property:string ):string; } -interface HammerDefaults +type RecognizerTuple = + [RecognizerStatic] + | [RecognizerStatic, RecognizerOptions] + | [RecognizerStatic, RecognizerOptions, string | string[]] + | [RecognizerStatic, RecognizerOptions, string | string[], (string | Recognizer) | (string | Recognizer)[]]; + +interface HammerDefaults extends HammerOptions { domEvents:boolean; enable:boolean; - preset:any[]; + preset:RecognizerTuple[]; touchAction:string; cssProps:CssProps; - inputClass():void; - inputTarget():void; + inputClass:() => void; + inputTarget:EventTarget; } interface CssProps @@ -90,13 +96,25 @@ interface CssProps userSelect:string; } -interface HammerOptions extends HammerDefaults +interface HammerOptions { + cssProps?:CssProps; + domEvents?:boolean; + enable?:boolean | ((manager: HammerManager) => boolean); + preset?:RecognizerTuple[]; + touchAction?:string; + recognizers?:RecognizerTuple[]; + inputClass?:() => void; + inputTarget?:EventTarget; } interface HammerManagerConstructor { - new( element:HTMLElement, options?:any ):HammerManager; + new( element:EventTarget, options?:HammerOptions ):HammerManager; +} + +interface HammerListener { + (event:HammerInput): void } interface HammerManager @@ -109,8 +127,8 @@ interface HammerManager emit( event:string, data:any ):void; get( recogniser:Recognizer ):Recognizer; get( recogniser:string ):Recognizer; - off( events:string, handler?:( event:HammerInput ) => void ):void; - on( events:string, handler:( event:HammerInput ) => void ):void; + off( events:string, handler?:HammerListener ):void; + on( events:string, handler:HammerListener ):void; recognize( inputData:any ):void; remove( recogniser:Recognizer ):HammerManager; remove( recogniser:string ):HammerManager; @@ -157,7 +175,7 @@ declare class HammerInput direction:number; /** Direction moved from it's starting point. Matches the DIRECTION constants. */ - offsetDirection:string; + offsetDirection:number; /** Scaling that has been done when multi-touch. 1 on a single touch. */ scale:number; @@ -221,9 +239,22 @@ declare class TouchMouseInput extends HammerInput constructor( manager:HammerManager, callback:Function ); } +interface RecognizerOptions { + direction?: number; + enable?: boolean | ((recognizer: Recognizer, inputData: HammerInput) => boolean); + event?: string; + interval?: number; + pointers?: number; + posThreshold?: number; + taps?: number + threshold?: number; + time?: number; + velocity?: number; +} + interface RecognizerStatic { - new( options?:any ):Recognizer; + new( options?:RecognizerOptions ):Recognizer; } interface Recognizer @@ -246,7 +277,7 @@ interface Recognizer requireFailure( otherRecognizer:Recognizer ):Recognizer; requireFailure( otherRecognizer:string ):Recognizer; reset():void; - set( options?:any ):Recognizer; + set( options?:RecognizerOptions ):Recognizer; tryEmit( input:HammerInput ):void; } @@ -258,12 +289,12 @@ interface AttrRecognizerStatic interface AttrRecognizer extends Recognizer { - new( options?:any ):AttrRecognizer; + new( options?:RecognizerOptions ):AttrRecognizer; } interface PanRecognizerStatic { - new( options?:any ):PanRecognizer; + new( options?:RecognizerOptions ):PanRecognizer; } interface PanRecognizer extends AttrRecognizer @@ -272,7 +303,7 @@ interface PanRecognizer extends AttrRecognizer interface PinchRecognizerStatic { - new( options?:any ):PinchRecognizer; + new( options?:RecognizerOptions ):PinchRecognizer; } interface PinchRecognizer extends AttrRecognizer @@ -281,7 +312,7 @@ interface PinchRecognizer extends AttrRecognizer interface PressRecognizerStatic { - new( options?:any ):PressRecognizer; + new( options?:RecognizerOptions ):PressRecognizer; } interface PressRecognizer extends AttrRecognizer @@ -290,7 +321,7 @@ interface PressRecognizer extends AttrRecognizer interface RotateRecognizerStatic { - new( options?:any ):RotateRecognizer; + new( options?:RecognizerOptions ):RotateRecognizer; } interface RotateRecognizer extends AttrRecognizer @@ -299,7 +330,7 @@ interface RotateRecognizer extends AttrRecognizer interface SwipeRecognizerStatic { - new( options?:any ):SwipeRecognizer; + new( options?:RecognizerOptions ):SwipeRecognizer; } interface SwipeRecognizer extends AttrRecognizer @@ -308,7 +339,7 @@ interface SwipeRecognizer extends AttrRecognizer interface TapRecognizerStatic { - new( options?:any ):TapRecognizer; + new( options?:RecognizerOptions ):TapRecognizer; } interface TapRecognizer extends AttrRecognizer From 71f47713ff9044c2f722562cc59f231055d1e03e Mon Sep 17 00:00:00 2001 From: David Poetzsch-Heffter Date: Sun, 24 Jul 2016 04:45:08 +0200 Subject: [PATCH 09/81] Parse fixes (#9987) * Added overriden version of extend in Parse.User * added type declaration of Parse.Promise.when with varargs * making Promise compatible with IPromise * fixed when: it is enough to have IPromise here * added Parse.Config class * fixed save/saveAll signatures * any object is allowed as function response * more precise signature for Parse.Object#find * request has a property object in beforeSave triggers * fixed types of trigger request & response objects * better fetch signatures * fixed typing for JobStatus * ErrorCode enum needs to be inlined in order to not create a dependency on the type definition * fixed return types of Parse.Promise#then * fixed typing of Parse.Promise.error * added static function Object.registerSubclass * fixed signature of Object#save * removed wrongly typed signatures; User inherits the correcrt ones from Object * added signature for Object#createAt and Object#updatedAt * javaScriptKey is optional according to https://github.com/ParsePlatform/Parse-SDK-JS/blob/v1.8.5/src/Parse.js * added class Session with methods typed according to https://parse.com/docs/js/api/classes/Parse.Session.html --- parse/parse.d.ts | 89 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/parse/parse.d.ts b/parse/parse.d.ts index e624b2ebcd..4035019c8d 100644 --- a/parse/parse.d.ts +++ b/parse/parse.d.ts @@ -67,29 +67,30 @@ declare namespace Parse { interface IPromise { - then(resolvedCallback: (value: T) => IPromise, rejectedCallback?: (reason: any) => IPromise): IPromise; - then(resolvedCallback: (value: T) => U, rejectedCallback?: (reason: any) => IPromise): IPromise; - then(resolvedCallback: (value: T) => U, rejectedCallback?: (reason: any) => U): IPromise; + then(resolvedCallback: (...values: T[]) => IPromise, rejectedCallback?: (reason: any) => IPromise): IPromise; + then(resolvedCallback: (...values: T[]) => U, rejectedCallback?: (reason: any) => IPromise): IPromise; + then(resolvedCallback: (...values: T[]) => U, rejectedCallback?: (reason: any) => U): IPromise; } - class Promise { + class Promise implements IPromise { static as(resolvedValue: U): Promise; - static error(error: U): Promise; + static error(error: U): Promise; static is(possiblePromise: any): Boolean; - static when(promises: Promise[]): Promise; + static when(promises: IPromise[]): Promise; + static when(...promises: IPromise[]): Promise; always(callback: Function): Promise; done(callback: Function): Promise; fail(callback: Function): Promise; reject(error: any): void; resolve(result: any): void; - then(resolvedCallback: (value: T) => Promise, - rejectedCallback?: (reason: any) => Promise): IPromise; - then(resolvedCallback: (value: T) => U, - rejectedCallback?: (reason: any) => IPromise): IPromise; - then(resolvedCallback: (value: T) => U, - rejectedCallback?: (reason: any) => U): IPromise; + then(resolvedCallback: (...values: T[]) => IPromise, + rejectedCallback?: (reason: any) => IPromise): IPromise; + then(resolvedCallback: (...values: T[]) => U, + rejectedCallback?: (reason: any) => IPromise): IPromise; + then(resolvedCallback: (...values: T[]) => U, + rejectedCallback?: (reason: any) => U): IPromise; } interface IBaseObject { @@ -306,7 +307,9 @@ declare namespace Parse { */ class Object extends BaseObject { - id: any; + id: string; + createdAt: Date; + updatedAt: Date; attributes: any; cid: string; changed: boolean; @@ -319,7 +322,9 @@ declare namespace Parse { static fetchAll(list: Object[], options: SuccessFailureOptions): Promise; static fetchAllIfNeeded(list: Object[], options: SuccessFailureOptions): Promise; static destroyAll(list: Object[], options?: Object.DestroyAllOptions): Promise; - static saveAll(list: Object[], options?: Object.SaveAllOptions): Promise; + static saveAll(list: T[], options?: Object.SaveAllOptions): Promise; + + static registerSubclass(className: string, clazz: new (options?: any) => T): void; initialize(): void; add(attr: string, item: any): Object; @@ -333,7 +338,7 @@ declare namespace Parse { dirtyKeys(): string[]; escape(attr: string): string; existed(): boolean; - fetch(options?: Object.FetchOptions): Promise; + fetch(options?: Object.FetchOptions): Promise; get(attr: string): any; getACL(): ACL; has(attr: string): boolean; @@ -345,7 +350,8 @@ declare namespace Parse { previousAttributes(): any; relation(attr: string): Relation; remove(attr: string, item: any): any; - save(options?: Object.SaveOptions, arg2?: any, arg3?: any): Promise; + save(attrs?: { [key: string]: any }, options?: Object.SaveOptions): Promise; + save(key: string, value: any, options?: Object.SaveOptions): Promise; set(key: string, value: any, options?: Object.SetOptions): boolean; setACL(acl: ACL, options?: SuccessFailureOptions): boolean; unset(attr: string, options?: any): any; @@ -587,7 +593,7 @@ declare namespace Parse { endsWith(key: string, suffix: string): Query; equalTo(key: string, value: any): Query; exists(key: string): Query; - find(options?: Query.FindOptions): Promise; + find(options?: Query.FindOptions): Promise; first(options?: Query.FirstOptions): Promise; get(objectId: string, options?: Query.GetOptions): Promise; greaterThan(key: string, value: any): Query; @@ -642,6 +648,21 @@ declare namespace Parse { setName(name: string, options?: SuccessFailureOptions): any; } + class Config extends Object { + static get(options?: SuccessFailureOptions): Promise; + static current(): Config; + + get(attr: string): any; + escape(attr: string): any; + } + + class Session extends Object { + static current(): Promise; + + getSessionToken(): string; + isCurrentSessionRevocable(): boolean; + } + /** * Routers map faux-URLs to actions, and fire events when routes are * matched. Creating a new one sets its `routes` hash, if not set statically. @@ -698,11 +719,10 @@ declare namespace Parse { static allowCustomUserClass(isAllowed: boolean): void; static become(sessionToken: string, options?: SuccessFailureOptions): Promise; static requestPasswordReset(email: string, options?: SuccessFailureOptions): Promise; + static extend(protoProps?: any, classProps?: any): any; signUp(attrs: any, options?: SuccessFailureOptions): Promise; logIn(options?: SuccessFailureOptions): Promise; - fetch(options?: SuccessFailureOptions): Promise; - save(arg1: any, arg2: any, arg3: any): Promise; authenticated(): boolean; isCurrent(): boolean; @@ -822,9 +842,9 @@ declare namespace Parse { } interface JobStatus { - error?: Function; - message?: Function; - success?: Function; + error?: (response: any) => void; + message?: (response: any) => void; + success?: (response: any) => void; } interface FunctionRequest { @@ -835,8 +855,8 @@ declare namespace Parse { } interface FunctionResponse { - success?: (response: HttpResponse) => void; - error?: (response: HttpResponse) => void; + success?: (response: any) => void; + error?: (response: any) => void; } interface Cookie { @@ -845,12 +865,18 @@ declare namespace Parse { value?: string; } - interface AfterSaveRequest extends FunctionRequest {} + interface SaveRequest extends FunctionRequest { + object: Object; + } + + interface AfterSaveRequest extends SaveRequest {} interface AfterDeleteRequest extends FunctionRequest {} interface BeforeDeleteRequest extends FunctionRequest {} interface BeforeDeleteResponse extends FunctionResponse {} - interface BeforeSaveRequest extends FunctionRequest {} - interface BeforeSaveResponse extends FunctionResponse {} + interface BeforeSaveRequest extends SaveRequest {} + interface BeforeSaveResponse extends FunctionResponse { + success?: () => void; + } function afterDelete(arg1: any, func?: (request: AfterDeleteRequest) => void): void; function afterSave(arg1: any, func?: (request: AfterSaveRequest) => void): void; @@ -911,7 +937,10 @@ declare namespace Parse { } - enum ErrorCode { + /* + * We need to inline the codes in order to make compilation work without this type definition as dependency. + */ + const enum ErrorCode { OTHER_CAUSE = -1, INTERNAL_SERVER_ERROR = 1, @@ -1043,10 +1072,10 @@ declare namespace Parse { * Call this method first to set up your authentication tokens for Parse. * You can get your keys from the Data Browser on parse.com. * @param {String} applicationId Your Parse Application ID. - * @param {String} javaScriptKey Your Parse JavaScript Key. + * @param {String} javaScriptKey (optional) Your Parse JavaScript Key (Not needed for parse-server) * @param {String} masterKey (optional) Your Parse Master Key. (Node.js only!) */ - function initialize(applicationId: string, javaScriptKey: string, masterKey?: string): void; + function initialize(applicationId: string, javaScriptKey?: string, masterKey?: string): void; } From 63f86fc0651c0cfa868a526c2bf53110c686bcc4 Mon Sep 17 00:00:00 2001 From: Thanh H Date: Sat, 23 Jul 2016 22:57:56 -0400 Subject: [PATCH 10/81] Fix #8985 (#10098) * Fix #8985 * Update definition of ITranslationTable to support namespace (#2433) --- 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 51946281ce..de7db4eb54 100644 --- a/angular-translate/angular-translate.d.ts +++ b/angular-translate/angular-translate.d.ts @@ -13,7 +13,7 @@ declare module "angular-translate" { declare namespace angular.translate { interface ITranslationTable { - [key: string]: any; + [key: string]: string | ITranslationTable; } interface ILanguageKeyAlias { @@ -96,7 +96,7 @@ declare namespace angular.translate { storageKey(): string; storageKey(key: string): void; // JeroMiya - the library should probably return ITranslateProvider but it doesn't here useUrlLoader(url: string): ITranslateProvider; - useStaticFilesLoader(options: IStaticFilesLoaderOptions): ITranslateProvider; + useStaticFilesLoader(options: IStaticFilesLoaderOptions | { files: IStaticFilesLoaderOptions[] }): ITranslateProvider; useLoader(loaderFactory: string, options?: any): ITranslateProvider; useLocalStorage(): ITranslateProvider; useCookieStorage(): ITranslateProvider; From b1bc0fa775a73477f52038fb74ddc4ae8708869f Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Sun, 24 Jul 2016 00:02:53 -0300 Subject: [PATCH 11/81] Jquery.payment (#10190) * fix jquery.payment for new API and add tests * add tests * squash! fix jquery.payment for new API and add tests --- jquery.payment/jquery.payment-tests.ts | 45 ++++++++++++++++++++++++++ jquery.payment/jquery.payment.d.ts | 19 +++++++---- 2 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 jquery.payment/jquery.payment-tests.ts diff --git a/jquery.payment/jquery.payment-tests.ts b/jquery.payment/jquery.payment-tests.ts new file mode 100644 index 0000000000..6ef1c2154d --- /dev/null +++ b/jquery.payment/jquery.payment-tests.ts @@ -0,0 +1,45 @@ +/// +/// + +$.payment.cards.push({ + // Card type, as returned by $.payment.cardType. + type: 'mastercard', + // Array of prefixes used to identify the card type. + patterns: [ + 51, 52, 53, 54, 55, + 22, 23, 24, 25, 26, 27 + ], + // Array of valid card number lengths. + length: [16], + // Array of valid card CVC lengths. + cvcLength: [3], + // Boolean indicating whether a valid card number should satisfy the Luhn check. + luhn: true, + // Regex used to format the card number. Each match is joined with a space. + format: /(\d{1,4})/g +}) + +$('[data-numeric]').payment('restrictNumeric'); + +$.payment.validateCardNumber('4242 4242 4242 4242') === true; //=> true + +$.payment.validateCardExpiry('05', '20') === true; //=> true +$.payment.validateCardExpiry('05', '2015') === true; //=> true +$.payment.validateCardExpiry('05', '05') === true; //=> false + +$.payment.validateCardCVC('123') === true; //=> true +$.payment.validateCardCVC('123', 'amex') === true; //=> true +$.payment.validateCardCVC('1234', 'amex') === true; //=> true +$.payment.validateCardCVC('12344') === false; //=> false + +$.payment.cardType('4242 4242 4242 4242') === 'visa'; //=> 'visa' + +$.payment.cardExpiryVal('03 / 2025') === {month: 3, year: 2025}; //=> {month: 3, year: 2025} +$.payment.cardExpiryVal('05 / 04') === {month: 3, year: 2025}; //=> {month: 5, year: 2004} +$('input.cc-exp').payment('cardExpiryVal') //=> {month: 4, year: 2020} + +var valid = $.payment.validateCardNumber($('input.cc-num').val()); + +if (!valid) { + alert('Your card is not valid!'); +} \ No newline at end of file diff --git a/jquery.payment/jquery.payment.d.ts b/jquery.payment/jquery.payment.d.ts index 61408d6ca9..1899eceaf4 100644 --- a/jquery.payment/jquery.payment.d.ts +++ b/jquery.payment/jquery.payment.d.ts @@ -77,33 +77,38 @@ declare namespace JQueryPayment { /** * Card type */ - type: string; + type?: string; - /* + /** * Regex used to identify the card type. For the best experience, this should be * the shortest pattern that can guarantee the card is of a particular type. */ - pattern: RegExp; + pattern?: RegExp; + + /** + * Array of prefixes used to identify the card type. + */ + patterns?: number[]; /** * Array of valid card number lengths. */ - length: number[]; + length?: number[]; /** * Array of valid card CVC lengths. */ - cvcLength: number[]; + cvcLength?: number[]; /** * Boolean indicating whether a valid card number should satisfy the Luhn check. */ - luhn: boolean; + luhn?: boolean; /** * Regex used to format the card number. Each match is joined with a space. */ - format: RegExp; + format?: RegExp; } } From acf17c35f3f6d21658f275c02cd368871d32fbec Mon Sep 17 00:00:00 2001 From: NN Date: Sun, 24 Jul 2016 06:08:35 +0300 Subject: [PATCH 12/81] onAuthRequired allows additional arguments. (#10200) See: https://developer.chrome.com/extensions/webRequest#type-OnAuthRequiredOptions https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/onAuthRequired --- chrome/chrome.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index bdd0271fca..efdfb5ce59 100644 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -7336,7 +7336,9 @@ declare namespace chrome.webRequest { interface WebRedirectionResponseEvent extends _WebResponseHeadersEvent {} - interface WebAuthenticationChallengeEvent extends chrome.events.Event<(details: WebAuthenticationChallengeDetails, callback?: (response: BlockingResponse) => void) => void> {} + interface WebAuthenticationChallengeEvent extends chrome.events.Event<(details: WebAuthenticationChallengeDetails, callback?: (response: BlockingResponse) => void) => void> { + addListener(callback: (details: WebAuthenticationChallengeDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void; + } interface WebResponseErrorEvent extends _WebResponseHeadersEvent {} From 52087dbaeef34185320ca5f11d93ff5d73735973 Mon Sep 17 00:00:00 2001 From: NN Date: Sun, 24 Jul 2016 06:09:03 +0300 Subject: [PATCH 13/81] Add missing url property for all requests (#10201) See documentation https://developer.chrome.com/extensions/webRequest https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/ --- chrome/chrome.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index efdfb5ce59..577d07b526 100644 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -7233,6 +7233,7 @@ declare namespace chrome.webRequest { } interface ResourceRequest { + url: string; /** The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request. */ requestId: string; /** The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (type is main_frame or sub_frame), frameId indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab. */ @@ -7251,7 +7252,6 @@ declare namespace chrome.webRequest { } interface WebRequestDetails extends ResourceRequest { - url: string; /** Standard HTTP method. */ method: string; } From 5e942d89e66a8ca8986a83fe5e1f4fb20029ddde Mon Sep 17 00:00:00 2001 From: NN Date: Sun, 24 Jul 2016 06:09:20 +0300 Subject: [PATCH 14/81] Fix typo, schema => scheme (#10203) See documentation https://developer.chrome.com/extensions/webRequest --- chrome/chrome.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index 577d07b526..75ec50afad 100644 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -7304,7 +7304,7 @@ declare namespace chrome.webRequest { interface WebAuthenticationChallengeDetails extends WebResponseHeadersDetails { /** The authentication scheme, e.g. Basic or Digest. */ - schema: string; + scheme: string; /** The authentication realm provided by the server, if there is one. */ realm?: string; /** The server requesting authentication. */ From 96034d863bf11341d8ef5080eddb3b298b5eb74d Mon Sep 17 00:00:00 2001 From: Birk Skyum Date: Sun, 24 Jul 2016 07:47:59 +0200 Subject: [PATCH 15/81] Update parse.d.ts (#10249) Alter options for Cloud.run and Query.each --- parse/parse.d.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/parse/parse.d.ts b/parse/parse.d.ts index 4035019c8d..825eedf386 100644 --- a/parse/parse.d.ts +++ b/parse/parse.d.ts @@ -25,6 +25,10 @@ declare namespace Parse { interface SuccessFailureOptions extends SuccessOption, ErrorOption { } + + interface SessionTokenOption { + sessionToken?: string; + } interface WaitOption { /** @@ -589,7 +593,7 @@ declare namespace Parse { doesNotExist(key: string): Query; doesNotMatchKeyInQuery(key: string, queryKey: string, query: Query): Query; doesNotMatchQuery(key: string, query: Query): Query; - each(callback: Function, options?: SuccessFailureOptions): Promise; + each(callback: Function, options?: Query.EachOptions): Promise; endsWith(key: string, suffix: string): Query; equalTo(key: string, value: any): Query; exists(key: string): Query; @@ -619,6 +623,7 @@ declare namespace Parse { } namespace Query { + interface EachOptions extends SuccessFailureOptions, UseMasterKeyOption { } interface CountOptions extends SuccessFailureOptions, UseMasterKeyOption { } interface FindOptions extends SuccessFailureOptions, UseMasterKeyOption { } interface FirstOptions extends SuccessFailureOptions, UseMasterKeyOption { } @@ -885,9 +890,11 @@ declare namespace Parse { function define(name: string, func?: (request: FunctionRequest, response: FunctionResponse) => void): void; function httpRequest(options: HTTPOptions): Promise; function job(name: string, func?: (request: JobRequest, status: JobStatus) => void): HttpResponse; - function run(name: string, data?: any, options?: SuccessFailureOptions): Promise; + function run(name: string, data?: any, options?: RunOptions): Promise; function useMasterKey(): void; + interface RunOptions extends SuccessFailureOptions, UseMasterKeyOption, SessionTokenOption { } + /** * To use this Cloud Module in Cloud Code, you must require 'buffer' in your JavaScript file. * From d9b96bdada46779594de26aa94333c9a5e5cd1a1 Mon Sep 17 00:00:00 2001 From: iclanton Date: Sat, 23 Jul 2016 22:48:56 -0700 Subject: [PATCH 16/81] webpack-stream typings. (#10248) --- webpack-stream/webpack-stream-tests.ts | 12 +++++++ webpack-stream/webpack-stream.d.ts | 48 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 webpack-stream/webpack-stream-tests.ts create mode 100644 webpack-stream/webpack-stream.d.ts diff --git a/webpack-stream/webpack-stream-tests.ts b/webpack-stream/webpack-stream-tests.ts new file mode 100644 index 0000000000..bd57e1c735 --- /dev/null +++ b/webpack-stream/webpack-stream-tests.ts @@ -0,0 +1,12 @@ +/// +/// + +import webpackStream = require("webpack-stream"); +import webpack = require("webpack"); + +let output: NodeJS.ReadWriteStream; + +output = webpackStream(); +output = webpackStream({ entry: '' }); +output = webpackStream({ entry: '' }, webpack); +output = webpackStream({ entry: '' }, webpack, (error: Error, stats: webpack.compiler.Stats) => { }); diff --git a/webpack-stream/webpack-stream.d.ts b/webpack-stream/webpack-stream.d.ts new file mode 100644 index 0000000000..1a41fa491b --- /dev/null +++ b/webpack-stream/webpack-stream.d.ts @@ -0,0 +1,48 @@ +// Type definitions for Combokeys v3.20.0 +// Project: https://github.com/shama/webpack-stream +// Definitions by: Ian Clanton-Thuon +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module "webpack-stream" { + import webpack = require("webpack"); + + interface WebpackStreamStatic { + /** + * Run webpack with the default configuration. + */ + (): NodeJS.ReadWriteStream; + + /** + * Run webpack with the specified configuration. + * + * @param {config} Webpack configuration + */ + (config: webpack.Configuration): NodeJS.ReadWriteStream; + + /** + * Run webpack with the specified configuration and webpack instance + * + * @param {config} Webpack configuration + * @param {webpack} A webpack object + */ + (config: webpack.Configuration, webpack: webpack.Webpack): NodeJS.ReadWriteStream; + + /** + * Run webpack with the specified configuration and webpack instance + * + * @param {config} Webpack configuration + * @param {webpack} A webpack object + * @param {callback} A callback with the webpack stats and error objects. + */ + (config: webpack.Configuration, + webpack: webpack.Webpack, + callback?: (err: Error, stats: webpack.compiler.Stats) => void): NodeJS.ReadWriteStream; + } + + var webpackStream: WebpackStreamStatic; + + export = webpackStream; +} From 24b237de6c18bc17f87443c16c5922c29b26a098 Mon Sep 17 00:00:00 2001 From: Sam Verschueren Date: Sun, 24 Jul 2016 07:52:55 +0200 Subject: [PATCH 17/81] add load-json-file (#10246) --- load-json-file/load-json-file-tests.ts | 15 +++++++++++++++ load-json-file/load-json-file.d.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 load-json-file/load-json-file-tests.ts create mode 100644 load-json-file/load-json-file.d.ts diff --git a/load-json-file/load-json-file-tests.ts b/load-json-file/load-json-file-tests.ts new file mode 100644 index 0000000000..89884bf78a --- /dev/null +++ b/load-json-file/load-json-file-tests.ts @@ -0,0 +1,15 @@ +/// +import * as loadJsonFile from 'load-json-file'; + +function assert(actual: string, expected: string): void { + if (actual !== expected) { + throw new Error(`${JSON.stringify(actual)} !== ${JSON.stringify(expected)}`); + } +} + +loadJsonFile('../package.json').then(pkg => { + assert(pkg.name, 'definitely-typed'); +}); + +const pkg = loadJsonFile.sync('../package.json'); +assert(pkg.name, 'definitely-typed'); diff --git a/load-json-file/load-json-file.d.ts b/load-json-file/load-json-file.d.ts new file mode 100644 index 0000000000..3da3c5ac2f --- /dev/null +++ b/load-json-file/load-json-file.d.ts @@ -0,0 +1,26 @@ +// Type definitions for load-json-file v2.0.0 +// Project: https://github.com/sindresorhus/load-json-file +// Definitions by: Sam Verschueren +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "load-json-file" { + + interface LoadJsonFile { + /** + * Returns a promise for the parsed JSON. + * + * @param filepath + */ + (filepath: string): Promise; + /** + * Returns the parsed JSON. + * + * @param filepath + */ + sync(filepath: string): any; + } + + const loadJsonFile: LoadJsonFile; + + export = loadJsonFile; +} From b27c623e2ad8e6b88d39ce0cd3a83b7c1a1ec875 Mon Sep 17 00:00:00 2001 From: Eytan Manor Date: Sun, 24 Jul 2016 08:57:39 +0300 Subject: [PATCH 18/81] refactor(meteor-publish-composite): Add module definition to 'meteor-publish-composite' definition file (#10245) --- .../meteor-publish-composite.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/meteor-publish-composite/meteor-publish-composite.d.ts b/meteor-publish-composite/meteor-publish-composite.d.ts index ac1e189e57..c5b8f87e4f 100644 --- a/meteor-publish-composite/meteor-publish-composite.d.ts +++ b/meteor-publish-composite/meteor-publish-composite.d.ts @@ -63,3 +63,18 @@ declare namespace Meteor { PublishCompositeConfig|PublishCompositeConfig[] ) : void; } + +declare module 'meteor/meteor' { + namespace Meteor { + function publishComposite( + name : string, + config : PublishCompositeConfig|PublishCompositeConfig[] + ) : void; + + function publishComposite( + name : string, + configFunc : (...args : any[]) => + PublishCompositeConfig|PublishCompositeConfig[] + ) : void; + } +} From 10f5180288583a331301e9f3531533a86c7f0d74 Mon Sep 17 00:00:00 2001 From: Eytan Manor Date: Sun, 24 Jul 2016 08:58:43 +0300 Subject: [PATCH 19/81] feat(meteor-accounts-phone): Add 'meteor-accounts-phone' definition file (#10244) --- .../meteor-accounts-phone-tests.ts | 50 ++++++++++++++ .../meteor-accounts-phone.d.ts | 69 +++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 meteor-accounts-phone/meteor-accounts-phone-tests.ts create mode 100644 meteor-accounts-phone/meteor-accounts-phone.d.ts diff --git a/meteor-accounts-phone/meteor-accounts-phone-tests.ts b/meteor-accounts-phone/meteor-accounts-phone-tests.ts new file mode 100644 index 0000000000..0604d54939 --- /dev/null +++ b/meteor-accounts-phone/meteor-accounts-phone-tests.ts @@ -0,0 +1,50 @@ +/// + +let booleanResult: boolean; +const options = {}; +function noop() {} + +SMS.twilio = { + FROM: 'me', + ACCOUNT_SID: 'my-account-sid', + AUTH_TOKEN: 'my-auth-token' +}; + +SMS.phoneTemplate = { + from: 'me', + text: noop +}; + +SMS.send(options); +SMS.send(options, noop); + +Meteor.loginWithPhoneAndPassword(options, 'password'); +Meteor.loginWithPhoneAndPassword('options', 'password'); +Meteor.loginWithPhoneAndPassword(options, 'password', noop); +Meteor.loginWithPhoneAndPassword('options', 'password', noop); + +Accounts._options = { + verificationCodeLength: 4, + verificationMaxRetries: 10, + verificationRetriesWaitTime: 60 * 1000, + verificationWaitTime: 10 * 1000, + sendPhoneVerificationCodeOnCreation: true, + forbidClientAccountCreation: true, + phoneVerificationMasterCode: ['1234'], + adminPhoneNumbers: ['+972546999999'] +}; + +Accounts.createUserWithPhone(options); +Accounts.createUserWithPhone(options, noop); + +Accounts.requestPhoneVerification('+972546999999'); +Accounts.requestPhoneVerification('+972546999999', noop); + +Accounts.verifyPhone('+972546999999', '1234'); +Accounts.verifyPhone('+972546999999', '1234', noop); +Accounts.verifyPhone('+972546999999', '1234', '123456'); +Accounts.verifyPhone('+972546999999', '1234', '123456', noop); + +booleanResult = Accounts.isPhoneVerified(); + +Accounts.onPhoneVerification(noop); diff --git a/meteor-accounts-phone/meteor-accounts-phone.d.ts b/meteor-accounts-phone/meteor-accounts-phone.d.ts new file mode 100644 index 0000000000..fe8a610d7f --- /dev/null +++ b/meteor-accounts-phone/meteor-accounts-phone.d.ts @@ -0,0 +1,69 @@ +// Type definitions for accounts-phone 0.0.21 +// Project: https://github.com/okland/accounts-phone +// Definitions by: Eytan Manor +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace SMS { + var twilio: { + FROM?: string; + ACCOUNT_SID?: string; + AUTH_TOKEN?: string; + }; + + var phoneTemplate: { + from: string; + text: Function; + }; + + function send(options: Object, callback?: Function): void; +} + +declare namespace Meteor { + function loginWithPhoneAndPassword(selector: Object | String, password: String, callback?: Function): void; +} + +declare module 'meteor/meteor' { + namespace Meteor { + function loginWithPhoneAndPassword(selector: Object | String, password: String, callback?: Function): void; + } +} + +declare namespace Accounts { + var _options: { + verificationCodeLength?: number, + verificationMaxRetries?: number, + verificationRetriesWaitTime?: number, + verificationWaitTime?: number, + sendPhoneVerificationCodeOnCreation?: boolean, + forbidClientAccountCreation?: boolean, + phoneVerificationMasterCode?: Array, + adminPhoneNumbers?: Array + }; + + function createUserWithPhone(options: Object, callback?: Function): void; + function requestPhoneVerification(phone: string, callback?: Function): void; + function verifyPhone(phone: string, code: string, newPassword?: string | Function, callback?: Function): void; + function isPhoneVerified(): boolean; + function onPhoneVerification(func: Function): void; +} + +declare module 'meteor/accounts-base' { + namespace Accounts { + var _options: { + verificationCodeLength?: number, + verificationMaxRetries?: number, + verificationRetriesWaitTime?: number, + verificationWaitTime?: number, + sendPhoneVerificationCodeOnCreation?: boolean, + forbidClientAccountCreation?: boolean, + phoneVerificationMasterCode?: Array, + adminPhoneNumbers?: Array + }; + + function createUserWithPhone(options: Object, callback?: Function): void; + function requestPhoneVerification(phone: string, callback?: Function): void; + function verifyPhone(phone: string, code: string, newPassword?: string | Function, callback?: Function): void; + function isPhoneVerified(): boolean; + function onPhoneVerification(func: Function): void; + } +} \ No newline at end of file From 994439d8ed69b57f5779cec2b07bf91f9dfddf49 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Sun, 24 Jul 2016 02:59:38 -0300 Subject: [PATCH 20/81] ioredis: Add some missing properties (#10240) These are minor changes: * There's a `status` field that can be used to check if the connection to the redis server is active. * There's a `getBuffer` method that returns a node `Buffer` instance instead of a string (if you're saving binary data on redis, this is useful). * The callback on `connect` is optional. --- ioredis/ioredis.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ioredis/ioredis.d.ts b/ioredis/ioredis.d.ts index a3769fee6c..983ed39f10 100644 --- a/ioredis/ioredis.d.ts +++ b/ioredis/ioredis.d.ts @@ -41,7 +41,8 @@ declare module IORedis { } interface Redis extends NodeJS.EventEmitter, Commander { - connect(callback: Function): Promise; + status: string; + connect(callback?: Function): Promise; disconnect(): void; duplicate(): Redis; monitor(calback: (error: Error, monitor: NodeJS.EventEmitter) => void): Promise; @@ -59,6 +60,7 @@ declare module IORedis { subscribe(channel: string): any; get(args: any[], callback?: ResCallbackT): any; get(...args: any[]): any; + getBuffer(key: string, callback?: ResCallbackT): any; set(args: any[], callback?: ResCallbackT): any; set(...args: any[]): any; setnx(args: any[], callback?: ResCallbackT): any; From b3889a9127faef8ca41ae67f3bf7aa3e26f1a77d Mon Sep 17 00:00:00 2001 From: "Dmitry A. Efimenko" Date: Sat, 23 Jul 2016 23:00:16 -0700 Subject: [PATCH 21/81] Agenda missing props/methods (#10239) --- agenda/agenda.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agenda/agenda.d.ts b/agenda/agenda.d.ts index 463ba43d2e..8dd58fdd80 100644 --- a/agenda/agenda.d.ts +++ b/agenda/agenda.d.ts @@ -319,6 +319,11 @@ declare module "agenda" { * The date/time the job last failed. */ failedAt: Date; + + /** + * Job's state + */ + disabled: boolean } /** @@ -409,6 +414,11 @@ declare module "agenda" { * @param cb Called after the job has been saved to the database. */ touch(cb?: Callback): void; + + /** + * Calculates next time the job should run + */ + computeNextRunAt(): Job; } interface JobOptions { From 5ad563cfc0e00afa2afabd44e7eb3647547eee59 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Sun, 24 Jul 2016 08:01:10 +0200 Subject: [PATCH 22/81] Aphrodite (#10238) * Aphrodite * added no-important module * change css() args to any[] --- aphrodite/aphrodite-tests.tsx | 82 +++++++++++++++++++++++++++++++++++ aphrodite/aphrodite.d.ts | 76 ++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 aphrodite/aphrodite-tests.tsx create mode 100644 aphrodite/aphrodite.d.ts diff --git a/aphrodite/aphrodite-tests.tsx b/aphrodite/aphrodite-tests.tsx new file mode 100644 index 0000000000..76d28ca43f --- /dev/null +++ b/aphrodite/aphrodite-tests.tsx @@ -0,0 +1,82 @@ +/// +/// + +import * as React from "react"; +import { StyleSheet, css, StyleSheetServer, StyleSheetTestUtils } from "aphrodite"; + +const styles = StyleSheet.create({ + red: { + backgroundColor: 'red' + }, + blue: { + backgroundColor: 'blue' + }, + hover: { + ':hover': { + backgroundColor: 'red' + } + }, + small: { + '@media (max-width: 600px)': { + backgroundColor: 'red', + } + } +}); + +const coolFont = { + fontFamily: "CoolFont", + fontStyle: "normal", + fontWeight: "normal", + src: "url('coolfont.woff2') format('woff2')" +}; + +const withFont = StyleSheet.create({ + headingText: { + fontFamily: coolFont, + fontSize: 20 + }, + bodyText: { + fontFamily: [coolFont, "sans-serif"], + fontSize: 12 + } +}); + + +class App extends React.Component<{}, {}> { + render() { + return
+ + This is red. + + + This turns red on hover. + + + This turns red when the browser is less than 600px width. + + + This is blue. + + + This is blue and turns red when the browser is less than + 600px width. + + + With font + +
; + } +} + +const output = StyleSheetServer.renderStatic(() => { + return "test"; +}); + +output.css.content; +output.css.renderedClassNames; +output.html; + +StyleSheet.rehydrate(output.css.renderedClassNames); + +StyleSheetTestUtils.suppressStyleInjection(); +StyleSheetTestUtils.clearBufferAndResumeStyleInjection(); diff --git a/aphrodite/aphrodite.d.ts b/aphrodite/aphrodite.d.ts new file mode 100644 index 0000000000..89d8646e54 --- /dev/null +++ b/aphrodite/aphrodite.d.ts @@ -0,0 +1,76 @@ +// Type definitions for Aphrodite 0.5.0 +// Project: https://github.com/Khan/aphrodite +// Definitions by: Alexey Svetliakov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "aphrodite" { + import * as React from "react"; + + /** + * Aphrodite style declaration + */ + export interface StyleDeclaration { + [key: string]: React.CSSProperties; + } + + interface StyleSheetStatic { + /** + * Create style sheet + */ + create(styles: T): T; + /** + * Rehydrate class names from server renderer + */ + rehydrate(renderedClassNames: string[]): void; + } + + export var StyleSheet: StyleSheetStatic; + /** + * Get class names from passed styles + */ + export function css(...styles: any[]): string; + + interface StaticRendererResult { + html: string; + css: { + content: string; + renderedClassNames: string[]; + } + } + + /** + * Utilities for using Aphrodite server-side. + */ + interface StyleSheetServerStatic { + renderStatic(renderFunc: () => string): StaticRendererResult; + } + + export var StyleSheetServer: StyleSheetServerStatic; + + interface StyleSheetTestUtilsStatic { + /** + * Prevent styles from being injected into the DOM. + * + * This is useful in situations where you'd like to test rendering UI + * components which use Aphrodite without any of the side-effects of + * Aphrodite happening. Particularly useful for testing the output of + * components when you have no DOM, e.g. testing in Node without a fake DOM. + * + * Should be paired with a subsequent call to + * clearBufferAndResumeStyleInjection. + */ + suppressStyleInjection(): void; + /** + * Opposite method of preventStyleInject. + */ + clearBufferAndResumeStyleInjection(): void; + } + + export var StyleSheetTestUtils: StyleSheetTestUtilsStatic; +} + +declare module "aphrodite/no-important" { + export * from "aphrodite"; +} From 66876a46ecef0bc3263e3f16e097bd1b2b3059a0 Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Sun, 24 Jul 2016 08:01:27 +0200 Subject: [PATCH 23/81] Indexing the IDocumentService should return Document (#10237) JQ(lite)-unwrapping $document[0] should be of type Document instead of the default HTMLElement. Otherwise important methods like getElementById are missing. --- angularjs/angular.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 2d9469ef80..82cce46541 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -985,7 +985,9 @@ declare namespace angular { // DocumentService // see http://docs.angularjs.org/api/ng.$document /////////////////////////////////////////////////////////////////////////// - interface IDocumentService extends JQuery {} + interface IDocumentService extends JQuery { + [index: number]: Document; + } /////////////////////////////////////////////////////////////////////////// // ExceptionHandlerService From 0afdcee8787c6491f4046a289306662ccdf11075 Mon Sep 17 00:00:00 2001 From: ^_^ Date: Sun, 24 Jul 2016 09:01:57 +0300 Subject: [PATCH 24/81] Update jquery.fileupload definitions (#10236) Actual code always tries to convert anything that's not jquery object to jquery --- jquery.fileupload/jquery.fileupload.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jquery.fileupload/jquery.fileupload.d.ts b/jquery.fileupload/jquery.fileupload.d.ts index da94ce19c6..7e46241999 100644 --- a/jquery.fileupload/jquery.fileupload.d.ts +++ b/jquery.fileupload/jquery.fileupload.d.ts @@ -17,13 +17,13 @@ interface JQueryFileInputOptions { * The drop target element(s), by the default the complete document. * Set to null to disable drag & drop support: */ - dropZone?: HTMLElement; + dropZone?: Element | Element[] | JQuery | string; /** * The paste target element(s), by the default the complete document. * Set to null to disable paste support: */ - pasteZone?: HTMLElement; + pasteZone?: Element | Element[] | JQuery | string; /** * The file input field(s), that are listened to for change events. @@ -31,7 +31,7 @@ interface JQueryFileInputOptions { * of the widget element on plugin initialization. * Set to null to disable the change listener. */ - fileInput?: HTMLElement; + fileInput?: Element | Element[] | JQuery | string; /** * By default, the file input field is replaced with a clone after @@ -286,4 +286,4 @@ interface JQueryFileUploadProgressObject extends JQueryFileInputOptions, JQueryF } interface JQueryFileUploadDone extends JQueryFileInputOptions, JQueryFileUploadXhr { -} \ No newline at end of file +} From d8d32d70b44d80c7b49bf515737e71f0b4b62b35 Mon Sep 17 00:00:00 2001 From: Matt Jeanes Date: Sun, 24 Jul 2016 07:20:53 +0100 Subject: [PATCH 25/81] Add WorkItemTrackingApi.createWorkItem to vso-node-api (#10233) --- vso-node-api/vso-node-api.d.ts | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/vso-node-api/vso-node-api.d.ts b/vso-node-api/vso-node-api.d.ts index 55fd857703..846cbf270a 100644 --- a/vso-node-api/vso-node-api.d.ts +++ b/vso-node-api/vso-node-api.d.ts @@ -12714,7 +12714,8 @@ declare module 'vso-node-api/WorkItemTrackingApi' { getWorkItem(id: number, fields: string[], asOf: Date, expand: WorkItemTrackingInterfaces.WorkItemExpand, onResult: (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => void): void; getWorkItems(ids: number[], fields: string[], asOf: Date, expand: WorkItemTrackingInterfaces.WorkItemExpand, onResult: (err: any, statusCode: number, workItems: WorkItemTrackingInterfaces.WorkItem[]) => void): void; updateWorkItem(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, id: number, validateOnly: boolean, bypassRules: boolean, onResult: (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => void): void; - getWorkItemTemplate(project: string, type: string, fields: string, asOf: Date, expand: WorkItemTrackingInterfaces.WorkItemExpand, onResult: (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => void): void; + createWorkItem(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, project: string, type: string, validateOnly: boolean, bypassRules: boolean, onResult: (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => void): void; + getWorkItemTemplate(project: string, type: string, fields: string, asOf: Date, expand: WorkItemTrackingInterfaces.WorkItemExpand, onResult: (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => void): void; updateWorkItemTemplate(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, project: string, type: string, validateOnly: boolean, bypassRules: boolean, onResult: (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => void): void; getWorkItemTypeCategories(project: string, onResult: (err: any, statusCode: number, workItemTypeCategories: WorkItemTrackingInterfaces.WorkItemTypeCategory[]) => void): void; getWorkItemTypeCategory(project: string, category: string, onResult: (err: any, statusCode: number, workItemTypeCategorie: WorkItemTrackingInterfaces.WorkItemTypeCategory) => void): void; @@ -12752,7 +12753,8 @@ declare module 'vso-node-api/WorkItemTrackingApi' { getWorkItem(id: number, fields?: string[], asOf?: Date, expand?: WorkItemTrackingInterfaces.WorkItemExpand): Q.Promise; getWorkItems(ids: number[], fields?: string[], asOf?: Date, expand?: WorkItemTrackingInterfaces.WorkItemExpand): Q.Promise; updateWorkItem(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, id: number, validateOnly?: boolean, bypassRules?: boolean): Q.Promise; - getWorkItemTemplate(project: string, type: string, fields?: string, asOf?: Date, expand?: WorkItemTrackingInterfaces.WorkItemExpand): Q.Promise; + createWorkItem(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, project: string, type: string, validateOnly?: boolean, bypassRules?: boolean): Q.Promise; + getWorkItemTemplate(project: string, type: string, fields?: string, asOf?: Date, expand?: WorkItemTrackingInterfaces.WorkItemExpand): Q.Promise; updateWorkItemTemplate(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, project: string, type: string, validateOnly?: boolean, bypassRules?: boolean): Q.Promise; getWorkItemTypeCategories(project: string): Q.Promise; getWorkItemTypeCategory(project: string, category: string): Q.Promise; @@ -13027,7 +13029,16 @@ declare module 'vso-node-api/WorkItemTrackingApi' { * @param {WorkItemTrackingInterfaces.WorkItemExpand} expand * @param onResult callback function with the resulting WorkItemTrackingInterfaces.WorkItem */ - getWorkItemTemplate(project: string, type: string, fields: string, asOf: Date, expand: WorkItemTrackingInterfaces.WorkItemExpand, onResult: (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => void): void; + getWorkItemTemplate(project: string, type: string, fields: string, asOf: Date, expand: WorkItemTrackingInterfaces.WorkItemExpand, onResult: (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => void): void; + /** + * @param {VSSInterfaces.JsonPatchDocument} document + * @param {string} project - Project ID or project name + * @param {string} type + * @param {boolean} validateOnly + * @param {boolean} bypassRules + * @param onResult callback function with the resulting WorkItemTrackingInterfaces.WorkItem + */ + createWorkItem(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, project: string, type: string, validateOnly: boolean, bypassRules: boolean, onResult: (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => void): void; /** * @param {VSSInterfaces.JsonPatchDocument} document * @param {string} project - Project ID or project name @@ -13282,7 +13293,15 @@ declare module 'vso-node-api/WorkItemTrackingApi' { * @param {boolean} bypassRules */ updateWorkItem(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, id: number, validateOnly?: boolean, bypassRules?: boolean): Q.Promise; - /** + /** + * @param {VSSInterfaces.JsonPatchDocument} document + * @param {string} project - Project ID or project name + * @param {string} type + * @param {boolean} validateOnly + * @param {boolean} bypassRules + */ + createWorkItem(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, project: string, type: string, validateOnly?: boolean, bypassRules?: boolean): Q.Promise; + /** * Returns a single work item from a template * * @param {string} project - Project ID or project name @@ -13433,4 +13452,4 @@ declare module 'vso-node-api/WebApi' { getQWorkItemTrackingApi(serverUrl?: string, handlers?: VsoBaseInterfaces.IRequestHandler[]): workitemtrackingm.IQWorkItemTrackingApi; } -} +} \ No newline at end of file From 3dde9d27dbc3269c09dad6eb95ab0f33bce312ad Mon Sep 17 00:00:00 2001 From: MichaelBuen Date: Sun, 24 Jul 2016 14:21:08 +0800 Subject: [PATCH 26/81] Update aws-sdk.d.ts (#10232) Make QueueUrl optional, as it can have a default value that is be obtained from aws.SQS: ``` var sqs = new aws.SQS({ region: config.aws.region, accessKeyId: config.aws.accessID, secretAccessKey: config.aws.secretKey, // For every request in this demo, I'm going to be using the same QueueUrl; so, // rather than explicitly defining it on every request, I can set it here as the // default QueueUrl to be automatically appended to every request. params: { QueueUrl: config.aws.queueUrl } }); var sendMessage = Q.nbind( sqs.sendMessage, sqs ); // ---------------------------------------------------------- // // ---------------------------------------------------------- // // Now that we have a Q-ified method, we can send the message. sendMessage({ MessageBody: "This is my first ever SQS request... evar!" }) ``` Based on: http://www.bennadel.com/blog/2792-shedding-the-monolithic-application-with-aws-simple-queue-service-sqs-and-node-js.htm --- aws-sdk/aws-sdk.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws-sdk/aws-sdk.d.ts b/aws-sdk/aws-sdk.d.ts index 270f06d36a..a5341fcb45 100644 --- a/aws-sdk/aws-sdk.d.ts +++ b/aws-sdk/aws-sdk.d.ts @@ -397,7 +397,7 @@ declare module "aws-sdk" { } export interface SendMessageParams { - QueueUrl: string; + QueueUrl?: string; MessageBody: string; DelaySeconds?: number; MessageAttributes?: { [name:string]: MessageAttribute; } From 13837166f17c4ac709e2fe8c685df132c0d723ef Mon Sep 17 00:00:00 2001 From: Ruben Slabbert Date: Sun, 24 Jul 2016 16:25:36 +1000 Subject: [PATCH 27/81] Knex.js: Added TableName type and changed join bindings (#10227) --- knex/knex-tests.ts | 4 ++++ knex/knex.d.ts | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index c01c54691e..a7a0417cc4 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -156,6 +156,10 @@ knex('users') .join('contacts', 'users.id', 'contacts.user_id') .select('users.id', 'contacts.phone'); +knex('users') + .join(knex('contacts').select('user_id', 'phone').as('contacts'), 'users.id', 'contacts.user_id') + .select('users.id', 'contacts.phone'); + knex.select('*').from('users').join('accounts', function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id') }); diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 24020b0083..bb6395807e 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -14,6 +14,7 @@ declare module "knex" { type Client = Function; type Value = string|number|boolean|Date|Array|Array|Array|Array; type ColumnName = string|Knex.Raw|Knex.QueryBuilder; + type TableName = string|Knex.Raw|Knex.QueryBuilder; interface Knex extends Knex.QueryInterface { (tableName?: string): Knex.QueryBuilder; @@ -164,12 +165,12 @@ declare module "knex" { interface Join { (raw: Raw): QueryBuilder; - (tableName: string, callback: (joinClause: JoinClause) => any): QueryBuilder; - (tableName: string, columns: {[key: string]: string|Raw}): QueryBuilder; - (tableName: string, raw: Raw): QueryBuilder; - (tableName: string, column1: string, column2: string): QueryBuilder; - (tableName: string, column1: string, raw: Raw): QueryBuilder; - (tableName: string, column1: string, operator: string, column2: string): QueryBuilder; + (tableName: TableName, callback: (joinClause: JoinClause) => any): QueryBuilder; + (tableName: TableName, columns: {[key: string]: string|Raw}): QueryBuilder; + (tableName: TableName, raw: Raw): QueryBuilder; + (tableName: TableName, column1: string, column2: string): QueryBuilder; + (tableName: TableName, column1: string, raw: Raw): QueryBuilder; + (tableName: TableName, column1: string, operator: string, column2: string): QueryBuilder; } interface JoinClause { From 98c279c49f82f5a49e22c69bf93f0417816ee6e7 Mon Sep 17 00:00:00 2001 From: Matt Ferderer Date: Sun, 24 Jul 2016 01:26:38 -0500 Subject: [PATCH 28/81] Added events to cropperjs options and tests for the events. The tests are from usage example on the cropperjs GitHub repo. (#10226) --- cropperjs/cropperjs-tests.ts | 14 ++++++++++++++ cropperjs/cropperjs.d.ts | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/cropperjs/cropperjs-tests.ts b/cropperjs/cropperjs-tests.ts index d328a12b4a..82232c268a 100644 --- a/cropperjs/cropperjs-tests.ts +++ b/cropperjs/cropperjs-tests.ts @@ -1,2 +1,16 @@ /// import * as Cropper from 'cropperjs'; + +var image = document.getElementById('image'); +var cropper = new Cropper(image, { + aspectRatio: 16 / 9, + crop: function(e) { + console.log(e.detail.x); + console.log(e.detail.y); + console.log(e.detail.width); + console.log(e.detail.height); + console.log(e.detail.rotate); + console.log(e.detail.scaleX); + console.log(e.detail.scaleY); + } +}); diff --git a/cropperjs/cropperjs.d.ts b/cropperjs/cropperjs.d.ts index f2f8e861e5..c76b4c7766 100644 --- a/cropperjs/cropperjs.d.ts +++ b/cropperjs/cropperjs.d.ts @@ -11,7 +11,26 @@ declare module cropperjs { CanvasShouldNotBeWithInTheContainer = 2, ContainerSshouldBeWithInTheCanvas = 3 } + export interface CropperCustomEvent extends CustomEvent { + detail: Data; + } export interface CropperOptions { + /** + * Function called when crop box is moved or resized + */ + crop?: (event: CropperCustomEvent) => void; + /** + * Function called at start of crop box being moved or resized + */ + cropstart?: (event: CropperCustomEvent) => void; + /** + * Function called when crop box is moved + */ + cropmove?: (event: CropperCustomEvent) => void; + /** + * Function called when crop box is finished being moved or resized + */ + cropend?: (event: CropperCustomEvent) => void; /** * Define the view mode of the cropper. * @default 0 From 269fe3fee957004647d5890afcffd9652c1ab3de Mon Sep 17 00:00:00 2001 From: mcriss Date: Sun, 24 Jul 2016 01:26:53 -0500 Subject: [PATCH 29/81] Add nodir to SrcOptions (#10225) --- gulp/gulp.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gulp/gulp.d.ts b/gulp/gulp.d.ts index 43bb5aa597..74968ddcc5 100644 --- a/gulp/gulp.d.ts +++ b/gulp/gulp.d.ts @@ -149,6 +149,11 @@ declare module "gulp" { * Note that an explicit dot in a portion of the pattern will always match dot files. */ dot?: boolean; + + /** + * Set to match only fles, not directories. Set this flag to prevent copying empty directories + */ + nodir?: boolean; /** * By default, a pattern starting with a forward-slash will be "mounted" onto the root setting, so that a valid From b9a4af1c2f47588836f62c4039d45926e50dbafd Mon Sep 17 00:00:00 2001 From: Sachin Patney Date: Sat, 23 Jul 2016 23:27:14 -0700 Subject: [PATCH 30/81] Update plotly.js.d.ts (#10222) This could also just be an element instead of a selector string --- plotly.js/plotly.js.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly.js/plotly.js.d.ts b/plotly.js/plotly.js.d.ts index 3083ea1ca3..863c708abb 100644 --- a/plotly.js/plotly.js.d.ts +++ b/plotly.js/plotly.js.d.ts @@ -29,7 +29,7 @@ interface PlotlyConfig { } interface PlotlyStatic { - newPlot(divid:string, data:any[], layout?:any, config?:PlotlyConfig):void; + newPlot(divid:string | HTMLElement, data:any[], layout?:any, config?:PlotlyConfig):void; } declare module "plotly.js" { From 00055c095dae3330f12553aba19da42bc063baf6 Mon Sep 17 00:00:00 2001 From: alexndlm Date: Sun, 24 Jul 2016 09:28:56 +0300 Subject: [PATCH 31/81] Add type definitions for BazingaJsTranslationBundle (#10220) --- .../bazinga-translator-tests.ts | 12 +++ bazinga-translator/bazinga-translator.d.ts | 99 +++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 bazinga-translator/bazinga-translator-tests.ts create mode 100644 bazinga-translator/bazinga-translator.d.ts diff --git a/bazinga-translator/bazinga-translator-tests.ts b/bazinga-translator/bazinga-translator-tests.ts new file mode 100644 index 0000000000..2401641815 --- /dev/null +++ b/bazinga-translator/bazinga-translator-tests.ts @@ -0,0 +1,12 @@ +/// + +Translator.fallback = 'en'; +Translator.defaultDomain = 'messages'; + +Translator.add("test", "it work", "frontend", "en"); + +Translator.trans('key', {}, 'frontend'); +Translator.trans('key', {"foo": "bar"}, 'DOMAIN_NAME'); + +Translator.transChoice('key', 1, {}, 'frontend'); +Translator.transChoice('key', 123, {"foo": "bar"}, 'DOMAIN_NAME'); \ No newline at end of file diff --git a/bazinga-translator/bazinga-translator.d.ts b/bazinga-translator/bazinga-translator.d.ts new file mode 100644 index 0000000000..5467fbfd85 --- /dev/null +++ b/bazinga-translator/bazinga-translator.d.ts @@ -0,0 +1,99 @@ +// Type definitions for Translator +// Project: https://github.com/willdurand/BazingaJsTranslationBundle +// Definitions by: Alex +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface BazingaTranslator { + /** + * The current locale. + * + * @type {String} + */ + locale: string; + + /** + * Fallback locale. + * + * @type {String} + */ + fallback: string; + + /** + * Placeholder prefix. + * + * @type {String} + */ + placeHolderPrefix: string; + + /** + * Placeholder suffix. + * + * @type {String} + */ + placeHolderSuffix: string; + + /** + * Default domain. + * + * @type {String} + */ + defaultDomain: string; + + /** + * Plural separator. + * + * @type {String} + */ + pluralSeparator: string; + + /** + * Adds a translation entry. + * + * @param {String} id The message id + * @param {String} message The message to register for the given id + * @param {String} [domain] The domain for the message or null to use the default + * @param {String} [locale] The locale or null to use the default + * + * @return {Object} Translator + */ + add(id: string, message: string, domain: string, locale: string): BazingaTranslator; + + + /** + * Translates the given message. + * + * @param {String} id The message id + * @param {Object} [parameters] An array of parameters for the message + * @param {String} [domain] The domain for the message or null to guess it + * @param {String} [locale] The locale or null to use the default + * + * @return {String} The translated string + */ + trans(id: string, parameters: any, domain: string, locale?: string): string; + + /** + * Translates the given choice message by choosing a translation according to a number. + * + * @param {String} id The message id + * @param {Number} number The number to use to find the indice of the message + * @param {Object} [parameters] An array of parameters for the message + * @param {String} [domain] The domain for the message or null to guess it + * @param {String} [locale] The locale or null to use the default + * + * @return {String} The translated string + */ + transChoice(id: string, number: number, parameters: any, domain: string, locale?: string): string, + + /** + * Loads translations from JSON. + * + * @param {String} data A JSON string or object literal + * + * @return {Object} Translator + */ + fromJSON(data: string): BazingaTranslator; + + reset(): void; +} + +declare var Translator: BazingaTranslator; \ No newline at end of file From da7c99c73bcdeb64c1238d537740825efdc24b89 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Sat, 23 Jul 2016 23:30:08 -0700 Subject: [PATCH 32/81] Added unselectedTintColor prop to TabBarIOS (#10251) Per https://facebook.github.io/react-native/docs/tabbarios.html#props --- react-native/react-native.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/react-native/react-native.d.ts b/react-native/react-native.d.ts index 74a86e27b7..0ffc6763a7 100644 --- a/react-native/react-native.d.ts +++ b/react-native/react-native.d.ts @@ -3575,6 +3575,11 @@ declare namespace __React { * A Boolean value that indicates whether the tab bar is translucent */ translucent?: boolean + + /** + * Color of text on unselected tabs + */ + unselectedTintColor?: string } export interface TabBarIOSStatic extends React.ComponentClass { From 88992f2e3217cc9a3eefd78fc77e869d0e1ade14 Mon Sep 17 00:00:00 2001 From: Michael McKenzie Date: Sun, 24 Jul 2016 07:31:10 +0100 Subject: [PATCH 33/81] Changing djit.Destroyable.own signature to match documentation and implementation (#10219) * Changing hitch signature to match documentation * Changing hitch signature to match documentation * Changing dojo/_base/lang mixin signature to match documentation * Revert "Changing dojo/_base/lang mixin signature to match documentation" This reverts commit cdfb764333a69c177fa59837d92a98b03f564538. * Changing djit.Destroyable.own signature to match documentation and implmentation --- dojo/dijit.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dojo/dijit.d.ts b/dojo/dijit.d.ts index 8d3e99b6b5..29abf02211 100644 --- a/dojo/dijit.d.ts +++ b/dojo/dijit.d.ts @@ -1606,7 +1606,7 @@ declare module dijit { * already removed/destroyed manually. * */ - own(): any; + own(...args: any[]): any[]; /** * Place this widget somewhere in the DOM based * on standard domConstruct.place() conventions. From 0c98b1516770cb564d106abc8adf92c560e4eb13 Mon Sep 17 00:00:00 2001 From: Gabriel JUCHAULT Date: Sun, 24 Jul 2016 08:31:51 +0200 Subject: [PATCH 34/81] Countdown.js (#10218) * Countdown.js * Remove header tags from tests * fix(countdownjs): removed var --- countdown/countdown-tests.ts | 42 ++++++++++++++++++++++ countdown/countdown.d.ts | 69 ++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 countdown/countdown-tests.ts create mode 100644 countdown/countdown.d.ts diff --git a/countdown/countdown-tests.ts b/countdown/countdown-tests.ts new file mode 100644 index 0000000000..c803f1acc2 --- /dev/null +++ b/countdown/countdown-tests.ts @@ -0,0 +1,42 @@ +/// + +import { countdown, Timespan, CountdownStatic, Format } from 'countdown'; + +let ts: Timespan; +let interval: number; + +ts = countdown(new Date()); +ts = countdown(150); + +interval = countdown(new Date(), + function (ts: Timespan) { + document.getElementById('pageTimer').innerHTML = ts.toHTML('strong'); + }, + countdown.HOURS | countdown.MINUTES | countdown.SECONDS, + 2, + 2 +); + +clearInterval(interval); + +ts.toString('foo'); +ts.toHTML('em', 'foo'); + +countdown.resetFormat(); +countdown.setLabels('a', 'b', 'c', 'd', 'e'); + +countdown.setLabels('a', 'b', 'c', 'd', 'e', function (value: number): string { + return 'ok'; +}, function (value: number, unit: number): string { + return 'ok'; +}); + +countdown.setLabels(null, null, null, null, 'Now.'); + +countdown.setLabels( + ' millisecond| second| minute| hour| day| week| month| year| decade| century| millennium', + ' milliseconds| seconds| minutes| hours| days| weeks| months| years| decades| centuries| millennia', + ' and ', + ', ', + '', + n => n.toString()); diff --git a/countdown/countdown.d.ts b/countdown/countdown.d.ts new file mode 100644 index 0000000000..5b40541dd0 --- /dev/null +++ b/countdown/countdown.d.ts @@ -0,0 +1,69 @@ +// Type definitions for countdown.js +// Project: http://countdownjs.org/ +// Definitions by: Gabriel Juchault +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'countdown' { + export type DateFunction = (timespan: Timespan) => void; + export type DateTime = number | Date | DateFunction; + + export interface Timespan { + start?: Date; + end?: Date; + units?: number; + value?: number; + millennia?: number; + centuries?: number; + decades?: number; + years?: number; + months?: number; + days?: number; + hours?: number; + minutes?: number; + seconds?: number; + milliseconds?: number; + toString(label?: string): string; + toHTML(tagName?: string, label?: string): string; + } + + export interface Format { + singular?: string | Array; + plural?: string | Array; + last?: string; + delim?: string; + empty?: string; + formatNumber?(value: number): string; + formatter?(value: number, unit: number): string; + } + + export interface CountdownStatic { + (start: DateTime, end?: DateTime, units?: number, max?: number, digits?: number): Timespan | number; + MILLENNIA: number; + CENTURIES: number; + DECADES: number; + YEARS: number; + MONTHS: number; + WEEKS: number; + DAYS: number; + HOURS: number; + MINUTES: number; + SECONDS: number; + MILLISECONDS: number; + ALL: number; + DEFAULTS: number; + resetLabels(): void; + setLabels( + singular?: string, + plural?: string, + last?: string, + delim?: string, + empty?: string, + formatNumber?: (value: number) => string, + formatter?: (value: number, unit: number) => string + ): void; + resetFormat(): void; + setFormat(format: Format): void; + } + + export let countdown: CountdownStatic; +} From 1f9a2508cfa95d990825dd3cd222d658fd403f79 Mon Sep 17 00:00:00 2001 From: Ray Singer Date: Sun, 24 Jul 2016 18:33:08 +1200 Subject: [PATCH 35/81] Update orientation type from number to string (#10215) When using this d.ts file I was getting a TS2345 error: Type 'string' is not assignable to type 'number'. Looks like it was just a copy and paste error or something. I've changed it from number to string. --- bootstrap-slider/bootstrap-slider.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap-slider/bootstrap-slider.d.ts b/bootstrap-slider/bootstrap-slider.d.ts index 77a5177fa0..d830e3c45a 100644 --- a/bootstrap-slider/bootstrap-slider.d.ts +++ b/bootstrap-slider/bootstrap-slider.d.ts @@ -35,7 +35,7 @@ interface SliderOptions { * Default: 'horizontal' * set the orientation. Accepts 'vertical' or 'horizontal' */ - orientation?: number; + orientation?: string; /** * Default: 5 * initial value. Use array to have a range slider. From ec2a478b24299379d932783c8aacdc4a3700cb71 Mon Sep 17 00:00:00 2001 From: ersimont Date: Sun, 24 Jul 2016 02:33:59 -0400 Subject: [PATCH 36/81] Update chai-jquery.d.ts (#10214) --- chai-jquery/chai-jquery.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chai-jquery/chai-jquery.d.ts b/chai-jquery/chai-jquery.d.ts index 3d287f30fc..e7256bb7ab 100644 --- a/chai-jquery/chai-jquery.d.ts +++ b/chai-jquery/chai-jquery.d.ts @@ -17,7 +17,7 @@ declare namespace Chai { html(html: string): Assertion; text(text: string): Assertion; value(text: string): Assertion; - (selector: string): Assertion; + descendants(selector: string): Assertion; visible: Assertion; hidden: Assertion; selected: Assertion; From d55ed5d0f1050b88323b30971bcea0fd644d5454 Mon Sep 17 00:00:00 2001 From: Tim Schubert Date: Sun, 24 Jul 2016 16:34:39 +1000 Subject: [PATCH 37/81] angularjs - Added optional interceptorFn and expensiveChecks parameters to IParseService (#10213) --- angularjs/angular-tests.ts | 6 ++++++ angularjs/angular.d.ts | 2 +- angularjs/legacy/angular-1.4.d.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 10d3b17eda..ef3e29b4c8 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -1098,6 +1098,12 @@ function parseTyping() { } } +function parseWithParams() { + var $parse: angular.IParseService; + var compiledExp = $parse('a.b.c', () => null); + var compiledExp = $parse('a.b.c', null, false); +} + function doBootstrap(element: Element | JQuery, mode: string): ng.auto.IInjectorService { if (mode === 'debug') { return angular.bootstrap(element, ['main', function($provide: ng.auto.IProvideService) { diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 82cce46541..5aa6807605 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -873,7 +873,7 @@ declare namespace angular { // see http://docs.angularjs.org/api/ng.$parseProvider /////////////////////////////////////////////////////////////////////////// interface IParseService { - (expression: string): ICompiledExpression; + (expression: string, interceptorFn?: (value: any, scope: IScope, locals: any) => any, expensiveChecks?: boolean): ICompiledExpression; } interface IParseProvider { diff --git a/angularjs/legacy/angular-1.4.d.ts b/angularjs/legacy/angular-1.4.d.ts index 22c504712e..2cb129dca1 100644 --- a/angularjs/legacy/angular-1.4.d.ts +++ b/angularjs/legacy/angular-1.4.d.ts @@ -886,7 +886,7 @@ declare namespace angular { // see http://docs.angularjs.org/api/ng.$parseProvider /////////////////////////////////////////////////////////////////////////// interface IParseService { - (expression: string): ICompiledExpression; + (expression: string, interceptorFn?: (value: any, scope: IScope, locals: any) => any, expensiveChecks?: boolean): ICompiledExpression; } interface IParseProvider { From feba22125aaa49e8134705443c9f3fbfaca7d6b8 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Sun, 24 Jul 2016 15:36:10 +0900 Subject: [PATCH 38/81] TypeScript-STL v1.0 RC-5 (#10211) * Node-Scanf * TypeScript-STL v1 RC-5 --- typescript-stl/typescript-stl.d.ts | 593 +++++++++++++++++++++-------- 1 file changed, 435 insertions(+), 158 deletions(-) diff --git a/typescript-stl/typescript-stl.d.ts b/typescript-stl/typescript-stl.d.ts index 9baa19ec30..a0f92b88b6 100644 --- a/typescript-stl/typescript-stl.d.ts +++ b/typescript-stl/typescript-stl.d.ts @@ -1,5 +1,5 @@ -// Type definitions for TypeScript-STL v1.0.0-rc.2 -// Project: https://github.com/samchon/stl +// Type definitions for TypeScript-STL v1.0.0-rc.3 +// Project: https://github.com/samchon/typescript-stl // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -13,16 +13,102 @@ declare module "typescript-stl" *

*

* - *

GitHub Repository: https://github.com/samchon/stl

- * *

STL (Standard Template Library) Containers and Algorithms for TypeScript.

* *

TypeScript-STL is a TypeScript's Standard Template Library who is migrated from C++ STL. Most of classes * and functions of STL have implemented. Just enjoy it.

* + * @git https://github.com/samchon/typescript-stl * @author Jeongho Nam */ declare namespace std { + /** + * Type definition of {@link Vector} and it's the original name used in C++. + */ + export import vector = Vector; + /** + * Type definition of {@link List} and it's the original name used in C++. + */ + export import list = List; + /** + * Type definition of {@link Deque} and it's the original name used in C++. + */ + export import deque = Deque; + /** + * Type definition of {@link Stack} and it's the original name used in C++. + */ + type stack = Stack; + /** + * Type definition of {@link Queue} and it's the original name used in C++. + */ + type queue = Queue; + /** + * Type definition of {@link PriorityQueue} and it's the original name used in C++. + */ + type priority_queue = PriorityQueue; + var stack: typeof Stack; + var queue: typeof Queue; + var priority_queue: typeof PriorityQueue; + /** + * Type definition of {@link TreeSet} and it's the original name used in C++. + */ + export import set = TreeSet; + /** + * Type definition of {@link TreeMultiSet} and it's the original name used in C++. + */ + export import multiset = TreeMultiSet; + /** + * Type definition of {@link HashSet} and it's the original name used in C++. + */ + export import unordered_set = HashSet; + /** + * Type definition of {@link HashMultiSet} and it's the original name used in C++. + */ + export import unordered_multiset = HashMultiSet; + /** + * Type definition of {@link TreeMap} and it's the original name used in C++. + */ + export import map = TreeMap; + /** + * Type definition of {@link TreeMultiMap} and it's the original name used in C++. + */ + export import multimap = TreeMultiMap; + /** + * Type definition of {@link HashMap} and it's the original name used in C++. + */ + export import unordered_map = HashMap; + /** + * Type definition of {@link HashMultiMap} and it's the original name used in C++. + */ + export import unordered_multimap = HashMultiMap; + type exception = Exception; + type logic_error = LogicError; + type domain_error = DomainError; + type invalid_argument = InvalidArgument; + type length_error = LengthError; + type out_of_range = OutOfRange; + type runtime_error = RuntimeError; + type overflow_error = OverflowError; + type underflow_error = UnderflowError; + type range_error = RangeError; + type system_error = SystemError; + type error_category = ErrorCategory; + type error_condition = ErrorCondition; + type error_code = ErrorCode; + var exception: typeof Exception; + var logic_error: typeof LogicError; + var domain_error: typeof DomainError; + var invalid_argument: typeof InvalidArgument; + var length_error: typeof LengthError; + var out_of_range: typeof OutOfRange; + var runtime_error: typeof RuntimeError; + var overflow_error: typeof OverflowError; + var underflow_error: typeof UnderflowError; + var range_error: typeof RangeError; + var system_error: typeof SystemError; + var error_category: typeof ErrorCategory; + var error_condition: typeof ErrorCondition; + var error_code: typeof ErrorCode; } /** * Base classes composing STL in background. @@ -2665,9 +2751,9 @@ declare namespace std.base { /** *

An abstract container.

* - *

- * - *

+ *

+ * + *

* *

Container properties

*
@@ -2786,8 +2872,8 @@ declare namespace std { *

There is not a single type of {@link Iterator bidirectional iterator}: {@link IContainer Each container} * may define its own specific iterator type able to iterate through it and access its elements.

* - *

- * + *

+ * *

* * @reference http://www.cplusplus.com/reference/iterator/BidirectionalIterator @@ -2872,8 +2958,8 @@ declare namespace std { * first element in a range is reversed, the reversed iterator points to the element before the first element (this * would be the past-the-end element of the reversed range).

* - *

- * + *

+ * *

* * @reference http://www.cplusplus.com/reference/iterator/reverse_iterator @@ -3074,6 +3160,10 @@ declare namespace std { */ function end(container: base.MapContainer): MapIterator; } +declare namespace std.Deque { + type iterator = std.DequeIterator; + type reverse_iterator = std.DequeReverseIterator; +} declare namespace std { /** *

Double ended queue.

@@ -3104,8 +3194,8 @@ declare namespace std { * the end, {@link Deque Deques} perform worse and have less consistent iterators and references than * {@link List Lists}.

* - *

- * + *

+ * *

* *

Container properties

@@ -3126,10 +3216,6 @@ declare namespace std { * @author Jeongho Nam */ class Deque extends base.Container implements base.IArrayContainer, base.IDequeContainer { - /** - * Type definition of {@link Deque}'s {@link DequeIterator iterator}. - */ - static iterator: typeof DequeIterator; /** *

Row size of the {@link matrix_ matrix} which contains elements.

* @@ -3394,8 +3480,8 @@ declare namespace std { /** *

An iterator of {@link Deque}.

* - *

- * + *

+ * *

* * @author Jeongho Nam @@ -3466,8 +3552,8 @@ declare namespace std { /** *

A reverse-iterator of Deque.

* - *

- * + *

+ * *

* * @param Type of the elements. @@ -3543,8 +3629,8 @@ declare namespace std { *

All objects thrown by components of the standard library are derived from this class. * Therefore, all standard exceptions can be caught by catching this type by reference.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/exception/exception * @author Jeongho Nam @@ -3592,8 +3678,8 @@ declare namespace std { * *

It is used as a base class for several logical error exceptions.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/stdexcept/logic_error * @author Jeongho Nam @@ -3618,8 +3704,8 @@ declare namespace std { *

No component of the standard library throws exceptions of this type. It is designed as a standard * exception to be thrown by programs.

* - *

< - * img src="http://samchon.github.io/stl/api/assets/images/design/exceptions.png" style="max-width: 100%" />

+ *

+ *

* * @reference http://www.cplusplus.com/reference/stdexcept/domain_error * @author Jeongho Nam @@ -3640,8 +3726,8 @@ declare namespace std { *

It is a standard exception that can be thrown by programs. Some components of the standard library * also throw exceptions of this type to signal invalid arguments.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/stdexcept/invalid_argument * @author Jeongho Nam @@ -3662,8 +3748,8 @@ declare namespace std { *

It is a standard exception that can be thrown by programs. Some components of the standard library, * such as vector and string also throw exceptions of this type to signal errors resizing.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/stdexcept/length_error * @author Jeongho Nam @@ -3685,8 +3771,8 @@ declare namespace std { * such as vector, deque, string and bitset also throw exceptions of this type to signal arguments * out of range.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/stdexcept/out_of_range * @author Jeongho Nam @@ -3707,8 +3793,8 @@ declare namespace std { * *

It is used as a base class for several runtime error exceptions.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/stdexcept/runtime_error * @author Jeongho Nam @@ -3729,10 +3815,10 @@ declare namespace std { *

It is a standard exception that can be thrown by programs. Some components of the standard library * also throw exceptions of this type to signal range errors.

* - *

- *

+ *

+ *

* - * @reference http://www.cplusplus.com/reference/stdexcept/outflow_error + * @reference http://www.cplusplus.com/reference/stdexcept/overflow_error * @author Jeongho Nam */ class OverflowError extends RuntimeError { @@ -3751,8 +3837,8 @@ declare namespace std { *

No component of the standard library throws exceptions of this type. It is designed as a standard * exception to be thrown by programs.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/stdexcept/underflow_error * @author Jeongho Nam @@ -3774,8 +3860,8 @@ declare namespace std { *

It is a standard exception that can be thrown by programs. Some components of the standard library * also throw exceptions of this type to signal range errors.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/stdexcept/range_error * @author Jeongho Nam @@ -4336,8 +4422,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -4360,10 +4446,6 @@ declare namespace std.base { * @author Jeongho Nam */ abstract class MapContainer extends base.Container> { - /** - * Type definition of {@link MapContainer}'s {@link MapIterator iterator}. - */ - static iterator: typeof MapIterator; /** *

{@link List} storing elements.

* @@ -4738,8 +4820,8 @@ declare namespace std { /** *

An iterator of {@link MapContainer map container}.

* - *

- *

+ *

+ *

* * @author Jeongho Nam */ @@ -4809,8 +4891,8 @@ declare namespace std { /** *

A reverse-iterator of {@link MapContainer map container}.

* - *

- *

+ *

+ *

* * @author Jeongho Nam */ @@ -4849,8 +4931,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -4902,6 +4984,50 @@ declare namespace std.base { * @param val Value, the item. */ set(key: Key, val: T): void; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

+ * + * @param key Key value of the element whose mapped value is accessed. + * + * @return A {@link Pair} containing the value pointed to by key. + */ + extract(key: Key): Pair; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

+ * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: MapIterator): MapIterator; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

+ * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: MapReverseIterator): MapReverseIterator; + /** + * @hidden + */ + private extract_by_key(key); + /** + * @hidden + */ + private extract_by_iterator(it); + /** + * @hidden + */ + private extract_by_reverse_iterator(it); /** *

Insert an element.

* @@ -4964,6 +5090,75 @@ declare namespace std.base { * @inheritdoc */ insert>>(first: InputIterator, last: InputIterator): void; + /** + *

Insert or assign an element.

+ * + *

Inserts an element or assigns to the current element if the key already exists.

+ * + *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether + * each inserted element has a key equivalent to the one of an element already in the container, and + * if so, the element is assigned, returning an iterator to this existing element (if the function returns a + * value).

+ * + *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

+ * + * @param key The key used both to look up and to insert if not found. + * @param value Value, the item. + * + * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly + * inserted element or to the element with an equivalent key in the {@link UniqueMap}. The + * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or + * false if an equivalent key already existed so the value is assigned. + */ + insert_or_assign(key: Key, value: T): Pair, boolean>; + /** + *

Insert or assign an element.

+ * + *

Inserts an element or assigns to the current element if the key already exists.

+ * + *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether + * each inserted element has a key equivalent to the one of an element already in the container, and + * if so, the element is assigned, returning an iterator to this existing element (if the function returns a + * value).

+ * + *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

+ * + * @param hint Hint for the position where the element can be inserted. + * @param key The key used both to look up and to insert if not found. + * @param value Value, the item. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had an + * equivalent key in the {@link UniqueMap}. + */ + insert_or_assign(hint: MapIterator, key: Key, value: T): MapIterator; + /** + *

Insert or assign an element.

+ * + *

Inserts an element or assigns to the current element if the key already exists.

+ * + *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether + * each inserted element has a key equivalent to the one of an element already in the container, and + * if so, the element is assigned, returning an iterator to this existing element (if the function returns a + * value).

+ * + *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

+ * + * @param hint Hint for the position where the element can be inserted. + * @param key The key used both to look up and to insert if not found. + * @param value Value, the item. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had an + * equivalent key in the {@link UniqueMap}. + */ + insert_or_assign(hint: MapReverseIterator, key: Key, value: T): MapReverseIterator; + /** + * @hidden + */ + private insert_or_assign_with_key_value(key, value); + /** + * @hidden + */ + private insert_or_assign_with_hint(hint, key, value); /** *

Swap content.

* @@ -5003,8 +5198,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -5092,6 +5287,10 @@ declare namespace std.base { swap(obj: MultiMap): void; } } +declare namespace std.HashMap { + type iterator = std.MapIterator; + type reverse_iterator = std.MapReverseIterator; +} declare namespace std { /** *

Hashed, unordered map.

@@ -5112,8 +5311,9 @@ declare namespace std { *

{@link HashMap} containers are faster than {@link TreeMap} containers to access individual elements by their * key, although they are generally less efficient for range iteration through a subset of their elements.

* - *

- *

+ *

+ * + *

* *

Container properties

*
@@ -5249,6 +5449,10 @@ declare namespace std { private swap_hash_map(obj); } } +declare namespace std.HashMultiMap { + type iterator = std.MapIterator; + type reverse_iterator = std.MapReverseIterator; +} declare namespace std { /** *

Hashed, unordered Multimap.

@@ -5269,8 +5473,9 @@ declare namespace std { *

Elements with equivalent keys are grouped together in the same bucket and in such a way that * an iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

* - *

- *

+ *

+ * + *

* *

Container properties

*
@@ -5428,8 +5633,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -5449,10 +5654,6 @@ declare namespace std.base { * @author Jeongho Nam */ abstract class SetContainer extends Container { - /** - * Type definition of {@link SetContainer}'s {@link SetIterator iterator}. - */ - static iterator: typeof SetIterator; /** *

{@link List} storing elements.

* @@ -5709,8 +5910,8 @@ declare namespace std { /** *

An iterator of a Set.

* - *

- *

+ *

+ *

* * @author Jeongho Nam */ @@ -5768,8 +5969,8 @@ declare namespace std { /** *

A reverse-iterator of Set.

* - *

- *

+ *

+ *

* * @param Type of the elements. * @@ -5798,8 +5999,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -5826,6 +6027,50 @@ declare namespace std.base { * @inheritdoc */ count(key: T): number; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by val and erases it from the {@link UniqueSet}.

+ * + * @param val Value to be extracted. + * + * @return A value. + */ + extract(val: T): T; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

+ * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: SetIterator): SetIterator; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

+ * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: SetReverseIterator): SetReverseIterator; + /** + * @hidden + */ + private extract_by_key(val); + /** + * @hidden + */ + private extract_by_iterator(it); + /** + * @hidden + */ + private extract_by_reverse_iterator(it); /** *

Insert an element.

* @@ -5879,8 +6124,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -5932,6 +6177,10 @@ declare namespace std.base { swap(obj: MultiSet): void; } } +declare namespace std.HashSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} declare namespace std { /** *

Hashed, unordered set.

@@ -5951,8 +6200,8 @@ declare namespace std { * elements by their key, although they are generally less efficient for range iteration through a * subset of their elements.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -6085,6 +6334,10 @@ declare namespace std { private swap_tree_set(obj); } } +declare namespace std.HashMultiSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} declare namespace std { /** *

Hashed, unordered Multiset.

@@ -6104,8 +6357,8 @@ declare namespace std { *

Elements with equivalent values are grouped together in the same bucket and in such a way that an * iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -6242,6 +6495,10 @@ declare namespace std { private swap_tree_set(obj); } } +declare namespace std.List { + type iterator = std.ListIterator; + type reverse_iterator = std.ListReverseIterator; +} declare namespace std { /** *

Doubly linked list.

@@ -6266,8 +6523,8 @@ declare namespace std { * distance between these. They also consume some extra memory to keep the linking information associated to each * element (which may be an important factor for large lists of small-sized elements).

* - *

- * + *

+ * *

* *

Container properties

@@ -6839,8 +7096,8 @@ declare namespace std { /** *

An iterator, node of a List.

* - *

- * + *

+ * *

* * @author Jeongho Nam @@ -6901,8 +7158,8 @@ declare namespace std { /** *

A reverse-iterator of List.

* - *

- * + *

+ * *

* * @param Type of the elements. @@ -6951,8 +7208,8 @@ declare namespace std { * By default, if no container class is specified for a particular {@link Queue} class instantiation, the standard * container {@link List} is used.

* - *

- * + *

+ * *

* * @param Type of elements. @@ -7283,8 +7540,8 @@ declare namespace std { * By default, if no container class is specified for a particular {@link Stack} class instantiation, the standard * container {@link List} is used.

* - *

- * + *

+ * *

* * @param Type of elements. @@ -7394,8 +7651,8 @@ declare namespace std.base { * so that they can be interpreted when needed as more abstract (and portable) * {@link ErrorCondition error conditions}.

* - *

- *

+ *

+ *

* * @author Jeongho Nam */ @@ -7504,8 +7761,8 @@ declare namespace std { *

The class inherits from {@link RuntimeError}, to which it adds an {@link ErrorCode} as * member code (and defines a specialized what member).

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/system_error/system_error * @author Jeongho Nam @@ -7570,8 +7827,8 @@ declare namespace std { * passed by reference. As such, only one object of each of these types shall exist, each uniquely identifying its own * category: all error codes and conditions of a same category shall return a reference to same object.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/system_error/error_category * @author Jeongho Nam @@ -7698,8 +7955,8 @@ declare namespace std { *

The {@link ErrorCategory categories} associated with the {@link ErrorCondition} and the * {@link ErrorCode} define the equivalences between them.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/system_error/error_condition * @author Jeongho Nam @@ -7731,8 +7988,8 @@ declare namespace std { *

Objects of this class associate such numerical codes to {@link ErrorCategory error categories}, so that they * can be interpreted when needed as more abstract (and portable) {@link ErrorCondition error conditions}.

* - *

- *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/system_error/error_code * @author Jeongho Nam @@ -7751,6 +8008,10 @@ declare namespace std { constructor(val: number, category: ErrorCategory); } } +declare namespace std.TreeMap { + type iterator = std.MapIterator; + type reverse_iterator = std.MapReverseIterator; +} declare namespace std { /** *

Tree-structured map, std::map of STL.

@@ -7773,8 +8034,8 @@ declare namespace std { * *

{@link TreeMap}s are typically implemented as binary search trees.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -7927,6 +8188,10 @@ declare namespace std { private swap_tree_map(obj); } } +declare namespace std.TreeMultiMap { + type iterator = std.MapIterator; + type reverse_iterator = std.MapReverseIterator; +} declare namespace std { /** *

Tree-structured multiple-key map.

@@ -7951,8 +8216,8 @@ declare namespace std { * *

{@link TreeMultiMap TreeMultiMaps} are typically implemented as binary search trees.

* - *

< - * img src="http://samchon.github.io/stl/api/assets/images/design/map_containers.png" style="max-width: 100%" />

+ *

< + * img src="http://samchon.github.io/typescript-stl/api/assets/images/design/map_containers.png" style="max-width: 100%" />

* *

Container properties

*
@@ -8112,6 +8377,10 @@ declare namespace std { private swap_tree_multimap(obj); } } +declare namespace std.TreeSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} declare namespace std { /** *

Tree-structured set, std::set of STL.

@@ -8132,8 +8401,8 @@ declare namespace std { * *

{@link TreeSet}s are typically implemented as binary search trees.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -8271,6 +8540,10 @@ declare namespace std { private swap_tree_set(obj); } } +declare namespace std.TreeMultiSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} declare namespace std { /** *

Tree-structured multiple-key set.

@@ -8292,8 +8565,8 @@ declare namespace std { * *

{@link TreeMultiSet TreeMultiSets} are typically implemented as binary search trees.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -8454,8 +8727,8 @@ declare namespace std { * T2). The individual values can be accessed through its public members {@link first} and * {@link second}.

* - * @param Type of member {@link first}. - * @param Type of member {@link second}. + * @param Type of member {@link first}. + * @param Type of member {@link second}. * * @reference http://www.cplusplus.com/reference/utility/pair * @author Jeongho Nam @@ -8509,6 +8782,10 @@ declare namespace std { */ function make_pair(x: T1, y: T2): Pair; } +declare namespace std.Vector { + type iterator = std.VectorIterator; + type reverse_iterator = std.VectorReverseIterator; +} declare namespace std { /** *

Vector, the dynamic array.

@@ -8541,9 +8818,9 @@ declare namespace std { * end, they perform worse than the others, and have less consistent iterators and references than {@link List}s. *

* - *

- * - *

+ *

+ * + *

* *

Container properties

*
@@ -8566,10 +8843,6 @@ declare namespace std { * @author Jeongho Nam */ class Vector extends Array implements base.IArrayContainer { - /** - * Type definition of {@link Vector}'s {@link VectorIterator iterator}. - */ - static iterator: typeof VectorIterator; /** *

Default Constructor.

* @@ -8927,8 +9200,8 @@ declare namespace std { /** *

An iterator of Vector.

* - *

- * + *

+ * *

* * @param Type of the elements. @@ -9004,8 +9277,8 @@ declare namespace std { /** *

A reverse-iterator of Vector.

* - *

- * + *

+ * *

* * @param Type of the elements. @@ -9127,8 +9400,9 @@ declare namespace std.base { *

Elements with equivalent keys are grouped together in the same bucket and in such a way that * an iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

* - *

- *

+ *

+ * + *

* *

Container properties

*
@@ -9422,8 +9696,9 @@ declare namespace std.base { /** *

Hash buckets storing {@link MapIterator MapIterators}.

* - *

- *

+ *

+ * + *

* * @author Jeongho Nam */ @@ -9452,8 +9727,9 @@ declare namespace std.base { * elements by their key, although they are generally less efficient for range iteration through a * subset of their elements.

* - *

- *

+ *

+ * + *

* *

Container properties

*
@@ -9675,8 +9951,9 @@ declare namespace std.base { /** *

Hash buckets storing {@link SetIterator SetIterators}.

* - *

- *

+ *

+ * + *

* * @author Jeongho Nam */ @@ -9716,9 +9993,9 @@ declare namespace std.base { * beginning or the end, {@link IArray} objects perform worse and have less consistent iterators and references * than {@link List Lists}

. * - *

- * - *

+ *

+ * + *

* *

Container properties

*
@@ -9830,9 +10107,9 @@ declare namespace std.base { *

There is not a single type of {@link IArrayIterator random-access iterator}: Each container may define its * own specific iterator type able to iterate through it and access its elements.

* - *

- * - *

+ *

+ * + *

* * @reference http://www.cplusplus.com/reference/iterator/RandomAccessIterator * @author Jeongho Nam @@ -9861,9 +10138,9 @@ declare namespace std.base { *

{@link IContainer} is an interface designed for sequence containers. Sequence containers of STL * (Standard Template Library) are based on the {@link IContainer}.

* - *

- * - *

+ *

+ * + *

* *

Container properties

*
@@ -10053,9 +10330,9 @@ declare namespace std.base { /** *

An interface for deque

* - *

- * - *

+ *

+ * + *

* * @author Jeongho Nam */ @@ -10083,8 +10360,8 @@ declare namespace std.base { /** *

An interface for linear containers.

* - *

- * + *

+ * *

* * @author Jeonngho Nam @@ -10245,7 +10522,7 @@ declare namespace std.base { * * * - *

* *

These constraints enforce a critical property of red-black trees: the path from the root to the farthest @@ -10440,7 +10717,7 @@ declare namespace std.base { * the only loop, and any rotations occur after this loop, this proves that a constant number of rotations * occur.

* - *

* * @param N A node to be inserted or swapped. @@ -10474,7 +10751,7 @@ declare namespace std.base { * node are black) is still violated, but now we can resolve this by * continuing to case 5.

* - *

* * @param N A node to be inserted or swapped. @@ -10505,7 +10782,7 @@ declare namespace std.base { * through {@link XTreeNode.parent P}. In each case, this is the only * black node of the three.

* - *

* * @param N A node to be inserted or swapped. @@ -10659,7 +10936,7 @@ declare namespace std.base { /** *

{@link XTreeNode.sibling S} is red.

* - *

* *

In this case we reverse the colors of {@link XTreeNode.parent P} and @@ -10681,7 +10958,7 @@ declare namespace std.base { *

{@link XTreeNode.parent P}, {@link XTreeNode.sibling S}, and {@link XTreeNode.sibling * S}'s children are black.

* - *

* *

In this case, we simply repaint {@link XTreeNode.sibling S} red. The @@ -10705,7 +10982,7 @@ declare namespace std.base { *

{@link XTreeNode.sibling S} and {@link XTreeNode.sibling S}'s children are * black, but {@link XTreeNode.parent P} is red.

* - *

* *

In this case, we simply exchange the colors of {@link XTreeNode.sibling S} and @@ -10722,7 +10999,7 @@ declare namespace std.base { * left child is red, {@link XTreeNode.sibling S}'s right child is * black, and N is the left child of its parent.

* - *

* *

In this case we rotate right at {@link XTreeNode.sibling S}, so that @@ -10761,7 +11038,7 @@ declare namespace std.base { *

Thus, the paths passing through N pass through one additional * black node.

* - *

* *

Meanwhile, if a path does not go through N, then there are two possibilities:

@@ -10845,8 +11122,8 @@ declare namespace std.base { * *

{@link ITreeMap TreeMultiMaps} are typically implemented as binary search trees.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -10980,8 +11257,8 @@ declare namespace std.base { /** *

A red-black tree storing {@link MapIterator MapIterators}.

* - *

- *

+ *

+ *

* * @author Jeongho Nam */ @@ -11132,8 +11409,8 @@ declare namespace std.base { * *

{@link ITreeSet TreeMultiSets} are typically implemented as binary search trees.

* - *

- *

+ *

+ *

* *

Container properties

*
@@ -11274,8 +11551,8 @@ declare namespace std.base { /** *

A red-black Tree storing {@link SetIterator SetIterators}.

* - *

- *

+ *

+ *

* * @author Jeongho Nam */ From 61e01886837c12f1ddcb855f47122257838376b2 Mon Sep 17 00:00:00 2001 From: York Yao Date: Sun, 24 Jul 2016 01:36:29 -0500 Subject: [PATCH 39/81] fix callback type (#10210) --- v8-profiler/v8-profiler.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v8-profiler/v8-profiler.d.ts b/v8-profiler/v8-profiler.d.ts index 155f37ba55..ca22a60af7 100644 --- a/v8-profiler/v8-profiler.d.ts +++ b/v8-profiler/v8-profiler.d.ts @@ -59,7 +59,7 @@ declare module "v8-profiler" { * callback(error, data) receives serialized snapshot as second argument. (Serialization is not equal to JSON.stringify result). * If callback will not be passed, export returns transform stream. */ - export(callback: (error?: Error, data?: any) => void): void; + export(callback: (error: Error, data: any) => void): void; /** * provides simple export API for snapshot. * callback(error, data) receives serialized snapshot as second argument. (Serialization is not equal to JSON.stringify result). @@ -86,7 +86,7 @@ declare module "v8-profiler" { * provides simple export API for profile. * callback(error, data) receives serialized profile as second argument. (Serialization is equal to JSON.stringify result). */ - export(callback: (error?: Error, data?: any) => void): void; + export(callback: (error: Error, data: any) => void): void; /** * provides simple export API for profile. * callback(error, data) receives serialized profile as second argument. (Serialization is equal to JSON.stringify result). From b8de53efe8604e1ca3e4c52fd9994df303214e88 Mon Sep 17 00:00:00 2001 From: Dan Bucholtz Date: Sun, 24 Jul 2016 01:38:12 -0500 Subject: [PATCH 40/81] eventType is a number, not a string, per the documentation (#10208) --- hammerjs/hammerjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index 6b7cc7fb19..faba777b7a 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -196,7 +196,7 @@ declare class HammerInput pointerType:string; /** Event type, matches the INPUT constants. */ - eventType:string; + eventType:number; /** true when the first input. */ isFirst:boolean; From 6e9e49ad9e1ca60fcc6d31529c66bc2bb79508ba Mon Sep 17 00:00:00 2001 From: NN Date: Sun, 24 Jul 2016 09:38:44 +0300 Subject: [PATCH 41/81] Type WebRequestBody.formData (#10205) --- chrome/chrome.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index 75ec50afad..dbf6a12446 100644 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -7219,7 +7219,7 @@ declare namespace chrome.webRequest { * Optional. * If the request method is POST and the body is a sequence of key-value pairs encoded in UTF8, encoded as either multipart/form-data, or application/x-www-form-urlencoded, this dictionary is present and for each key contains the list of all values for that key. If the data is of another media type, or if it is malformed, the dictionary is not present. An example value of this dictionary is {'key': ['value1', 'value2']}. */ - formData?: Object; + formData?: { [key: string]: string[] }; /** * Optional. * If the request method is PUT or POST, and the body is not already parsed in formData, then the unparsed request body elements are contained in this array. From d3a0db378af7168a4e893480a41ae9b0113d0414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Guillot?= Date: Sun, 24 Jul 2016 08:38:59 +0200 Subject: [PATCH 42/81] Added missing property GridColumnCommandItem.template (#10204) --- kendo-ui/kendo-ui.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/kendo-ui/kendo-ui.d.ts b/kendo-ui/kendo-ui.d.ts index 934a8cd8b1..d90c5f2356 100644 --- a/kendo-ui/kendo-ui.d.ts +++ b/kendo-ui/kendo-ui.d.ts @@ -4411,6 +4411,7 @@ declare namespace kendo.ui { name?: string; text?: GridColumnCommandItemText; className?: string; + template?: string; imageClass?: string; click?: Function; } From a396c170ba4b6a7f45b20fccbdba0d2b81cc8833 Mon Sep 17 00:00:00 2001 From: geppy Date: Sun, 24 Jul 2016 01:45:00 -0500 Subject: [PATCH 43/81] Pouchdb (#10171) * Started definitions for multi-module PouchDB * Fixed whitespace * Updated PouchDB definitions for v5.4.4. --- pouchDB/pouch-tests.ts | 142 -------- pouchDB/pouch-tests.ts.tscparams | 1 - pouchDB/pouch.d.ts | 232 ------------ pouchDB/pouch.d.ts.tscparams | 1 - .../pouchdb-adapter-fruitdown-tests.ts | 18 + .../pouchdb-adapter-fruitdown.d.ts | 26 ++ .../pouchdb-adapter-http-tests.ts | 8 + .../pouchdb-adapter-http.d.ts | 26 ++ .../pouchdb-adapter-idb-tests.ts | 16 + pouchdb-adapter-idb/pouchdb-adapter-idb.d.ts | 38 ++ .../pouchdb-adapter-leveldb-tests.ts | 15 + .../pouchdb-adapter-leveldb.d.ts | 25 ++ .../pouchdb-adapter-localstorage-tests.ts | 15 + .../pouchdb-adapter-localstorage.d.ts | 26 ++ .../pouchdb-adapter-memory-tests.ts | 15 + .../pouchdb-adapter-memory.d.ts | 26 ++ .../pouchdb-adapter-node-websql-tests.ts | 28 ++ .../pouchdb-adapter-node-websql.d.ts | 12 + .../pouchdb-adapter-websql-tests.ts | 29 ++ .../pouchdb-adapter-websql.d.ts | 36 ++ pouchdb-browser/pouchdb-browser-tests.ts | 19 + pouchdb-browser/pouchdb-browser.d.ts | 15 + pouchdb-core/pouchdb-core-tests.ts | 78 ++++ pouchdb-core/pouchdb-core.d.ts | 334 ++++++++++++++++++ pouchdb-http/pouchdb-http-tests.ts | 14 + pouchdb-http/pouchdb-http.d.ts | 12 + pouchdb-mapreduce/pouchdb-mapreduce-tests.ts | 12 + pouchdb-mapreduce/pouchdb-mapreduce.d.ts | 26 ++ pouchdb-node/pouchdb-node-tests.ts | 19 + pouchdb-node/pouchdb-node.d.ts | 24 ++ .../pouchdb-replication-tests.ts | 1 + pouchdb-replication/pouchdb-replication.d.ts | 23 ++ pouchdb/pouchdb-tests.ts | 106 ++++++ pouchdb/pouchdb.d.ts | 24 ++ 34 files changed, 1066 insertions(+), 376 deletions(-) delete mode 100644 pouchDB/pouch-tests.ts delete mode 100644 pouchDB/pouch-tests.ts.tscparams delete mode 100644 pouchDB/pouch.d.ts delete mode 100644 pouchDB/pouch.d.ts.tscparams create mode 100644 pouchdb-adapter-fruitdown/pouchdb-adapter-fruitdown-tests.ts create mode 100644 pouchdb-adapter-fruitdown/pouchdb-adapter-fruitdown.d.ts create mode 100644 pouchdb-adapter-http/pouchdb-adapter-http-tests.ts create mode 100644 pouchdb-adapter-http/pouchdb-adapter-http.d.ts create mode 100644 pouchdb-adapter-idb/pouchdb-adapter-idb-tests.ts create mode 100644 pouchdb-adapter-idb/pouchdb-adapter-idb.d.ts create mode 100644 pouchdb-adapter-leveldb/pouchdb-adapter-leveldb-tests.ts create mode 100644 pouchdb-adapter-leveldb/pouchdb-adapter-leveldb.d.ts create mode 100644 pouchdb-adapter-localstorage/pouchdb-adapter-localstorage-tests.ts create mode 100644 pouchdb-adapter-localstorage/pouchdb-adapter-localstorage.d.ts create mode 100644 pouchdb-adapter-memory/pouchdb-adapter-memory-tests.ts create mode 100644 pouchdb-adapter-memory/pouchdb-adapter-memory.d.ts create mode 100644 pouchdb-adapter-node-websql/pouchdb-adapter-node-websql-tests.ts create mode 100644 pouchdb-adapter-node-websql/pouchdb-adapter-node-websql.d.ts create mode 100644 pouchdb-adapter-websql/pouchdb-adapter-websql-tests.ts create mode 100644 pouchdb-adapter-websql/pouchdb-adapter-websql.d.ts create mode 100644 pouchdb-browser/pouchdb-browser-tests.ts create mode 100644 pouchdb-browser/pouchdb-browser.d.ts create mode 100644 pouchdb-core/pouchdb-core-tests.ts create mode 100644 pouchdb-core/pouchdb-core.d.ts create mode 100644 pouchdb-http/pouchdb-http-tests.ts create mode 100644 pouchdb-http/pouchdb-http.d.ts create mode 100644 pouchdb-mapreduce/pouchdb-mapreduce-tests.ts create mode 100644 pouchdb-mapreduce/pouchdb-mapreduce.d.ts create mode 100644 pouchdb-node/pouchdb-node-tests.ts create mode 100644 pouchdb-node/pouchdb-node.d.ts create mode 100644 pouchdb-replication/pouchdb-replication-tests.ts create mode 100644 pouchdb-replication/pouchdb-replication.d.ts create mode 100644 pouchdb/pouchdb-tests.ts create mode 100644 pouchdb/pouchdb.d.ts diff --git a/pouchDB/pouch-tests.ts b/pouchDB/pouch-tests.ts deleted file mode 100644 index 976a8b0e5f..0000000000 --- a/pouchDB/pouch-tests.ts +++ /dev/null @@ -1,142 +0,0 @@ -/// - -window.alert = function (thing?: string) { - var div = document.createElement('div'); - div.appendChild(document.createTextNode(thing)); - document.getElementsByTagName('body')[0].appendChild(div); -} - -var pouch: PouchDB; - -function pouchTests() { - new PouchDB('testdb', function (err: PouchError, res: PouchDB) { - if (err) { - alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason); - } - else { - pouch = res; - alert("database opened"); - runTests(); - } - }); -} - -var tests = [ - setupTests, - testId, - testAllDocs, - testGet, - testUpdate, - testDelete, - deleteDb -]; - -var testIndex; - -var revs: any = {}; - -function runTests() { - testIndex = 0; - tests[testIndex++](); -} - -// each test function except the last one needs to call nextTest when it is finished doing its thing. -function nextTest() { - alert("starting test " + testIndex); - tests[testIndex++](); -} - -function setupTests() { - alert('setupTests'); - pouch.bulkDocs({ - docs: [{ _id: '1', name: 'record 1' }, - { _id: '2', name: 'record 2' }, - { _id: '3', name: 'record 3' } - ] - }, function (err: PouchError, res: PouchUpdateResponse[]) { - if (err) { - alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason); - } - else { - for (var i = 0; i < res.length; i++) { - if (res[i].ok) { - revs[res[i].id] = res[i].rev; - } - } - alert("test records loaded"); - } - nextTest(); - }); -} - -function testId() { - alert('testId'); - var id = pouch.id(); - alert('Database Id = ' + id); - nextTest(); -} - -function testGet() { - alert('testGet'); - pouch.get('1', function (err: PouchError, res: PouchGetResponse) { - if (err) { - alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason); - } - else { - alert('Retrieved record with id=1, name=[' + res['name'] + ']'); - } - nextTest(); - }); -} - -function testAllDocs() { - alert('testAllDocs'); - pouch.allDocs(function (err: PouchError, res: PouchAllDocsResponse) { - alert('allDocs resulted in ' + res.total_rows + ' results'); - for (var i = 0; i < res.total_rows; i++) { - alert('Retrieved record with id=' + res.rows[i].id + ', rev=[' + res.rows[i].value.rev + ']'); - } - nextTest(); - }); -} - -function testUpdate() { - alert('testUpdate'); - pouch.put({ _id: '2', _rev: revs['2'], name: 'record 2 updated' }, function (err: PouchError, res: PouchUpdateResponse) { - if (err) { - alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason); - } - else { - alert('record updated id=' + res.id + ', rev=[' + res.rev + ']'); - } - testAllDocs(); // spit out the db contents and then go on - }); -} - -function testDelete() { - alert('testDelete'); - pouch.remove({ _id: '3', _rev: revs['3'] }, function (err: PouchError, res: PouchUpdateResponse) { - if (err) { - alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason); - } - else { - alert('record deleted id=' + res.id + ', rev=[' + res.rev + ']'); - } - testAllDocs(); // spit out the db contents and then go on - }); -} - -function deleteDb() { - alert('deleteDb'); - if (pouch) { - pouch = null; - PouchDB.destroy('testdb', function (err: PouchError) { - if (err) { - alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason); - } - else { - alert("database destroyed"); - } - }); - } -} diff --git a/pouchDB/pouch-tests.ts.tscparams b/pouchDB/pouch-tests.ts.tscparams deleted file mode 100644 index 8b13789179..0000000000 --- a/pouchDB/pouch-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pouchDB/pouch.d.ts b/pouchDB/pouch.d.ts deleted file mode 100644 index e601bcaa53..0000000000 --- a/pouchDB/pouch.d.ts +++ /dev/null @@ -1,232 +0,0 @@ -// Type definitions for Pouch 0.1 -// Project: http://pouchdb.com -// Definitions by: Bill Sears -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface PouchError { - status: number; - error: string; - reason: string; -} - -interface PouchApi { - type(): string; - id(): string; - close(callback: () => void): void; -} - -interface PouchInfoResponse { - db_name: string; - doc_count: number; - update_seq: string; -} - -interface PouchApi { - info(callback: (err: PouchError, res: PouchInfoResponse) => void): void; -} - -interface PouchGetOptions { - rev?: string; - revs?: boolean; - revs_info?: boolean; - conflicts?: boolean; - attachments?: boolean; -} - -interface PouchGetResponse { - _id: string; - _rev: string; - _attachments: any; -} - -interface PouchAllDocsOptions { - startkey?: string; - endKey?: string; - descending?: boolean; - include_docs?: boolean; - conflicts?: boolean; -} - -interface PouchAllDocsItem { - id: string; - key: string; - value: any; - doc: any; -} - -interface PouchAllDocsResponse { - total_rows: number; - rows: PouchAllDocsItem[]; -} - -interface PouchApi { - // - // get == select by id - // - get(id: string, opts: PouchGetOptions, callback: (err: PouchError, res: PouchGetResponse) => void): void; - get(id: string, callback: (err: PouchError, res: PouchGetResponse) => void): void; - allDocs(opts: PouchAllDocsOptions, callback: (err: PouchError, res: PouchAllDocsResponse) => void): void; - allDocs(callback: (err: PouchError, res: PouchAllDocsResponse) => void): void; -} - -interface PouchBulkDocsRequest { - docs: any[]; -} - -interface PouchUpdateOptions { - new_edits?: boolean; -} - -interface PouchUpdateResponse { - ok: boolean; - id: string; - rev: string; -} - -interface PouchApi { - bulkDocs(req: PouchBulkDocsRequest, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse[]) => void): void; - bulkDocs(req: PouchBulkDocsRequest, callback: (err: PouchError, res: PouchUpdateResponse[]) => void): void; - // - // post == insert (doc does not contain an _id) - // - post(doc: any, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; - post(doc: any, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; - // - // put == update (doc DOES contain an _id) - // - put(doc: any, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; - put(doc: any, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; - // - // remove == delete - // - remove(doc: any, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; - remove(doc: any, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; -} - -interface PouchFilter { - map: (doc: any) => void; - reduce?: (key: string, value: any) => any; -} - -interface PouchQueryOptions { - complete?: any; - include_docs?: boolean; - error?: (err: PouchError) => void; - descending?: boolean; - reduce?: boolean; -} - -interface PouchQueryResponse { - rows: any[]; -} - -interface PouchApi { - // - // query == select by other criteria - // - query(fun: string, opts: PouchQueryOptions, callback: (err: PouchError, res: PouchQueryResponse) => void): void; - query(fun: string, callback: (err: PouchError, res: PouchQueryResponse) => void): void; - query(fun: PouchFilter, opts: PouchQueryOptions, callback: (err: PouchError, res: PouchQueryResponse) => void): void; - query(fun: PouchFilter, callback: (err: PouchError, res: PouchQueryResponse) => void): void; -} - -interface PouchAttachmentOptions { - decode?: boolean; -} - -interface PouchApi { - getAttachment(id: string, opts: PouchAttachmentOptions, callback: (err: PouchError, res: any) => void): void; - getAttachment(id: string, callback: (err: PouchError, res: any) => void): void; - putAttachment(id: string, rev: string, doc: any, type: string, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; - removeAttachment(id: string, rev: string, callback: (err: PouchError, res: PouchUpdateResponse) => void): void; -} - -interface PouchCancellable { - cancel: () => void; -} - -interface PouchChangesOptions { - onChange: (change: PouchChange) => void; - complete?: (err: PouchError, res: PouchChanges) => void; - seq?: number; - since?: number; - descending?: boolean; - filter?: PouchFilter; - continuous?: boolean; - include_docs?: boolean; - conflicts?: boolean; -} - -interface PouchChange { - changes: any; - doc: PouchGetResponse; - id: string; - seq: number; -} - -interface PouchChanges { - results: PouchChange[]; -} - -interface PouchApi { - changes(opts: PouchChangesOptions, callback: (err: PouchError, res: PouchChanges) => void): PouchCancellable; - changes(callback: (err: PouchError, res: PouchChanges) => void): PouchCancellable; -} - -interface PouchRevsDiffOptions { -} - -interface PouchReplicateOptions { - continuous?: boolean; - onChange?: (e: any) => void; - filter?: any; // Can be either string or PouchFilter - complete?: (err: PouchError, res: PouchChanges) => void; -} - -interface PouchReplicateResponse { - ok: boolean; - start_time: Date; - end_time: Date; - docs_read: number; - docs_written: number; -} - -interface PouchReplicate { - from(url: string, opts: PouchReplicateOptions, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable; - from(url: string, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable; - to(dbName: string, opts: PouchReplicateOptions, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable; - to(dbName: string, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable; -} - -interface PouchApi { - revsDiff(req: any, opts: PouchRevsDiffOptions, callback: (missing: any) => void): void; - revsDiff(req: any, callback: (missing: any) => void): void; - replicate: PouchReplicate; -} - -interface PouchOptions { - name?: string; - adapter?: string; - skip_setup?: boolean; -} - -interface PouchDB extends PouchApi { - new (name: string, opts: PouchOptions, callback: (err: PouchError, res: PouchDB) => void): PouchDB; - new (name: string, callback: (err: PouchError, res: PouchDB) => void): PouchDB; - new (name: string, opts: PouchOptions): PouchDB; - new (name: string): PouchDB; - destroy(name: string, callback: (err: PouchError) => void): void; -} - -declare var PouchDB: PouchDB; - -// Support AMD require -declare module 'pouchdb' { - export = PouchDB; -} - -// -// emit is the function that the PouchFilter.map function should call in order to add a particular item to -// a filter view. -// -declare function emit(key: any, value: any): void; diff --git a/pouchDB/pouch.d.ts.tscparams b/pouchDB/pouch.d.ts.tscparams deleted file mode 100644 index 8b13789179..0000000000 --- a/pouchDB/pouch.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pouchdb-adapter-fruitdown/pouchdb-adapter-fruitdown-tests.ts b/pouchdb-adapter-fruitdown/pouchdb-adapter-fruitdown-tests.ts new file mode 100644 index 0000000000..ee6f70c59b --- /dev/null +++ b/pouchdb-adapter-fruitdown/pouchdb-adapter-fruitdown-tests.ts @@ -0,0 +1,18 @@ +/// +/// + +namespace PouchDBAdapterFruitdownTests { + function testConstructor() { + type MyModel = { numericProperty: number }; + let model: PouchDB.Core.Document; + + let db = new PouchDB(null, { + adapter: 'fruitdown', + }); + db.get('model').then((result) => model); + db = new PouchDB('myDb', { + adapter: 'fruitdown', + }); + db.get('model').then((result) => model); + } +} diff --git a/pouchdb-adapter-fruitdown/pouchdb-adapter-fruitdown.d.ts b/pouchdb-adapter-fruitdown/pouchdb-adapter-fruitdown.d.ts new file mode 100644 index 0000000000..e818121543 --- /dev/null +++ b/pouchdb-adapter-fruitdown/pouchdb-adapter-fruitdown.d.ts @@ -0,0 +1,26 @@ +// Type definitions for pouchdb-adapter-fruitdown v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace PouchDB { + namespace FruitDOWNAdapter { + interface FruitDOWNAdapterConfiguration + extends Configuration.LocalDatabaseConfiguration { + adapter: 'fruitdown'; + } + } + + interface Static { + new(name: string | void, + options: FruitDOWNAdapter.FruitDOWNAdapterConfiguration + ): Database; + } +} + +declare module 'pouchdb-adapter-fruitdown' { + const plugin: PouchDB.Plugin; + export = plugin; +} diff --git a/pouchdb-adapter-http/pouchdb-adapter-http-tests.ts b/pouchdb-adapter-http/pouchdb-adapter-http-tests.ts new file mode 100644 index 0000000000..bbd1b5ec69 --- /dev/null +++ b/pouchdb-adapter-http/pouchdb-adapter-http-tests.ts @@ -0,0 +1,8 @@ +/// +/// + +function testHttpDbCreation() { + const basicDB = new PouchDB('basic', { + adapter: 'http' + }); +} diff --git a/pouchdb-adapter-http/pouchdb-adapter-http.d.ts b/pouchdb-adapter-http/pouchdb-adapter-http.d.ts new file mode 100644 index 0000000000..f1a535be5e --- /dev/null +++ b/pouchdb-adapter-http/pouchdb-adapter-http.d.ts @@ -0,0 +1,26 @@ +// Type definitions for pouchdb-http v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace PouchDB { + namespace HttpAdapter { + interface HttpAdapterConfiguration + extends Configuration.RemoteDatabaseConfiguration { + adapter: 'http'; + } + } + + interface Static { + new(name: string | void, + options: HttpAdapter.HttpAdapterConfiguration + ): Database; + } +} + +declare module 'pouchdb-adapter-http' { + const plugin: PouchDB.Plugin; + export = plugin; +} diff --git a/pouchdb-adapter-idb/pouchdb-adapter-idb-tests.ts b/pouchdb-adapter-idb/pouchdb-adapter-idb-tests.ts new file mode 100644 index 0000000000..2256bfc6bc --- /dev/null +++ b/pouchdb-adapter-idb/pouchdb-adapter-idb-tests.ts @@ -0,0 +1,16 @@ +/// +/// + +function testIdbDbCreation() { + const basicDB = new PouchDB('basic', { + adapter: 'idb' + }); + const persistentDb = new PouchDB('persistent', { + adapter: 'idb', + storage: 'persistent' + }); + const temporaryDb = new PouchDB('temporary', { + adapter: 'idb', + storage: 'temporary' + }); +} diff --git a/pouchdb-adapter-idb/pouchdb-adapter-idb.d.ts b/pouchdb-adapter-idb/pouchdb-adapter-idb.d.ts new file mode 100644 index 0000000000..34e75f6bdf --- /dev/null +++ b/pouchdb-adapter-idb/pouchdb-adapter-idb.d.ts @@ -0,0 +1,38 @@ +// Type definitions for pouchdb-adapter-idb v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace PouchDB { + namespace Core { + interface DatabaseInfo { + idb_attachment_format?: 'base64' | 'binary'; + } + } + + namespace IdbAdapter { + interface IdbAdapterConfiguration + extends Configuration.LocalDatabaseConfiguration { + /** + * Configures storage persistence. + * + * Only works in Firefox 26+. + */ + storage?: 'persistent' | 'temporary'; + adapter: 'idb'; + } + } + + interface Static { + new(name: string | void, + options: IdbAdapter.IdbAdapterConfiguration + ): Database; + } +} + +declare module 'pouchdb-adapter-idb' { + const plugin: PouchDB.Plugin; + export = plugin; +} diff --git a/pouchdb-adapter-leveldb/pouchdb-adapter-leveldb-tests.ts b/pouchdb-adapter-leveldb/pouchdb-adapter-leveldb-tests.ts new file mode 100644 index 0000000000..a9a66df854 --- /dev/null +++ b/pouchdb-adapter-leveldb/pouchdb-adapter-leveldb-tests.ts @@ -0,0 +1,15 @@ +/// +/// + +namespace PouchDBAdapterLevelDBTests { + function testConstructor() { + type MyModel = { numericProperty: number }; + + let db = new PouchDB(null, { + adapter: 'leveldb', + }); + db = new PouchDB('myDb', { + adapter: 'leveldb', + }); + } +} diff --git a/pouchdb-adapter-leveldb/pouchdb-adapter-leveldb.d.ts b/pouchdb-adapter-leveldb/pouchdb-adapter-leveldb.d.ts new file mode 100644 index 0000000000..fcdaaea65b --- /dev/null +++ b/pouchdb-adapter-leveldb/pouchdb-adapter-leveldb.d.ts @@ -0,0 +1,25 @@ +// Type definitions for pouchdb-adapter-leveldb v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace PouchDB { + namespace LevelDbAdapter { + interface LevelDbAdapterConfiguration extends Configuration.LocalDatabaseConfiguration { + adapter: 'leveldb'; + } + } + + interface Static { + new(name: string | void, + options: LevelDbAdapter.LevelDbAdapterConfiguration + ): Database; + } +} + +declare module 'pouchdb-adapter-leveldb' { + const plugin: PouchDB.Plugin; + export = plugin; +} diff --git a/pouchdb-adapter-localstorage/pouchdb-adapter-localstorage-tests.ts b/pouchdb-adapter-localstorage/pouchdb-adapter-localstorage-tests.ts new file mode 100644 index 0000000000..06fe1f9a0b --- /dev/null +++ b/pouchdb-adapter-localstorage/pouchdb-adapter-localstorage-tests.ts @@ -0,0 +1,15 @@ +/// +/// + +namespace PouchDBAdapterLocalStorageyTests { + function testConstructor() { + type MyModel = { numericProperty: number }; + + let db = new PouchDB(null, { + adapter: 'localstorage', + }); + db = new PouchDB('myDb', { + adapter: 'localstorage', + }); + } +} diff --git a/pouchdb-adapter-localstorage/pouchdb-adapter-localstorage.d.ts b/pouchdb-adapter-localstorage/pouchdb-adapter-localstorage.d.ts new file mode 100644 index 0000000000..92f9b17752 --- /dev/null +++ b/pouchdb-adapter-localstorage/pouchdb-adapter-localstorage.d.ts @@ -0,0 +1,26 @@ +// Type definitions for pouchdb-adapter-localstorage v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace PouchDB { + namespace LocalStorageAdapter { + interface LocalStorageAdapterConfiguration + extends Configuration.LocalDatabaseConfiguration { + adapter: 'localstorage'; + } + } + + interface Static { + new(name: string | void, + options: LocalStorageAdapter.LocalStorageAdapterConfiguration + ): Database; + } +} + +declare module 'pouchdb-adapter-localstorage' { + const plugin: PouchDB.Plugin; + export = plugin; +} diff --git a/pouchdb-adapter-memory/pouchdb-adapter-memory-tests.ts b/pouchdb-adapter-memory/pouchdb-adapter-memory-tests.ts new file mode 100644 index 0000000000..b234915648 --- /dev/null +++ b/pouchdb-adapter-memory/pouchdb-adapter-memory-tests.ts @@ -0,0 +1,15 @@ +/// +/// + +namespace PouchDBAdapterMemoryTests { + function testConstructor() { + type MyModel = { numericProperty: number }; + + let db = new PouchDB(null, { + adapter: 'memory', + }); + db = new PouchDB('myDb', { + adapter: 'memory', + }); + } +} diff --git a/pouchdb-adapter-memory/pouchdb-adapter-memory.d.ts b/pouchdb-adapter-memory/pouchdb-adapter-memory.d.ts new file mode 100644 index 0000000000..75c89509ba --- /dev/null +++ b/pouchdb-adapter-memory/pouchdb-adapter-memory.d.ts @@ -0,0 +1,26 @@ +// Type definitions for pouchdb-adapter-memory v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace PouchDB { + namespace MemoryAdapter { + interface MemoryAdapterConfiguration + extends Configuration.LocalDatabaseConfiguration { + adapter: 'memory'; + } + } + + interface Static { + new(name: string | void, + options: MemoryAdapter.MemoryAdapterConfiguration + ): Database; + } +} + +declare module 'pouchdb-adapter-memory' { + const plugin: PouchDB.Plugin; + export = plugin; +} diff --git a/pouchdb-adapter-node-websql/pouchdb-adapter-node-websql-tests.ts b/pouchdb-adapter-node-websql/pouchdb-adapter-node-websql-tests.ts new file mode 100644 index 0000000000..4f751d3395 --- /dev/null +++ b/pouchdb-adapter-node-websql/pouchdb-adapter-node-websql-tests.ts @@ -0,0 +1,28 @@ +/// +/// + +namespace PouchDBAdapterNodeWebSQLTests { + function isBoolean(someBoolean: boolean) { + } + function isNumber(someNumber: number) { + } + function isString(someString: string) { + } + + function testConstructor() { + type MyModel = { numericProperty: number }; + + let db = new PouchDB(null, { + adapter: 'websql', + size: 5, + }); + db = new PouchDB('myDb', { + adapter: 'websql', + }); + + db.info().then((info) => { + isBoolean(info.sqlite_plugin); + isString(info.websql_encoding); + }); + } +} diff --git a/pouchdb-adapter-node-websql/pouchdb-adapter-node-websql.d.ts b/pouchdb-adapter-node-websql/pouchdb-adapter-node-websql.d.ts new file mode 100644 index 0000000000..57a0407a5e --- /dev/null +++ b/pouchdb-adapter-node-websql/pouchdb-adapter-node-websql.d.ts @@ -0,0 +1,12 @@ +// Type definitions for pouchdb-adapter-node-websql v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module 'pouchdb-adapter-node-websql' { + const plugin: PouchDB.Plugin; + export = plugin; +} diff --git a/pouchdb-adapter-websql/pouchdb-adapter-websql-tests.ts b/pouchdb-adapter-websql/pouchdb-adapter-websql-tests.ts new file mode 100644 index 0000000000..1c0242a17c --- /dev/null +++ b/pouchdb-adapter-websql/pouchdb-adapter-websql-tests.ts @@ -0,0 +1,29 @@ +/// +/// + +namespace PouchDBAdapterWebSQLTests { + function isBoolean(someBoolean: boolean) { + } + function isNumber(someNumber: number) { + } + function isString(someString: string) { + } + + function testConstructor() { + type MyModel = { numericProperty: number }; + + let db = new PouchDB('basic'); + db = new PouchDB(null, { + adapter: 'websql' + }); + db = new PouchDB('sized', { + adapter: 'websql', + size: 10 + }); + + db.info().then((info) => { + isBoolean(info.sqlite_plugin); + isString(info.websql_encoding); + }); + } +} diff --git a/pouchdb-adapter-websql/pouchdb-adapter-websql.d.ts b/pouchdb-adapter-websql/pouchdb-adapter-websql.d.ts new file mode 100644 index 0000000000..64b732d482 --- /dev/null +++ b/pouchdb-adapter-websql/pouchdb-adapter-websql.d.ts @@ -0,0 +1,36 @@ +// Type definitions for pouchdb-adapter-websql v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace PouchDB { + namespace Core { + interface DatabaseInfo { + sqlite_plugin?: boolean; + websql_encoding?: 'UTF-8' | 'UTF-16'; + } + } + + namespace AdapterWebSql { + interface Configuration + extends Configuration.LocalDatabaseConfiguration { + /** + * Amount in MB to request for storage. + */ + size?: number; + adapter: 'websql'; + } + } + + interface Static { + new(name: string | void, + options: AdapterWebSql.Configuration): Database; + } +} + +declare module 'pouchdb-adapter-websql' { + const plugin: PouchDB.Plugin; + export = plugin; +} diff --git a/pouchdb-browser/pouchdb-browser-tests.ts b/pouchdb-browser/pouchdb-browser-tests.ts new file mode 100644 index 0000000000..82575efada --- /dev/null +++ b/pouchdb-browser/pouchdb-browser-tests.ts @@ -0,0 +1,19 @@ +/// +/// + +namespace PouchDBBrowserTests { + function testConstructor() { + type MyModel = { numericProperty: number }; + let model: PouchDB.Core.Document; + + let db = new PouchDB(null, { + adapter: 'idb', + }); + db = new PouchDB('myDb', { + adapter: 'http', + }); + db.get('model').then((result) => model); + db.viewCleanup().catch((error) => { + }); + } +} diff --git a/pouchdb-browser/pouchdb-browser.d.ts b/pouchdb-browser/pouchdb-browser.d.ts new file mode 100644 index 0000000000..3fb6dc9f2e --- /dev/null +++ b/pouchdb-browser/pouchdb-browser.d.ts @@ -0,0 +1,15 @@ +// Type definitions for pouchdb-browser v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// + +declare module 'pouchdb-browser' { + const PouchDb: PouchDB.Static; + export = PouchDb; +} diff --git a/pouchdb-core/pouchdb-core-tests.ts b/pouchdb-core/pouchdb-core-tests.ts new file mode 100644 index 0000000000..ac7a6c3e69 --- /dev/null +++ b/pouchdb-core/pouchdb-core-tests.ts @@ -0,0 +1,78 @@ +/// + +namespace PouchDBCoreTests { + function isString(someString: string) { + } + function isNumber(someNumber: number) { + } + + function testAllDocs() { + const db = new PouchDB<{ foo: number }>(); + + db.allDocs().then(({ offset, total_rows, rows }) => { + isNumber(offset); + isNumber(total_rows); + + rows.forEach(({ id, key, value, doc }) => { + isString(id); + isString(key); + isString(value.rev); + + // check document property + isNumber(doc.foo); + }) + }); + + db.allDocs({ startkey: "a", endkey: "b" }); + db.allDocs({ startkey: "a", endkey: "b", inclusive_end: true }); + db.allDocs({ keys: ["a", "b", "c" ]}); + db.allDocs({ key: "a" }); + db.allDocs({ + attachments: true, + binary: true, + conflicts: true, + descending: true, + include_docs: true, + limit: 5, + skip: 1 + }); + } + + function testDestroy() { + const db = new PouchDB<{}>(); + + db.destroy({}, (error) => { + }); + db.destroy().then(() => { + }).catch((error) => { + }); + } + + function testBasics() { + type MyModel = { property: 'someProperty '}; + let model: PouchDB.Core.Document; + const id = 'model'; + + const db = new PouchDB(); + + db.post(model).then((result) => { + isString(result.id); + }); + db.post(model, null, (error, response) => { + }); + + db.get(id).then((result) => model = result); + db.get(id, null, (error, result) => { + }); + + db.put(model).then((error) => { + }); + db.put(model, null, null, null, (error) => { + }); + + db.info().then((info) => { + }); + db.info({ ajax: { cache: true }}, (error, result) => { + }); + } +} diff --git a/pouchdb-core/pouchdb-core.d.ts b/pouchdb-core/pouchdb-core.d.ts new file mode 100644 index 0000000000..a8b6418510 --- /dev/null +++ b/pouchdb-core/pouchdb-core.d.ts @@ -0,0 +1,334 @@ +// Type definitions for pouchdb-core v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace PouchDB { + namespace Core { + interface Error { + } + interface Callback { + (error: E | void, result: R | void): void; + } + type AnyCallback = Callback; + type DocumentId = string; + type DocumentKey = string; + type RevisionId = string; + type Availability = 'available' | 'compacted' | 'not compacted' | 'missing'; + type Attachment = string | ArrayBuffer; + type Encodable = { [propertyName: string]: any }; + + interface Options { + ajax?: Configuration.RemoteRequesterConfiguration; + } + + interface BasicResponse { + /** `true` if the operation was successful; `false` otherwise */ + ok: boolean; + } + interface Response extends BasicResponse { + /** id of the targeted document */ + id: DocumentId; + /** resulting revision of the targeted document */ + rev: RevisionId; + } + + interface DatabaseInfo { + } + + interface Revision { + ok: Document & RevisionIdMeta; + } + interface RevisionInfo { + rev: RevisionId; + status: Availability; + } + + interface IdMeta { + _id: DocumentId; + } + interface RevisionIdMeta { + _rev: RevisionId; + } + interface GetMeta { + /** Conflicting leaf revisions. + * + * Only present if `GetOptions.conflicts` is `true` + */ + _conflicts?: RevisionId[]; + _rev?: RevisionId; + /** Only present if `GetOptions.revs` is `true` */ + _revs_info?: RevisionInfo[]; + /** Only present if `GetOptions.revs_info` is `true` */ + _revisions?: { + ids: RevisionId[]; + start: number; + } + } + type NewDocument = Content; + type Document = Content & IdMeta; + type ExistingDocument = + Document & RevisionIdMeta; + + interface AllDocsOptions extends Options { + /** Include attachment data for each document. + * + * Requires `include_docs` to be `true`. + * + * By default, attachments are Base64-encoded. + * @see binary + */ + attachments?: boolean; + /** Return attachments as Buffers. + * + * Requires `include_docs` to be `true`. + * Requires `attachments` to be `true`. */ + binary?: boolean; + /** Include conflict information for each document. + * + * Requires `include_docs` to be `true`. */ + conflicts?: boolean; + /** Reverse ordering of results. */ + descending?: boolean; + /** Include contents for each document. */ + include_docs?: boolean; + /** Maximum number of documents to return. */ + limit?: number; + /** Number of documents to skip before returning. + * + * Causes poor performance on IndexedDB and LevelDB. */ + skip?: number; + } + interface AllDocsWithKeyOptions extends AllDocsOptions { + /** Constrain results to documents matching this key. */ + key: DocumentKey; + } + interface AllDocsWithKeysOptions extends AllDocsOptions { + /** Constrains results to documents matching any of these keys. */ + keys: DocumentId[]; + } + interface AllDocsWithinRangeOptions extends AllDocsOptions { + /** Low end of range, or high end if `descending` is `true`. */ + startkey: DocumentKey; + /** High end of range, or low end if `descending` is `true`. */ + endkey: DocumentKey; + /** Include any documents identified by `endkey`. + * + * Defaults to `true`. */ + inclusive_end?: boolean; + } + interface AllDocsMeta { + _attachments?: { + [attachmentId: string]: Attachment; + }; + } + interface AllDocsResponse { + /** The `skip` if provided, or in CouchDB the actual offset */ + offset: number; + total_rows: number; + rows: { + /** Only present if `include_docs` was `true`. */ + doc?: Document; + id: DocumentId; + key: DocumentKey; + value: { + rev: RevisionId; + } + }[]; + } + + interface DestroyOptions extends Options { + } + + interface GetOptions extends Options { + /** Include list of conflicting leaf revisions. */ + conflicts?: boolean; + /** Specific revision to fetch */ + rev?: RevisionId; + /** Include revision history of the document. */ + revs?: boolean; + /** Include a list of revisions of the document, and their + * availability. */ + revs_info?: boolean; + } + interface GetOpenRevisions extends Options { + /** Fetch all leaf revisions if open_revs="all" or fetch all leaf + * revisions specified in open_revs array. Leaves will be returned + * in the same order as specified in input array. */ + open_revs: 'all' | Core.RevisionId[]; + } + + /** @todo does this have any other properties? */ + interface PutOptions extends Options { + } + interface PostOptions extends PutOptions { + } + + interface InfoOptions extends Options { + } + } + + /** + * Pass this to `PouchDB.plugin()`. + */ + export type Plugin = 'This should be passed to PouchDB.plugin()'; + + namespace Configuration { + interface CommonDatabaseConfiguration { + /** + * Database name. + */ + name?: string; + /** + * Database adapter to use. + * + * If unspecified, PouchDB will infer this automatically, preferring + * IndexedDB to WebSQL in browsers that support both (i.e. Chrome, + * Opera and Android 4.4+). + */ + adapter?: string; + } + + interface LocalDatabaseConfiguration extends CommonDatabaseConfiguration { + /** + * Enables auto compaction, which means compact() is called after + * every change to the database. + * + * Defaults to false. + */ + auto_compaction?: boolean; + /** + * How many old revisions we keep track (not a copy) of. + */ + revs_limit?: number; + } + + interface RemoteRequesterConfiguration { + /** + * Time before HTTP requests time out (in ms). + */ + timeout?: number; + /** + * Appends a random string to the end of all HTTP GET requests to avoid + * them being cached on IE. Set this to true to prevent this happening. + */ + cache?: boolean; + /** + * HTTP headers to add to requests. + */ + headers?: { + [name: string]: string; + } + username?: string; + password?: string; + /** + * Enables transferring cookies and HTTP Authorization information. + * + * Defaults to true. + */ + withCredentials?: boolean; + /** + * Disables automatic creation of databases. + */ + skip_setup?: boolean; + } + + interface RemoteDatabaseConfiguration extends CommonDatabaseConfiguration { + ajax?: RemoteRequesterConfiguration; + } + + type DatabaseConfiguration = LocalDatabaseConfiguration | + RemoteDatabaseConfiguration; + } + + + + interface Static { + plugin(plugin: Plugin): Static; + + new(name?: string, + options?: Configuration.DatabaseConfiguration): Database; + } + + interface Database { + /** Fetch all documents matching the given key. */ + allDocs(options: Core.AllDocsWithKeyOptions): + Promise>; + /** Fetch all documents matching any of the given keys. */ + allDocs(options: Core.AllDocsWithKeysOptions): + Promise>; + /** Fetch all documents matching the given key range. */ + allDocs(options: Core.AllDocsWithinRangeOptions): + Promise>; + /** Fetch all documents. */ + allDocs(options?: Core.AllDocsOptions): + Promise>; + + /** Destroy the database */ + destroy(options: Core.DestroyOptions | void, + callback: Core.AnyCallback): void; + destroy(options?: Core.DestroyOptions | void): Promise; + + /** Fetch a document */ + get(docId: Core.DocumentId, + options: Core.GetOpenRevisions): Promise[]>; + get(docId: Core.DocumentId, + options: Core.GetOpenRevisions, + callback: Core.Callback[]>): void; + get(docId: Core.DocumentId, + options: Core.GetOptions + ): Promise & Core.GetMeta>; + get(docId: Core.DocumentId, + options: Core.GetOptions, + callback: Core.Callback & Core.GetMeta> + ): void; + get(docId: Core.DocumentId, + options: void, + callback: Core.Callback>): void; + get(docId: Core.DocumentId): Promise>; + + /** Create a new document without providing an id. + * + * You should prefer put() to post(), because when you post(), you are + * missing an opportunity to use allDocs() to sort documents by _id + * (because your _ids are random). + * + * @see {@link https://pouchdb.com/2014/06/17/12-pro-tips-for-better-code-with-pouchdb.html|PouchDB Pro Tips} + * */ + post(doc: Core.NewDocument, + options: Core.PostOptions | void, + callback: Core.Callback): void; + post(doc: Core.NewDocument, + options?: Core.PostOptions): Promise; + + /** Create a new document or update an existing document. + * + * If the document already exists, you must specify its revision _rev, + * otherwise a conflict will occur. + * There are some restrictions on valid property names of the documents. + * If you try to store non-JSON data (for instance Date objects) you may + * see inconsistent results. */ + put(doc: Core.Document, + id: Core.DocumentId | void, + revision: Core.RevisionId | void, + options: Core.PutOptions | void, + callback: Core.Callback): void; + put(doc: Core.Document, + id?: Core.DocumentId, + revision?: Core.RevisionId, + options?: Core.PutOptions): Promise; + + /** Get database information */ + info(options: Core.InfoOptions | void, + callback: Core.Callback): void; + info(options?: Core.InfoOptions): Promise; + } +} + +declare module 'pouchdb-core' { + const PouchDb: PouchDB.Static; + export = PouchDb; +} + +declare var PouchDB: PouchDB.Static; diff --git a/pouchdb-http/pouchdb-http-tests.ts b/pouchdb-http/pouchdb-http-tests.ts new file mode 100644 index 0000000000..b3378e68b1 --- /dev/null +++ b/pouchdb-http/pouchdb-http-tests.ts @@ -0,0 +1,14 @@ +/// +/// + +namespace PouchDBHttpTests { + function testConstructor() { + type MyModel = { numericProperty: number }; + let model: PouchDB.Core.Document; + + let db = new PouchDB('myDb', { + adapter: 'http', + }); + db.get('model').then((result) => model); + } +} diff --git a/pouchdb-http/pouchdb-http.d.ts b/pouchdb-http/pouchdb-http.d.ts new file mode 100644 index 0000000000..0fb6d2963c --- /dev/null +++ b/pouchdb-http/pouchdb-http.d.ts @@ -0,0 +1,12 @@ +// Type definitions for pouchdb-http v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module 'pouchdb-http' { + const PouchDb: PouchDB.Static; + export = PouchDb; +} diff --git a/pouchdb-mapreduce/pouchdb-mapreduce-tests.ts b/pouchdb-mapreduce/pouchdb-mapreduce-tests.ts new file mode 100644 index 0000000000..a42f8178ee --- /dev/null +++ b/pouchdb-mapreduce/pouchdb-mapreduce-tests.ts @@ -0,0 +1,12 @@ +/// + +namespace PouchDBBrowserTests { + function testConstructor() { + type MyModel = { numericProperty: number }; + let model: PouchDB.Core.Document; + + let db = new PouchDB('mydb'); + db.viewCleanup().catch((error) => { + }); + } +} diff --git a/pouchdb-mapreduce/pouchdb-mapreduce.d.ts b/pouchdb-mapreduce/pouchdb-mapreduce.d.ts new file mode 100644 index 0000000000..1c04ddceaf --- /dev/null +++ b/pouchdb-mapreduce/pouchdb-mapreduce.d.ts @@ -0,0 +1,26 @@ +// Type definitions for pouchdb-mapreduce v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace PouchDB { + export interface Database { + /** + * Cleans up any stale map/reduce indexes. + * + * As design docs are deleted or modified, their associated index + * files(in CouchDB) or companion databases (in local PouchDBs) continue + * to take up space on disk. viewCleanup() removes these unnecessary + * index files. + */ + viewCleanup(callback: PouchDB.Core.Callback): void; + viewCleanup(): Promise; + } +} + +declare module 'pouchdb-adapter-mapreduce' { + const plugin: PouchDB.Plugin; + export = plugin; +} diff --git a/pouchdb-node/pouchdb-node-tests.ts b/pouchdb-node/pouchdb-node-tests.ts new file mode 100644 index 0000000000..ec9c338092 --- /dev/null +++ b/pouchdb-node/pouchdb-node-tests.ts @@ -0,0 +1,19 @@ +/// +/// + +namespace PouchDBBrowserTests { + function testConstructor() { + type MyModel = { numericProperty: number }; + let model: PouchDB.Core.Document; + + let db = new PouchDB('myDb', { + adapter: 'http', + }); + db = new PouchDB('myDb', { + adapter: 'leveldb', + }); + db.get('model').then((result) => model); + db.viewCleanup().catch((error) => { + }); + } +} diff --git a/pouchdb-node/pouchdb-node.d.ts b/pouchdb-node/pouchdb-node.d.ts new file mode 100644 index 0000000000..deac5a0140 --- /dev/null +++ b/pouchdb-node/pouchdb-node.d.ts @@ -0,0 +1,24 @@ +// Type definitions for pouchdb-node v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// + +declare namespace PouchDB { + namespace Core { + interface DatabaseInfo { + /** The backend *DOWN adapter being used (MemDOWN, RiakDOWN, …). */ + backend_adapter?: string; + } + } +} + +declare module 'pouchdb-node' { + const PouchDb: PouchDB.Static; + export = PouchDb; +} diff --git a/pouchdb-replication/pouchdb-replication-tests.ts b/pouchdb-replication/pouchdb-replication-tests.ts new file mode 100644 index 0000000000..4e51bdea95 --- /dev/null +++ b/pouchdb-replication/pouchdb-replication-tests.ts @@ -0,0 +1 @@ +/// diff --git a/pouchdb-replication/pouchdb-replication.d.ts b/pouchdb-replication/pouchdb-replication.d.ts new file mode 100644 index 0000000000..3dddb04f85 --- /dev/null +++ b/pouchdb-replication/pouchdb-replication.d.ts @@ -0,0 +1,23 @@ +// Type definitions for pouchdb-replication v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace PouchDB { + namespace Replication { + /** @todo When is this present? */ + interface ReplicationMeta { + _replication_id: string; + _replication_state: string; + _replication_state_time: number; + _replication_stats: {}; + } + } +} + +declare module 'pouchdb-replication' { + const plugin: PouchDB.Plugin; + export = plugin; +} diff --git a/pouchdb/pouchdb-tests.ts b/pouchdb/pouchdb-tests.ts new file mode 100644 index 0000000000..4dddcfe50d --- /dev/null +++ b/pouchdb/pouchdb-tests.ts @@ -0,0 +1,106 @@ +/// + +namespace PouchDBTests { + function isString(someString: string) { + } + function isNumber(someNumber: number) { + } + + function testAllDocs() { + const db = new PouchDB<{ foo: number }>(); + + db.allDocs().then(({ offset, total_rows, rows }) => { + isNumber(offset); + isNumber(total_rows); + + rows.forEach(({ id, key, value, doc }) => { + isString(id); + isString(key); + isString(value.rev); + + // check document property + isNumber(doc.foo); + }) + }); + + db.allDocs({ startkey: "a", endkey: "b" }); + db.allDocs({ startkey: "a", endkey: "b", inclusive_end: true }); + db.allDocs({ keys: ["a", "b", "c" ]}); + db.allDocs({ key: "a" }); + db.allDocs({ + attachments: true, + binary: true, + conflicts: true, + descending: true, + include_docs: true, + limit: 5, + skip: 1 + }); + } + + function testDestroy() { + const db = new PouchDB<{}>(); + + db.destroy({}, (error) => { + }); + db.destroy().then(() => { + }).catch((error) => { + }); + } + + function testBasics() { + type MyModel = { property: 'someProperty '}; + let model: PouchDB.Core.Document; + const id = 'model'; + + let db = new PouchDB(); + db = new PouchDB(null, { + adapter: 'fruitdown' + }); + db = new PouchDB(null, { + adapter: 'http' + }); + db = new PouchDB(null, { + adapter: 'idb' + }); + db = new PouchDB(null, { + adapter: 'leveldb' + }); + db = new PouchDB(null, { + adapter: 'localstorage' + }); + db = new PouchDB(null, { + adapter: 'memory' + }); + db = new PouchDB(null, { + adapter: 'websql' + }); + db = new PouchDB(null, { + adapter: 'websql', + size: 100 + }); + + db.post(model).then((result) => { + isString(result.id); + }); + db.post(model, null, (error, response) => { + }); + + db.get(id).then((result) => model = result); + db.get(id, null, (error, result) => { + }); + + db.put(model).then((error) => { + }); + db.put(model, null, null, null, (error) => { + }); + + db.info().then((info) => { + }); + db.info({ ajax: { cache: true }}, (error, result) => { + }); + + db.viewCleanup().catch((error) => { + }); + } +} diff --git a/pouchdb/pouchdb.d.ts b/pouchdb/pouchdb.d.ts new file mode 100644 index 0000000000..2d40feb2ec --- /dev/null +++ b/pouchdb/pouchdb.d.ts @@ -0,0 +1,24 @@ +// Type definitions for pouchdb v5.4.4 +// Project: https://pouchdb.com/ +// Definitions by: Andy Brown , Brian Geppert , Frederico Galvão +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// + +declare module 'pouchdb' { + const plugin: PouchDB.Static; + export = plugin; +} From 54b446166e62553ad923a42f8c6ec42f13cac69f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Guillot?= Date: Sun, 24 Jul 2016 08:48:53 +0200 Subject: [PATCH 44/81] Added new property 'fixedHeight' (#10163) * Added new property 'fixedHeight' * Updated version --- react-datepicker/react-datepicker.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/react-datepicker/react-datepicker.d.ts b/react-datepicker/react-datepicker.d.ts index d987d26f1b..733f783faa 100644 --- a/react-datepicker/react-datepicker.d.ts +++ b/react-datepicker/react-datepicker.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-datepicker v0.27.0 +// Type definitions for react-datepicker v0.28.1 // Project: https://github.com/Hacker0x01/react-datepicker // Definitions by: Rajab Shakirov , Andrey Balokha // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -38,8 +38,9 @@ declare module "react-datepicker" { tabIndex?: number; tetherConstraints?: any[]; title?: string; - todayButton?: string; + todayButton?: string; + fixedHeight?: boolean; } let ReactDatePicker: __React.ClassicComponentClass; export = ReactDatePicker; -} \ No newline at end of file +} From e9aaf22c56bf78193bddf04336907ac3fab54229 Mon Sep 17 00:00:00 2001 From: Afshin Darian Date: Sun, 24 Jul 2016 07:51:55 +0100 Subject: [PATCH 45/81] Rewrite sanitize-html typings. (#10139) * Rewrite sanitize-html typings from scratch, reflect new version, full API. * Remove superfluous exports, concat author instead of replace. --- sanitize-html/sanitize-html-tests.ts | 45 +++++++----------- sanitize-html/sanitize-html.d.ts | 68 ++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 47 deletions(-) diff --git a/sanitize-html/sanitize-html-tests.ts b/sanitize-html/sanitize-html-tests.ts index 22811faac5..eabdcd5a40 100644 --- a/sanitize-html/sanitize-html-tests.ts +++ b/sanitize-html/sanitize-html-tests.ts @@ -1,33 +1,22 @@ /// -import sanitizeHtml = require('sanitize-html'); +import * as sanitize from 'sanitize-html'; -var s: string; -var t: string; - -t = sanitizeHtml(s); -t = sanitizeHtml(s, { -}); -t = sanitizeHtml(s, { - allowedTags: ["a", "br"], - allowedSchemes: ["http"], - allowedAttributes: { "a": ["href"] }, - allowedClasses: { "a": ["someclass"] }, - transformTags: { - "a": "b", - "br": function(tagName: string, attributes: {[index: string]: string}): { tagName: string; attributes: {[index: string]: string};} { - return { tagName: tagName, attributes: attributes }; - } - }, - exclusiveFilter: { - "a": function(frame: { - tag: string; - attribs: { [index: string]: string }; - text: string; - tagPosition: number; - }): boolean { - return false; - } +let options: sanitize.IOptions = { + allowedTags: sanitize.defaults.allowedTags.concat('h1', 'h2', 'img'), + allowedAttributes: { + 'a': sanitize.defaults.allowedAttributes['a'].concat('rel'), + 'img': ['src', 'height', 'width', 'alt'] + }, + transformTags: { + 'a': sanitize.simpleTransform('a', { 'rel': 'nofollow' }), + 'img': 'canvas' + }, + exclusiveFilter: function(frame: sanitize.IFrame) { + return frame.tag === 'a' && !frame.text.trim(); } -}); +}; +let unsafe = '
'; + +let safe = sanitize(unsafe, options); diff --git a/sanitize-html/sanitize-html.d.ts b/sanitize-html/sanitize-html.d.ts index e610a14f71..79ee44b15d 100644 --- a/sanitize-html/sanitize-html.d.ts +++ b/sanitize-html/sanitize-html.d.ts @@ -1,27 +1,57 @@ -// Type definitions for sanitize-html 1.6.0 +// Type definitions for sanitize-html 1.12.0 // Project: https://github.com/punkave/sanitize-html -// Definitions by: Rogier Schouten +// Definitions by: Rogier Schouten , Afshin Darian // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module "sanitize-html" { +declare function sanitize(dirty: string, options?: sanitize.IOptions): string; - function sanitizeHtml(s: string, opts?: { - allowedTags?: string[]; - allowedSchemes?: string[]; - allowedAttributes?: { [index: string]: string[] }; - allowedClasses?: { [index: string]: string[] }; - transformTags?: { [index: string]: any }; - exclusiveFilter?: { - [index: string]: (frame: { - tag: string; - attribs: { [index: string]: string }; - text: string; - tagPosition: number; - }) => boolean - }; - }): string; +declare namespace sanitize { + type Attributes = { [attr: string]: string }; - export = sanitizeHtml; + + type Tag = { tagName: string; attributes: Attributes; }; + + + type Transformer = (tagName: string, attributes: Attributes) => Tag; + + + interface IDefaults { + allowedAttributes: { [index: string]: string[] }; + allowedSchemes: string[]; + allowedSchemesByTag: { [index: string]: string[] }; + allowedTags: string[]; + selfClosing: string[]; + } + + + interface IFrame { + tag: string; + attributes: { [index: string]: string }; + text: string; + tagPosition: number; + } + + + interface IOptions { + allowedAttributes?: { [index: string]: string[] }; + allowedClasses?: { [index: string]: string[] }; + allowedSchemes?: string[]; + allowedTags?: string[]; + exclusiveFilter?: (frame: IFrame) => boolean; + selfClosing?: string[]; + transformTags?: { [tagName: string]: string | Transformer }; + } + + + var defaults: IDefaults; + + + function simpleTransform(tagName: string, attributes: Attributes, merge?: boolean): Transformer; +} + + +declare module 'sanitize-html' { + export = sanitize; } From 1eaec643620630d410d3356c4b6a80ae09d79efb Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sun, 24 Jul 2016 02:52:50 -0400 Subject: [PATCH 46/81] fetch-mock: update to v5 (#10138) --- fetch-mock/fetch-mock-tests.ts | 8 +- fetch-mock/fetch-mock.d.ts | 189 ++++++++++++++++++++++----------- 2 files changed, 129 insertions(+), 68 deletions(-) diff --git a/fetch-mock/fetch-mock-tests.ts b/fetch-mock/fetch-mock-tests.ts index d22bf6d8b8..defefa25a1 100644 --- a/fetch-mock/fetch-mock-tests.ts +++ b/fetch-mock/fetch-mock-tests.ts @@ -18,17 +18,15 @@ fetchMock.mock(/test/, { } }); -fetchMock.reMock(); - fetchMock.restore().reset(); -fetchMock.calls().matched[0][1].body; +(fetchMock.calls().matched[0][1] as RequestInit).body; fetchMock.calls().unmatched[0][0].toUpperCase(); fetchMock.calls("http://test.com")[0][0].toUpperCase(); -fetchMock.calls("http://test.com")[0][1].body; +(fetchMock.calls("http://test.com")[0][1] as RequestInit).body; fetchMock.called("http://test.com"); -fetchMock.lastCall()[1].body; +(fetchMock.lastCall()[1] as RequestInit).body; fetchMock.lastUrl(); fetchMock.lastOptions(); diff --git a/fetch-mock/fetch-mock.d.ts b/fetch-mock/fetch-mock.d.ts index 23fa1cd808..490b4c7dfd 100644 --- a/fetch-mock/fetch-mock.d.ts +++ b/fetch-mock/fetch-mock.d.ts @@ -1,40 +1,32 @@ -// Type definitions for fetch-mock 4.6.0 +// Type definitions for fetch-mock 5.0.0 // Project: https://github.com/wheresrhys/fetch-mock // Definitions by: Alexey Svetliakov , Tamir Duberstein // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// - declare module "fetch-mock" { + type MockRequest = Request | RequestInit; + /** * Mock matcher function * @param url * @param opts */ - type MockMatcherFunction = (url: string, opts: any) => boolean; + type MockMatcherFunction = (url: string, opts: MockRequest) => boolean /** * Mock matcher. Can be one of following: - * string: Either an exact url to match e.g. 'http://www.site.com/page.html' or, if the string begins with a ^, the string following the ^ must begin the url - * e.g. '^http://www.site.com' would match 'http://www.site.com' or 'http://www.site.com/page.html' + * string: Either + * an exact url to match e.g. 'http://www.site.com/page.html' + * if the string begins with a `^`, the string following the `^` must + begin the url e.g. '^http://www.site.com' would match + 'http://www.site.com' or 'http://www.site.com/page.html' + * '*' to match any url * RegExp: A regular expression to test the url against - * Function(url, opts): A function (returning a Boolean) that is passed the url and opts fetch() is called with (or, if fetch() was called with one, the Request instance) + * Function(url, opts): A function (returning a Boolean) that is passed the + url and opts fetch() is called with (or, if fetch() was called with one, + the Request instance) */ - type MockMatcher = string | RegExp | Function | MockMatcherFunction; - - /** - * Mock response function - * @param url - * @param opts - */ - type MockResponseFunction = (url: string, opts: any) => MockResponse; - /** - * number: Creates a response with this status - * string: Creates a 200 response with the string as the response body - * object: As long as the object does not contain any of the properties below it is converted into a json string and returned as the body of a 200 response. - * If MockResponseObject was given then it's used to configure response - */ - type MockResponse = number | string | MockResponseObject | {}; - + type MockMatcher = string | RegExp | MockMatcherFunction; /** * Mock response object @@ -52,93 +44,164 @@ declare module "fetch-mock" { /** * Set the response headers. */ - headers?: { [key: string]: any }; + headers?: { [key: string]: string }; /** - * If this property is present then a Promise rejected with the value of throws is returned + * If this property is present then a Promise rejected with the value + of throws is returned */ throws?: boolean; /** - * This property determines whether or not the request body should be JSON.stringified before being sent + * This property determines whether or not the request body should be + JSON.stringified before being sent * @default true */ sendAsJson?: boolean; } + /** + * Response: A Response instance - will be used unaltered + * number: Creates a response with this status + * string: Creates a 200 response with the string as the response body + * object: As long as the object is not a MockResponseObject it is + converted into a json string and returned as the body of a 200 response + * If MockResponseObject was given then it's used to configure response + * Function(url, opts): A function that is passed the url and opts fetch() + is called with and that returns any of the responses listed above + */ + type MockResponse = Response | Promise + | number | Promise + | string | Promise + | Object | Promise + | MockResponseObject | Promise; + /** + * Mock response function + * @param url + * @param opts + */ + type MockResponseFunction = (url: string, opts: MockRequest) => MockResponse; - interface MockCallOptions { - [key: string]: any; + /** + * Mock options object + */ + interface MockOptions { + /** + * A unique string naming the route. Used to subsequently retrieve + references to the calls, grouped by name. + * @default matcher.toString() + * + * Note: If a non-unique name is provided no error will be thrown + (because names are optional, auto-generated ones may legitimately + clash) + */ + name?: string; + /** + * http method to match + */ + method?: string; + /** + * as specified above + */ + matcher?: MockMatcher; + /** + * as specified above + */ + response?: MockResponse | MockResponseFunction; } - type MockCall = [string, RequestInit]; + type MockCall = [string, MockRequest]; interface MatchedRoutes { - matched: MockCall[]; - unmatched: MockCall[]; + matched: Array; + unmatched: Array; } interface FetchMockStatic { /** - * When using isomorphic-fetch or node-fetch ideally fetch should be added as a global. - * If not possible to do so you can still use fetch-mock in combination with mockery or similar in nodejs. - * To use fetch-mock with with mockery you may use this function to prevent fetch-mock trying to mock the function globally. - * @deprecated - */ - useNonGlobalFetch(func?: any): void; - /** - * Replaces fetch() with a stub which records its calls, grouped by route, and optionally returns a mocked - * Response object or passes the call through to fetch(). Calls to .mock() can be chained. + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Calls to .mock() can be chained. * @param matcher Condition for selecting which requests to mock * @param response Configures the http response returned by the mock */ - mock(matcher: MockMatcher, response?: MockResponse | MockResponseFunction): this; + mock(matcher: MockMatcher, response: MockResponse | MockResponseFunction): this; /** - * Replaces fetch() with a stub which records its calls, grouped by route, and optionally returns a mocked - * Response object or passes the call through to fetch(). Calls to .mock() can be chained. + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Calls to .mock() can be chained. * @param matcher Condition for selecting which requests to mock - * @param method Only matches requests using this http method * @param response Configures the http response returned by the mock + * @param options Additional properties defining the route to mock */ - mock(matcher: MockMatcher, method?: string, response?: MockResponse | MockMatcherFunction): this; + mock(matcher: MockMatcher, response: MockResponse | MockResponseFunction, options: MockOptions): this; /** - * Restores fetch() to its unstubbed state and clears all data recorded for its calls + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Calls to .mock() can be chained. + * @param options The route to mock + */ + mock(options: MockOptions): this; + /** + * Chainable method that restores fetch() to its unstubbed state and + clears all data recorded for its calls. */ restore(): this; /** - * Clears all data recorded for fetch()'s calls + * Chainable method that clears all data recorded for fetch()'s calls */ reset(): this; /** - * Calls restore() internally then calls mock(). This allows you to put some generic calls to mock() in a - * beforeEach() while retaining the flexibility to vary the responses for some tests. reMock() can be chained. + * Returns all calls to fetch, grouped by whether fetch-mock matched + them or not. */ - reMock(matcher?: MockMatcher, response?: MockResponse | MockResponseFunction): this; - reMock(matcher?: MockMatcher, method?: string, response?: MockResponse | MockMatcherFunction): this; - - /** - * Returns an object {matched: [], unmatched: []} containing arrays of all calls to fetch, grouped by whether fetch-mock matched them or not. - * If matcherName is specified then only calls to fetch matching that route are returned. - */ - calls(matcher: string): MockCall[]; calls(): MatchedRoutes; /** - * Returns a Boolean indicating whether fetch was called and a route was matched. If matcherName is specified it only returns true if that particular route was matched. + * Returns all calls to fetch matching matcherName. */ - called(matcher?: string): boolean; + calls(matcherName?: string): Array; + /** + * Returns a Boolean indicating whether fetch was called and a route + was matched. + */ + called(): boolean; + /** + * Returns a Boolean indicating whether fetch was called and a route + named matcherName was matched. + */ + called(matcherName?: string): boolean; /** * Returns the arguments for the last matched call to fetch */ - lastCall(matcher?: string): MockCall; + lastCall(): MockCall; + /** + * Returns the arguments for the last call to fetch matching + matcherName + */ + lastCall(matcherName?: string): MockCall; /** * Returns the url for the last matched call to fetch */ - lastUrl(matcher?: string): string; + lastUrl(): string; + /** + * Returns the url for the last call to fetch matching matcherName + */ + lastUrl(matcherName?: string): string; /** * Returns the options for the last matched call to fetch */ - lastOptions(matcher?: string): MockCallOptions; - + lastOptions(): MockRequest; + /** + * Returns the options for the last call to fetch matching matcherName + */ + lastOptions(matcherName?: string): MockRequest; + /** + * Set some global config options, which include + * sendAsJson [default `true`] - by default fetchMock will + convert objects to JSON before sending. This is overrideable + for each call but for some scenarios, e.g. when dealing with a + lot of array buffers, it can be useful to default to `false` + */ + configure(opts: Object): void; } var fetchMock: FetchMockStatic; export = fetchMock; - } From bc5616cf9c9c1c5045ec8a0623f8fc946e85488f Mon Sep 17 00:00:00 2001 From: Linda_pp Date: Sun, 24 Jul 2016 15:55:13 +0900 Subject: [PATCH 47/81] github-electron: Update to v1.2.7 (#10132) * github-electron: Update to v1.2.6 * github-electron: Update to v1.2.7 * Fix tests for startDrag() * Fix 'Wether' -> 'Whether' * Fix missing/wrong APIs and fix some description * Add missing notes of platform limitations * Fix wether -> whether * Add the same description to overloaded functions * Add `BeginFrameSubscriptionCallback` --- github-electron/github-electron-main-tests.ts | 26 +++ .../github-electron-renderer-tests.ts | 1 + github-electron/github-electron.d.ts | 209 +++++++++++++++--- 3 files changed, 205 insertions(+), 31 deletions(-) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index 9a75f9699e..2c2d66f767 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -96,6 +96,7 @@ app.on('ready', () => { mainWindow.webContents.executeJavaScript('return true;', true); mainWindow.webContents.executeJavaScript('return true;', true, (result: boolean) => console.log(result)); mainWindow.webContents.insertText('blah, blah, blah'); + mainWindow.webContents.startDrag({file: '/path/to/img.png', icon: nativeImage.createFromPath('/path/to/icon.png')}); mainWindow.webContents.findInPage('blah'); mainWindow.webContents.findInPage('blah', { forward: true, @@ -133,6 +134,12 @@ app.on('ready', () => { }); mainWindow.webContents.debugger.sendCommand("Network.enable"); + mainWindow.webContents.capturePage(image => { + console.log(image.toDataURL()); + }); + mainWindow.webContents.capturePage({width: 100, height: 200}, image => { + console.log(image.toPNG()); + }); }); app.commandLine.appendSwitch('enable-web-bluetooth'); @@ -220,6 +227,7 @@ app.dock.setBadge('foo'); var id = app.dock.bounce('informational'); app.dock.cancelBounce(id); app.dock.setIcon('/path/to/icon.png'); +app.dock.setBadgeCount(app.dock.getBadgeCount() + 1); app.setUserTasks([ { @@ -232,6 +240,12 @@ app.setUserTasks([ } ]); app.setUserTasks([]); +if (app.isUnityRunning()) { +} +if (app.isAccessibilitySupportEnabled()) { +} +app.setLoginItemSettings({openAtLogin: true, openAsHidden: false}); +console.log(app.getLoginItemSettings().wasOpenedAtLogin); var window = new BrowserWindow(); window.setProgressBar(0.5); @@ -247,6 +261,7 @@ app.on('ready', () => { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }); onlineStatusWindow.loadURL(`file://${__dirname}/online-status.html`); }); +app.on('accessibility-support-changed', (_, enabled) => console.log('accessibility: ' + enabled)); ipcMain.on('online-status-changed', (event: any, status: any) => { console.log(status); @@ -429,6 +444,14 @@ ipcMain.on('synchronous-message', (event: Electron.IpcMainEvent, arg: any) => { event.returnValue = 'pong'; }); +var winWindows = new BrowserWindow({ + width: 800, + height: 600, + show: false, + thickFrame: false, + type: 'toolbar', +}); + // menu-item // https://github.com/atom/electron/blob/master/docs/api/menu-item.md @@ -700,8 +723,11 @@ app.on('ready', () => { clipboard.writeText('Example String'); clipboard.writeText('Example String', 'selection'); +clipboard.writeBookmark('foo', 'http://example.com'); +clipboard.writeBookmark('foo', 'http://example.com', 'selection'); console.log(clipboard.readText('selection')); console.log(clipboard.availableFormats()); +console.log(clipboard.readBookmark().title); clipboard.clear(); clipboard.write({ diff --git a/github-electron/github-electron-renderer-tests.ts b/github-electron/github-electron-renderer-tests.ts index eecec65752..b7292e3ac5 100644 --- a/github-electron/github-electron-renderer-tests.ts +++ b/github-electron/github-electron-renderer-tests.ts @@ -250,6 +250,7 @@ webview.addEventListener('ipc-message', function(event) { console.log(event.channel); // Prints "pong" }); webview.send('ping'); +webview.capturePage((image) => { console.log(image); }); // In guest page. ipcRenderer.on('ping', function() { diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index b5cd642811..818e75f21b 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Electron v1.2.5 +// Type definitions for Electron v1.2.7 // Project: http://electron.atom.io/ // Definitions by: jedmao , rhysd , Milan Burda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -160,6 +160,12 @@ declare namespace Electron { * Emitted when the gpu process crashes. */ on(event: 'gpu-process-crashed', listener: Function): this; + /** + * Emitted when Chrome's accessibility support changes. + * + * Note: This API is only available on macOS and Windows. + */ + on(event: 'accessibility-support-changed', listener: (event: Event, accessibilitySupportEnabled: boolean) => void): this; on(event: string, listener: Function): this; /** * Try to close all windows. The before-quit event will first be emitted. @@ -341,6 +347,33 @@ declare namespace Electron { * This method can only be called before app is ready. */ disableHardwareAcceleration(): void; + /** + * @returns whether current desktop environment is Unity launcher. (Linux) + * + * Note: This API is only available on Linux. + */ + isUnityRunning(): boolean; + /** + * Returns a Boolean, true if Chrome's accessibility support is enabled, false otherwise. + * This API will return true if the use of assistive technologies, such as screen readers, + * has been detected. + * See https://www.chromium.org/developers/design-documents/accessibility for more details. + * + * Note: This API is only available on macOS and Windows. + */ + isAccessibilitySupportEnabled(): boolean; + /** + * @returns an Object with the login item settings of the app. + * + * Note: This API is only available on macOS and Windows. + */ + getLoginItemSettings(): LoginItemSettings; + /** + * Set the app's login item settings. + * + * Note: This API is only available on macOS and Windows. + */ + setLoginItemSettings(settings: LoginItemSettings): void; commandLine: CommandLine; /** * Note: This API is only available on macOS. @@ -414,6 +447,20 @@ declare namespace Electron { * Note: This API is only available on macOS. */ getBadge(): string; + /** + * Sets the counter badge for current app. Setting the count to 0 will hide the badge. + * + * @returns True when the call succeeded, otherwise returns false. + * + * Note: This API is only available on macOS and Linux. + */ + setBadgeCount(count: number): boolean; + /** + * @returns The current value displayed in the counter badge. + * + * Note: This API is only available on macOS and Linux. + */ + getBadgeCount(): number; /** * Hides the dock icon. * @@ -472,6 +519,32 @@ declare namespace Electron { iconIndex?: number; } + interface LoginItemSettings { + /** + * True if the app is set to open at login. + */ + openAtLogin: boolean; + /** + * True if the app is set to open as hidden at login. This setting is only supported on macOS. + */ + openAsHidden: boolean; + /** + * True if the app was opened at login automatically. This setting is only supported on macOS. + */ + wasOpenedAtLogin?: boolean; + /** + * True if the app was opened as a hidden login item. This indicates that the app should not + * open any windows at startup. This setting is only supported on macOS. + */ + wasOpenedAsHidden?: boolean; + /** + * True if the app was opened as a login item that should restore the state from the previous session. + * This indicates that the app should restore the windows that were open the last time the app was closed. + * This setting is only supported on macOS. + */ + restoreState?: boolean; + } + // https://github.com/electron/electron/blob/master/docs/api/auto-updater.md /** @@ -968,6 +1041,13 @@ declare namespace Electron { * @param callback Supplies the image that stores data of the snapshot. */ capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void; + /** + * Captures the snapshot of page within rect, upon completion the callback + * will be called. Omitting the rect would capture the whole visible page. + * Note: Be sure to read documents on remote buffer in remote if you are going + * to use this API in renderer process. + * @param callback Supplies the image that stores data of the snapshot. + */ capturePage(callback: (image: NativeImage) => void): void; /** * Same as webContents.loadURL(url). @@ -1458,15 +1538,20 @@ declare namespace Electron { * The style of window title bar. */ titleBarStyle?: 'default' | 'hidden' | 'hidden-inset'; + /** + * Use WS_THICKFRAME style for frameless windows on Windows + */ + thickFrame?: boolean; /** * Settings of web page’s features. */ webPreferences?: WebPreferences; } - type BrowserWindowType = BrowserWindowTypeLinux | BrowserWindowTypeMac; + type BrowserWindowType = BrowserWindowTypeLinux | BrowserWindowTypeMac | BrowserWindowTypeWindows; type BrowserWindowTypeLinux = 'desktop' | 'dock' | 'toolbar' | 'splash' | 'notification'; type BrowserWindowTypeMac = 'desktop' | 'textured'; + type BrowserWindowTypeWindows = 'toolbar'; interface Rectangle { x?: number; @@ -1541,10 +1626,27 @@ declare namespace Electron { html?: string; image?: NativeImage; }, type?: ClipboardType): void; + /** + * @returns An Object containing title and url keys representing the bookmark in the clipboard. + * + * Note: This API is available on macOS and Windows. + */ + readBookmark(): Bookmark; + /** + * Writes the title and url into the clipboard as a bookmark. + * + * Note: This API is available on macOS and Windows. + */ + writeBookmark(title: string, url: string, type?: ClipboardType): void; } type ClipboardType = '' | 'selection'; + interface Bookmark { + title: string; + url: string; + } + // https://github.com/electron/electron/blob/master/docs/api/content-tracing.md /** @@ -1836,7 +1938,7 @@ declare namespace Electron { /** * Contains which features the dialog should use. */ - properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory')[]; + properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory' | 'showHiddenFiles')[]; } interface SaveDialogOptions { @@ -3292,6 +3394,17 @@ declare namespace Electron { metaKey: boolean; } + interface DragItem { + /** + * The absolute path of the file to be dragged + */ + file: string; + /** + * The image showing under the cursor when dragging. + */ + icon: NativeImage; + } + // https://github.com/electron/electron/blob/master/docs/api/web-contents.md /** @@ -3739,16 +3852,12 @@ declare namespace Electron { * Begin subscribing for presentation events and captured frames, * The callback will be called when there is a presentation event. */ - beginFrameSubscription(callback: ( - /** - * The frameBuffer is a Buffer that contains raw pixel data. - * On most machines, the pixel data is effectively stored in 32bit BGRA format, - * but the actual representation depends on the endianness of the processor - * (most modern processors are little-endian, on machines with big-endian - * processors the data is in 32bit ARGB format). - */ - frameBuffer: Buffer - ) => void): void; + beginFrameSubscription(onlyDirty: boolean, callback: BeginFrameSubscriptionCallback): void; + /** + * Begin subscribing for presentation events and captured frames, + * The callback will be called when there is a presentation event. + */ + beginFrameSubscription(callback: BeginFrameSubscriptionCallback): void; /** * End subscribing for frame presentation events. */ @@ -3762,6 +3871,18 @@ declare namespace Electron { * Note: This API is available only on macOS. */ showDefinitionForSelection(): void; + /** + * Sets the item as dragging item for current drag-drop operation. + */ + startDrag(item: DragItem): void; + /** + * Captures a snapshot of the page within rect. + */ + capturePage(callback: (image: NativeImage) => void): void; + /** + * Captures a snapshot of the page within rect. + */ + capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void; /** * @returns The unique ID of this WebContents. */ @@ -3786,6 +3907,24 @@ declare namespace Electron { debugger: Debugger; } + interface BeginFrameSubscriptionCallback { + ( + /** + * The frameBuffer is a Buffer that contains raw pixel data. + * On most machines, the pixel data is effectively stored in 32bit BGRA format, + * but the actual representation depends on the endianness of the processor + * (most modern processors are little-endian, on machines with big-endian + * processors the data is in 32bit ARGB format). + */ + frameBuffer: Buffer, + /** + * The dirtyRect is an object with x, y, width, height properties that describes which part of the page was repainted. + * If onlyDirty is set to true, frameBuffer will only contain the repainted area. onlyDirty defaults to false. + */ + dirtyRect?: Bounds + ): void + } + interface ContextMenuParams { /** * x coordinate @@ -3825,76 +3964,76 @@ declare namespace Electron { */ mediaFlags: { /** - * Wether the media element has crashed. + * Whether the media element has crashed. */ inError: boolean; /** - * Wether the media element is paused. + * Whether the media element is paused. */ isPaused: boolean; /** - * Wether the media element is muted. + * Whether the media element is muted. */ isMuted: boolean; /** - * Wether the media element has audio. + * Whether the media element has audio. */ hasAudio: boolean; /** - * Wether the media element is looping. + * Whether the media element is looping. */ isLooping: boolean; /** - * Wether the media element's controls are visible. + * Whether the media element's controls are visible. */ isControlsVisible: boolean; /** - * Wether the media element's controls are toggleable. + * Whether the media element's controls are toggleable. */ canToggleControls: boolean; /** - * Wether the media element can be rotated. + * Whether the media element can be rotated. */ canRotate: boolean; } /** - * Wether the context menu was invoked on an image which has non-empty contents. + * Whether the context menu was invoked on an image which has non-empty contents. */ hasImageContents: boolean; /** - * Wether the context is editable. + * Whether the context is editable. */ isEditable: boolean; /** - * These flags indicate wether the renderer believes it is able to perform the corresponding action. + * These flags indicate whether the renderer believes it is able to perform the corresponding action. */ editFlags: { /** - * Wether the renderer believes it can undo. + * Whether the renderer believes it can undo. */ canUndo: boolean; /** - * Wether the renderer believes it can redo. + * Whether the renderer believes it can redo. */ canRedo: boolean; /** - * Wether the renderer believes it can cut. + * Whether the renderer believes it can cut. */ canCut: boolean; /** - * Wether the renderer believes it can copy + * Whether the renderer believes it can copy */ canCopy: boolean; /** - * Wether the renderer believes it can paste. + * Whether the renderer believes it can paste. */ canPaste: boolean; /** - * Wether the renderer believes it can delete. + * Whether the renderer believes it can delete. */ canDelete: boolean; /** - * Wether the renderer believes it can select all. + * Whether the renderer believes it can select all. */ canSelectAll: boolean; } @@ -4556,6 +4695,14 @@ declare namespace Electron { * @returns The WebContents associated with this webview. */ getWebContents(): WebContents; + /** + * Captures a snapshot of the webview's page. Same as webContents.capturePage([rect, ]callback). + */ + capturePage(callback: (image: NativeImage) => void): void; + /** + * Captures a snapshot of the webview's page. Same as webContents.capturePage([rect, ]callback). + */ + capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void; /** * Fired when a load has committed. This includes navigation within the current document * as well as subframe document-level loads, but does not include asynchronous resource loads. From 4a19f0cc199b863cc300c553b8f97a8448e81c56 Mon Sep 17 00:00:00 2001 From: Marcin Pacholec Date: Sun, 24 Jul 2016 08:56:45 +0200 Subject: [PATCH 48/81] Update chroma-js to v1.1.1 (#10127) * Update chroma-js to v1.1.1 * fix --- chroma-js/chroma-js-0.5.6-tests.ts | 120 +++++++++ chroma-js/chroma-js-0.5.6.d.ts | 317 +++++++++++++++++++++++ chroma-js/chroma-js-tests.ts | 260 +++++++++++-------- chroma-js/chroma-js.d.ts | 400 +++++++++++++---------------- 4 files changed, 764 insertions(+), 333 deletions(-) create mode 100644 chroma-js/chroma-js-0.5.6-tests.ts create mode 100644 chroma-js/chroma-js-0.5.6.d.ts diff --git a/chroma-js/chroma-js-0.5.6-tests.ts b/chroma-js/chroma-js-0.5.6-tests.ts new file mode 100644 index 0000000000..cb8b593d26 --- /dev/null +++ b/chroma-js/chroma-js-0.5.6-tests.ts @@ -0,0 +1,120 @@ +/// + +function test_chroma() { + chroma("red"); + chroma("#ff0000"); + chroma("#f00"); + chroma("FF0000"); + chroma(255, 0, 0); + chroma([255, 0, 0]); + chroma(0, 1, 0.5, 'hsl'); + chroma([0, 1, 0.5], 'hsl'); + chroma(0, 1, 1, 'hsv'); + chroma("rgb(255,0,0)"); + chroma("rgb(100%,0%,0%)"); + chroma("hsl(0,100%,50%)"); + chroma(53.24, 80.09, 67.20, 'lab'); + chroma(53.24, 104.55, 40, 'lch'); + chroma(1, 0, 0, 'gl'); + + chroma.hex("#ff0000"); + chroma.hex("red"); + chroma.hex("rgb(255, 0, 0)"); + + chroma.rgb(255, 0, 0); + chroma.hsl(0, 1, 0.5); + chroma.hsv(120, 0.5, 0.5); + chroma.lab(53.24, 80.09, 67.20); + chroma.lch(53.24, 104.55, 40); + chroma.gl(1, 0, 0); + + chroma.interpolate('white', 'black', 0) // #ffffff + chroma.interpolate('white', 'black', 1) // #000000 + chroma.interpolate('white', 'black', 0.5) // #7f7f7f + chroma.interpolate('white', 'black', 0.5, 'hsv') // #808080 + chroma.interpolate('white', 'black', 0.5, 'lab') // #777777 + + chroma.interpolate('rgba(0,0,0,0)', 'rgba(255,0,0,1)', 0.5).css() //"rgba(127.5,0,0,0.5)" + + var bezInterpolator = chroma.interpolate.bezier(['white', 'yellow', 'red', 'black']); + bezInterpolator(0).hex() // #ffffff + bezInterpolator(0.33).hex() // #ffcc67 + bezInterpolator(0.66).hex() // #b65f1a + bezInterpolator(1).hex() // #000000 + + chroma.luminance('black') // 0 + chroma.luminance('white') // 1 + chroma.luminance('#ff0000') // 0.2126 + + chroma.contrast('white', 'navy') // 16.00 – ok + chroma.contrast('white', 'yellow') // 1.07 – not ok! +} + +function test_color() { + chroma('red').hex() // "#FF0000"" + chroma('red').rgb() // [255, 0, 0] + chroma('red').hsv() // [0, 1, 1] + chroma('red').hsl() // [0, 1, 0.5] + chroma('red').lab() // [53.2407, 80.0924, 67.2031] + chroma('red').lch() // [53.2407, 104.5517, 39.9990] + chroma('red').rgba() // [255, 0, 0, 1] + chroma('red').css() // "rgb(255,0,0)" + chroma('red').alpha(0.7).css() // "rgba(255,0,0,0.7)" + chroma('red').css('hsl') // "hsl(0,100%,50%)" + chroma('red').alpha(0.7).css('hsl') // "hsla(0,100%,50%,0.7)" + chroma('blue').css('hsla') // "hsla(240,100%,50%,1)" + + var red = chroma('red'); + red.alpha(0.5); + red.css(); // rgba(255,0,0,0.5); + + chroma('red').darken().hex() // #BC0000 + chroma('red').brighten().hex() // #FF603B + chroma('#eecc99').saturate().hex() // #fcc973 + chroma('red').desaturate().hex() // #ec3d23 + + chroma('black').luminance() // 0 + chroma('white').luminance() // 1 + chroma('red').luminance() // 0.2126 +} + +function test_scale() { + var scale = chroma.scale(['lightyellow', 'navy']); + scale(0.5); // #7F7FB0 + + chroma.scale('RdYlBu'); + + var col = scale(0.5); + col.hex(); // #7F7FB0 + col.rgb(); // [127.5, 127.5, 176] + + scale = chroma.scale(['lightyellow', 'navy']).out('hex'); + scale(0.5); // "#7F7FB0" + + var scale = chroma.scale(['lightyellow', 'navy']); + scale.mode('hsv')(0.5); // #54C08A + scale.mode('hsl')(0.5); // #31FF98 + scale.mode('lab')(0.5); // #967CB2 + scale.mode('lch')(0.5); // #D26662 + + var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 400]); + scale(200); // #7F7FB0 + + var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 100, 200, 300, 400]); + scale(98); // #7F7FB0 + scale(99); // #7F7FB0 + scale(100); // #AAAAC0 + scale(101); // #AAAAC0 + + chroma.scale(['#eee', '#900']).domain([0, 400], 7); + chroma.scale(['#eee', '#900']).domain([1, 1000000], 7, 'log'); + chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'quantiles'); + chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'k-means'); + chroma.scale(['white', 'red']).domain([0, 100], 4).domain() // [0, 25, 50, 75, 100] + + chroma.scale().range(['lightyellow', 'navy']); + + chroma.scale(['lightyellow', 'navy']).correctLightness(true); + + chroma.scale('RdYlGn').domain([0,1], 5).colors() +} diff --git a/chroma-js/chroma-js-0.5.6.d.ts b/chroma-js/chroma-js-0.5.6.d.ts new file mode 100644 index 0000000000..5d785eda27 --- /dev/null +++ b/chroma-js/chroma-js-0.5.6.d.ts @@ -0,0 +1,317 @@ +// Type definitions for Chroma.js v0.5.6 +// Project: https://github.com/gka/chroma.js +// Definitions by: Sebastian Brückner +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Chroma.js is a tiny library for all kinds of color conversions and color scales. + */ +declare namespace Chroma { + + export interface ChromaStatic { + /** + * Creates a color from a string representation (as supported in CSS). + * + * @param color The string to convert to a color. + * @return the color object. + */ + (color: string): Color; + + /** + * Create a color in the specified color space using a, b and c as values. + * + * @param a + * @param b + * @param c + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + * @return the color object. + */ + (a: number, b: number, c: number, colorSpace?: string): Color; + + /** + * Create a color in the specified color space using values. + * + * @param values An array of values (e.g. [r, g, b, a?]). + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + * @return the color object. + */ + (values: number[], colorSpace?: string): Color; + + /** + * Create a color in the specified color space using a, b and c as values. + * + * @param a + * @param b + * @param c + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + * @return the color object. + */ + color(a: number, b: number, c: number, colorSpace?: string): Color; + + /** + * Calculate the contrast ratio of two colors. + * + * @param color1 The first color. + * @param color2 The second color. + * @return the contrast ratio. + */ + contrast(color1: Color, color2: Color): number; + /** + * Calculate the contrast ratio of two colors. + * + * @param color1 The first color. + * @param color2 The second color. + * @return the contrast ratio. + */ + contrast(color1: Color, color2: string): number; + /** + * Calculate the contrast ratio of two colors. + * + * @param color1 The first color. + * @param color2 The second color. + * @return the contrast ratio. + */ + contrast(color1: string, color2: Color): number; + /** + * Calculate the contrast ratio of two colors. + * + * @param color1 The first color. + * @param color2 The second color. + * @return the contrast ratio. + */ + contrast(color1: string, color2: string): number; + + /** + * Create a color from a hex or string representation (as supported in CSS). + * + * This is an alias of chroma.hex(). + * + * @param color The string to convert to a color. + * @return the color object. + */ + css(color: string): Color; + + /** + * Create a color from a hex or string representation (as supported in CSS). + * + * This is an alias of chroma.css(). + * + * @param color The string to convert to a color. + * @return the color object. + */ + hex(color: string): Color; + + rgb(red: number, green: number, blue: number, alpha?: number): Color; + hsl(hue: number, saturation: number, lightness: number, alpha?: number): Color; + hsv(hue: number, saturation: number, value: number, alpha?: number): Color; + lab(lightness: number, a: number, b: number, alpha?: number): Color; + lch(lightness: number, chroma: number, hue: number, alpha?: number): Color; + gl(red: number, green: number, blue: number, alpha?: number): Color; + + interpolate: InterpolateFunction; + mix: InterpolateFunction; + + luminance(color: Color): number; + luminance(color: string): number; + + /** + * Creates a color scale using a pre-defined color scale. + * + * @param name The name of the color scale. + * @return the resulting color scale. + */ + scale(name: string): Scale; + + /** + * Creates a color scale function from the given set of colors. + * + * @param colors An Array of at least two color names or hex values. + * @return the resulting color scale. + */ + scale(colors?: string[]): Scale; + + scales: PredefinedScales; + } + + interface InterpolateFunction { + (color1: Color, color2: Color, f: number, mode?: string): Color; + (color1: Color, color2: string, f: number, mode?: string): Color; + (color1: string, color2: Color, f: number, mode?: string): Color; + (color1: string, color2: string, f: number, mode?: string): Color; + + bezier(colors: any[]): (t: number) => Color; + } + + interface PredefinedScales { + [key: string]: Scale; + + cool: Scale; + hot: Scale; + } + + export interface Color { + /** + * Creates a color from a string representation (as supported in CSS). + * + * @param color The string to convert to a color. + */ + new(color: string): Color; + + /** + * Create a color in the specified color space using a, b and c as values. + * + * @param a + * @param b + * @param c + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + */ + new(a: number, b: number, c: number, colorSpace?: string): Color; + + /** + * Create a color in the specified color space using a, b and c as color values and alpha as the alpha value. + * + * @param a + * @param b + * @param c + * @param alpha The alpha value of the color. + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + */ + new(a: number, b: number, c: number, alpha: number, colorSpace?: string): Color; + + /** + * Create a color in the specified color space using values. + * + * @param values An array of values (e.g. [r, g, b, a?]). + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + */ + new(values: number[], colorSpace: string): Color; + + /** + * Convert this color to CSS hex representation. + * + * @return this color's hex representation. + */ + hex(): string; + + /** + * @return the relative luminance of the color, which is a value between 0 (black) and 1 (white). + */ + luminance(): number; + + /** + * @return the X11 name of this color or its hex value if it does not have a name. + */ + name(): string; + + /** + * @return the alpha value of the color. + */ + alpha(): number; + + /** + * Set the alpha value. + * + * @param alpha The alpha value. + * @return this + */ + alpha(alpha: number): Color; + + css(mode?: string): string; + + interpolate(color: Color, f: number, mode?: string): Color; + interpolate(color: string, f: number, mode?: string): Color; + + premultiply(): Color; + + rgb(): number[]; + rgba(): number[]; + hsl(): number[]; + hsv(): number[]; + lab(): number[]; + lch(): number[]; + hsi(): number[]; + gl(): number[]; + + darken(amount?: number): Color; + darker(amount: number): Color; + brighten(amount?: number): Color; + brighter(amount: number): Color; + saturate(amount?: number): Color; + desaturate(amount?: number): Color; + + toString(): string; + } + + export interface Scale { + /** + * Interpolate a color using the currently set range and domain. + * + * @param value The value to use for interpolation. + * @return the interpolated hex color OR a Color object (depending on the mode set on this Scale). + */ + (value: number): any; + + /** + * Retreive all possible colors generated by this scale if it has distinct classes. + * + * @param mode The output mode to use. Must be one of Color's getters. Defaults to "hex". + * @return an array of colors in the type specified by mode. + */ + colors(mode?: string): any[]; + + correctLightness(): boolean; + + /** + * Enable or disable automatic lightness correction of this scale. + * + * @param Whether to enable or disable automatic lightness correction. + * @return this + */ + correctLightness(enable: boolean): Scale; + + /** + * Get the current domain. + * + * @return The current domain. + */ + domain(): number[]; + + /** + * Set the domain. + * + * @param domain An Array of at least two numbers (min and max). + * @param classes The number of fixed classes to create between min and max. + * @param mode The scale to use. Examples: log, quantiles, k-means. + * @return this + */ + domain(domain: number[], classes?: number, mode?: string): Scale; + + /** + * Specify in which color space the colors should be interpolated. Defaults to "rgb". + * You can use any of the following spaces: rgb, hsv, hsl, lab, lch + * + * @param colorSpace The color space to use for interpolation. + * @return this + */ + mode(colorSpace: string): Scale; + + /** + * Set the output mode of this Scale. + * + * @param mode The output mode to use. Must be one of Color's getters. + * @return this + */ + out(mode: string): Scale; + + /** + * Set the color range after initialization. + * + * @param colors An Array of at least two color names or hex values. + * @return this + */ + range(colors: string[]): Scale; + } + +} + +declare var chroma: Chroma.ChromaStatic; diff --git a/chroma-js/chroma-js-tests.ts b/chroma-js/chroma-js-tests.ts index 3240ac11f8..ccc9d5a1a7 100644 --- a/chroma-js/chroma-js-tests.ts +++ b/chroma-js/chroma-js-tests.ts @@ -1,120 +1,166 @@ /// function test_chroma() { - chroma("red"); - chroma("#ff0000"); - chroma("#f00"); - chroma("FF0000"); - chroma(255, 0, 0); - chroma([255, 0, 0]); - chroma(0, 1, 0.5, 'hsl'); - chroma([0, 1, 0.5], 'hsl'); - chroma(0, 1, 1, 'hsv'); - chroma("rgb(255,0,0)"); - chroma("rgb(100%,0%,0%)"); - chroma("hsl(0,100%,50%)"); - chroma(53.24, 80.09, 67.20, 'lab'); - chroma(53.24, 104.55, 40, 'lch'); - chroma(1, 0, 0, 'gl'); - - chroma.hex("#ff0000"); - chroma.hex("red"); - chroma.hex("rgb(255, 0, 0)"); - - chroma.rgb(255, 0, 0); - chroma.hsl(0, 1, 0.5); - chroma.hsv(120, 0.5, 0.5); - chroma.lab(53.24, 80.09, 67.20); - chroma.lch(53.24, 104.55, 40); - chroma.gl(1, 0, 0); - - chroma.interpolate('white', 'black', 0) // #ffffff - chroma.interpolate('white', 'black', 1) // #000000 - chroma.interpolate('white', 'black', 0.5) // #7f7f7f - chroma.interpolate('white', 'black', 0.5, 'hsv') // #808080 - chroma.interpolate('white', 'black', 0.5, 'lab') // #777777 - - chroma.interpolate('rgba(0,0,0,0)', 'rgba(255,0,0,1)', 0.5).css() //"rgba(127.5,0,0,0.5)" - - var bezInterpolator = chroma.interpolate.bezier(['white', 'yellow', 'red', 'black']); - bezInterpolator(0).hex() // #ffffff - bezInterpolator(0.33).hex() // #ffcc67 - bezInterpolator(0.66).hex() // #b65f1a - bezInterpolator(1).hex() // #000000 - - chroma.luminance('black') // 0 - chroma.luminance('white') // 1 - chroma.luminance('#ff0000') // 0.2126 - - chroma.contrast('white', 'navy') // 16.00 – ok - chroma.contrast('white', 'yellow') // 1.07 – not ok! + chroma('hotpink'); + chroma('#ff3399'); + chroma('F39'); + chroma.hex("#fff"); + + chroma(0xff3399); + chroma(0xff, 0x33, 0x99); + chroma(255, 51, 153); + chroma([255, 51, 153]); + chroma(330, 1, 0.6, 'hsl'); + chroma.hsl(330, 1, 0.6); + chroma.lch(80, 40, 130); + chroma(80, 40, 130, 'lch'); + chroma.cmyk(0.2, 0.8, 0, 0); + chroma(0.2, 0.8, 0, 0, 'cmyk'); + chroma.gl(0.6, 0, 0.8); + chroma.gl(0.6, 0, 0.8, 0.5); + chroma(0.6, 0, 0.8, 'gl'); + chroma.temperature(2000); + chroma.temperature(3500); + chroma.temperature(6000); + chroma.mix('red', 'blue'); + chroma.mix('red', 'blue', 0.25); + chroma.mix('red', 'blue', 0.5, 'rgb'); + chroma.mix('red', 'blue', 0.5, 'hsl'); + chroma.mix('red', 'blue', 0.5, 'lab'); + chroma.mix('red', 'blue', 0.5, 'lch'); + chroma.blend('4CBBFC', 'EEEE22', 'multiply'); + chroma.blend('4CBBFC', 'EEEE22', 'darken'); + chroma.blend('4CBBFC', 'EEEE22', 'lighten'); + chroma.random(); + chroma.contrast('pink', 'hotpink'); + chroma.contrast('pink', 'purple'); + chroma.brewer.OrRd; + var data = [3.0, 3.5, 3.6, 3.8, 3.8, 4.1, 4.3, 4.4, + 4.6, 4.9, 5.2, 5.3, 5.4, 5.7, 5.8, 5.9, + 6.2, 6.5, 6.8, 7.2, 9]; + chroma.limits(data, 'e', 5); + chroma.limits(data, 'q', 5); + chroma.limits(data, 'k', 5); } function test_color() { - chroma('red').hex() // "#FF0000"" - chroma('red').rgb() // [255, 0, 0] - chroma('red').hsv() // [0, 1, 1] - chroma('red').hsl() // [0, 1, 0.5] - chroma('red').lab() // [53.2407, 80.0924, 67.2031] - chroma('red').lch() // [53.2407, 104.5517, 39.9990] - chroma('red').rgba() // [255, 0, 0, 1] - chroma('red').css() // "rgb(255,0,0)" - chroma('red').alpha(0.7).css() // "rgba(255,0,0,0.7)" - chroma('red').css('hsl') // "hsl(0,100%,50%)" - chroma('red').alpha(0.7).css('hsl') // "hsla(0,100%,50%,0.7)" - chroma('blue').css('hsla') // "hsla(240,100%,50%,1)" - - var red = chroma('red'); - red.alpha(0.5); - red.css(); // rgba(255,0,0,0.5); - - chroma('red').darken().hex() // #BC0000 - chroma('red').brighten().hex() // #FF603B - chroma('#eecc99').saturate().hex() // #fcc973 - chroma('red').desaturate().hex() // #ec3d23 - - chroma('black').luminance() // 0 - chroma('white').luminance() // 1 - chroma('red').luminance() // 0.2126 + chroma('red').alpha(0.5); + chroma('rgba(255,0,0,0.35)').alpha(); + chroma('hotpink').darken(); + chroma('hotpink').darken(2); + chroma('hotpink').brighten(); + chroma('slategray').saturate(); + chroma('slategray').saturate(2); + chroma('hotpink').desaturate(); + chroma('hotpink').desaturate(2); + chroma('hotpink').desaturate(3); + // change hue to 0 deg (=red) + chroma('skyblue').set('hsl.h', 0); + // set chromacity to 30 + chroma('hotpink').set('lch.c', 30); + // half Lab lightness + chroma('orangered').set('lab.l', '*0.5'); + // double Lch saturation + chroma('darkseagreen').set('lch.c', '*2'); + chroma('orangered').get('lab.l'); + chroma('orangered').get('hsl.l'); + chroma('orangered').get('rgb.g'); + chroma('white').luminance(); + chroma('aquamarine').luminance(); + chroma('hotpink').luminance(); + chroma('darkslateblue').luminance(); + chroma('black').luminance(); + chroma('white').luminance(0.5); + chroma('aquamarine').luminance(0.5); + chroma('hotpink').luminance(0.5); + chroma('darkslateblue').luminance(0.5); + chroma('aquamarine').luminance(0.5); + chroma('aquamarine').luminance(0.5, 'lab'); + chroma('aquamarine').luminance(0.5, 'hsl'); + chroma('orange').hex(); + chroma('#ffa500').name(); + chroma('#ffa505').name(); + chroma('teal').css(); + chroma('teal').alpha(0.5).css(); + chroma('teal').css('hsl'); + chroma('orange').rgb(); + chroma('orange').hsl(); + chroma('white').hsl(); + chroma('orange').hsv(); + chroma('white').hsv(); + chroma('orange').hsi(); + chroma('white').hsi(); + chroma('orange').lab(); + chroma('skyblue').lch(); + chroma('skyblue').hcl(); + chroma('#ff3300').temperature(); + chroma('#ff8a13').temperature(); + chroma('#ffe3cd').temperature(); + chroma('#cbdbff').temperature(); + chroma('#b3ccff').temperature(); + chroma('33cc00').gl(); } function test_scale() { - var scale = chroma.scale(['lightyellow', 'navy']); - scale(0.5); // #7F7FB0 + var f = chroma.scale(); + f(0.25); + f(0.5); + f(0.75); + chroma.scale(['yellow', '008ae5']); + chroma.scale(['yellow', 'red', 'black']); + // default domain is [0,1] + chroma.scale(['yellow', '008ae5']); + // set domain to [0,100] + chroma.scale(['yellow', '008ae5']).domain([0, 100]); + // default domain is [0,1] + chroma.scale(['yellow', 'lightgreen', '008ae5']) + .domain([0, 0.25, 1]); + chroma.scale(['yellow', '008ae5']); + chroma.scale(['yellow', 'navy']); + chroma.scale(['yellow', 'navy']).mode('lab'); + chroma.scale(['yellow', 'navy']).mode('lab'); + chroma.scale(['yellow', 'navy']).mode('hsl'); + chroma.scale(['yellow', 'navy']).mode('lch'); + chroma.scale('YlGnBu'); + chroma.scale('Spectral'); + chroma.scale('Spectral').domain([1, 0]); + chroma.brewer.OrRd; + chroma.scale(['yellow', '008ae5']).mode('lch'); + + chroma.scale(['yellow', '008ae5']) + .mode('lch') + .correctLightness(); + // linear interpolation + chroma.scale(['yellow', 'red', 'black']); + // bezier interpolation + chroma.bezier(['yellow', 'red', 'black']); + // convert bezier interpolator into chroma.scale + chroma.bezier(['yellow', 'red', 'black']) + .scale().colors(5); + // use the default helix... + chroma.cubehelix(); + // or customize it + chroma.cubehelix() + .start(200) + .rotations(-0.5) + .gamma(0.8) + .lightness([0.3, 0.8]); + + chroma.cubehelix() + .start(200) + .rotations(-0.35) + .gamma(0.7) + .lightness([0.3, 0.8]) + .scale() // convert to chroma.scale + .correctLightness() + .colors(5); chroma.scale('RdYlBu'); + chroma.scale('RdYlBu').padding(0.15); - var col = scale(0.5); - col.hex(); // #7F7FB0 - col.rgb(); // [127.5, 127.5, 176] + chroma.scale('OrRd'); + chroma.scale('OrRd').padding([0.2, 0]); - scale = chroma.scale(['lightyellow', 'navy']).out('hex'); - scale(0.5); // "#7F7FB0" - - var scale = chroma.scale(['lightyellow', 'navy']); - scale.mode('hsv')(0.5); // #54C08A - scale.mode('hsl')(0.5); // #31FF98 - scale.mode('lab')(0.5); // #967CB2 - scale.mode('lch')(0.5); // #D26662 - - var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 400]); - scale(200); // #7F7FB0 - - var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 100, 200, 300, 400]); - scale(98); // #7F7FB0 - scale(99); // #7F7FB0 - scale(100); // #AAAAC0 - scale(101); // #AAAAC0 - - chroma.scale(['#eee', '#900']).domain([0, 400], 7); - chroma.scale(['#eee', '#900']).domain([1, 1000000], 7, 'log'); - chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'quantiles'); - chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'k-means'); - chroma.scale(['white', 'red']).domain([0, 100], 4).domain() // [0, 25, 50, 75, 100] - - chroma.scale().range(['lightyellow', 'navy']); - - chroma.scale(['lightyellow', 'navy']).correctLightness(true); - - chroma.scale('RdYlGn').domain([0,1], 5).colors() -} + chroma.scale('OrRd').classes(5); + chroma.scale('OrRd').classes(8); +} \ No newline at end of file diff --git a/chroma-js/chroma-js.d.ts b/chroma-js/chroma-js.d.ts index 5d785eda27..654c4d8cef 100644 --- a/chroma-js/chroma-js.d.ts +++ b/chroma-js/chroma-js.d.ts @@ -1,14 +1,14 @@ -// Type definitions for Chroma.js v0.5.6 +// Type definitions for Chroma.js v1.1.1 // Project: https://github.com/gka/chroma.js -// Definitions by: Sebastian Brückner +// Definitions by: Sebastian Brückner , Marcin Pacholec // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * Chroma.js is a tiny library for all kinds of color conversions and color scales. */ declare namespace Chroma { - export interface ChromaStatic { + /** * Creates a color from a string representation (as supported in CSS). * @@ -17,6 +17,14 @@ declare namespace Chroma { */ (color: string): Color; + /** + * Creates a color from a number representation [0; 16777215] + * + * @param color The number to convert to a color. + * @return the color object. + */ + (number: number): Color; + /** * Create a color in the specified color space using a, b and c as values. * @@ -25,72 +33,20 @@ declare namespace Chroma { * @param c * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". * @return the color object. - */ + */ (a: number, b: number, c: number, colorSpace?: string): Color; + (a: number, b: number, c: number, d: number, colorSpace?: string): Color; + /** - * Create a color in the specified color space using values. - * - * @param values An array of values (e.g. [r, g, b, a?]). - * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". - * @return the color object. - */ + * Create a color in the specified color space using values. + * + * @param values An array of values (e.g. [r, g, b, a?]). + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + * @return the color object. + */ (values: number[], colorSpace?: string): Color; - /** - * Create a color in the specified color space using a, b and c as values. - * - * @param a - * @param b - * @param c - * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". - * @return the color object. - */ - color(a: number, b: number, c: number, colorSpace?: string): Color; - - /** - * Calculate the contrast ratio of two colors. - * - * @param color1 The first color. - * @param color2 The second color. - * @return the contrast ratio. - */ - contrast(color1: Color, color2: Color): number; - /** - * Calculate the contrast ratio of two colors. - * - * @param color1 The first color. - * @param color2 The second color. - * @return the contrast ratio. - */ - contrast(color1: Color, color2: string): number; - /** - * Calculate the contrast ratio of two colors. - * - * @param color1 The first color. - * @param color2 The second color. - * @return the contrast ratio. - */ - contrast(color1: string, color2: Color): number; - /** - * Calculate the contrast ratio of two colors. - * - * @param color1 The first color. - * @param color2 The second color. - * @return the contrast ratio. - */ - contrast(color1: string, color2: string): number; - - /** - * Create a color from a hex or string representation (as supported in CSS). - * - * This is an alias of chroma.hex(). - * - * @param color The string to convert to a color. - * @return the color object. - */ - css(color: string): Color; - /** * Create a color from a hex or string representation (as supported in CSS). * @@ -101,217 +57,209 @@ declare namespace Chroma { */ hex(color: string): Color; - rgb(red: number, green: number, blue: number, alpha?: number): Color; - hsl(hue: number, saturation: number, lightness: number, alpha?: number): Color; - hsv(hue: number, saturation: number, value: number, alpha?: number): Color; + hsl(h: number, s: number, l: number): Color; + + hsv(h: number, s: number, v: number): Color; + lab(lightness: number, a: number, b: number, alpha?: number): Color; - lch(lightness: number, chroma: number, hue: number, alpha?: number): Color; + + lch(l: number, c: number, h: number): Color; + + rgb(r: number, g: number, b: number): Color; + + /** + * GL is a variant of RGB(A), with the only difference that the components are normalized to the range of 0..1. + */ gl(red: number, green: number, blue: number, alpha?: number): Color; - interpolate: InterpolateFunction; - mix: InterpolateFunction; + /** + * light 2000K, bright sunlight 6000K. Based on Neil Bartlett's implementation. + * https://github.com/neilbartlett/color-temperature + */ + temperature(t: number): Color; - luminance(color: Color): number; - luminance(color: string): number; + mix(col1: string | Color, col2: string | Color, f?: number, colorSpace?: string): Color; + + interpolate(col1: string | Color, col2: string | Color, f?: number, colorSpace?: string): Color; /** - * Creates a color scale using a pre-defined color scale. - * - * @param name The name of the color scale. - * @return the resulting color scale. + * Blends two colors using RGB channel-wise blend functions. Valid blend modes are multiply, darken, lighten, screen, overlay, burn, and dogde. */ + blend(col1: string, col2: string, blendMode: string): Color; + + /** + * Returns a random color. + */ + random(): Color; + + /** + * Computes the WCAG contrast ratio between two colors. + * A minimum contrast of 4.5:1 is recommended to ensure that text is still readable against a background color. + * + * @param color1 The first color. + * @param color2 The second color. + * @return the contrast ratio. + */ + contrast(col1: string | Color, col2: string | Color): number; + + bezier(colors: string[]): Scale; + + /** + * chroma.brewer is an map of ColorBrewer scales that are included in chroma.js for convenience. + * chroma.scale uses the colors to construct. + */ + brewer: { + OrRd: string[]; + PuBu: string[]; + BuPu: string[]; + Oranges: string[]; + BuGn: string[]; + YlOrBr: string[]; + YlGn: string[]; + Reds: string[]; + RdPu: string[]; + Greens: string[]; + YlGnBu: string[]; + Purples: string[]; + GnBu: string[]; + Greys: string[]; + YlOrRd: string[]; + PuRd: string[]; + Blues: string[]; + PuBuGn: string[]; + Spectral: string[]; + RdYlGn: string[]; + RdBu: string[]; + PiYG: string[]; + PRGn: string[]; + RdYlBu: string[]; + BrBG: string[]; + RdGy: string[]; + PuOr: string[]; + Set2: string[]; + Accent: string[]; + Set1: string[]; + Set3: string[]; + Dark2: string[]; + Paired: string[]; + Pastel2: string[]; + Pastel1: string[]; + }; + + /** + * Helper function that computes class breaks for you, based on actual data. + * Supports three different modes: equidistant breaks, quantiles breaks and breaks based on k-means clusting. + */ + limits(data: number[], mode: string, c: number): number[]; + scale(name: string): Scale; - /** - * Creates a color scale function from the given set of colors. - * - * @param colors An Array of at least two color names or hex values. - * @return the resulting color scale. - */ scale(colors?: string[]): Scale; - scales: PredefinedScales; - } + cubehelix(): Cubehelix; - interface InterpolateFunction { - (color1: Color, color2: Color, f: number, mode?: string): Color; - (color1: Color, color2: string, f: number, mode?: string): Color; - (color1: string, color2: Color, f: number, mode?: string): Color; - (color1: string, color2: string, f: number, mode?: string): Color; - - bezier(colors: any[]): (t: number) => Color; - } - - interface PredefinedScales { - [key: string]: Scale; - - cool: Scale; - hot: Scale; + cmyk(c: number, m: number, y: number, k: number): Color; + + /** + * Create a color from a hex or string representation (as supported in CSS). + * + * This is an alias of chroma.hex(). + * + * @param color The string to convert to a color. + * @return the color object. + */ + css(col: string, mode?: string): string; } export interface Color { - /** - * Creates a color from a string representation (as supported in CSS). - * - * @param color The string to convert to a color. - */ - new(color: string): Color; + alpha(a?: number): Color; - /** - * Create a color in the specified color space using a, b and c as values. - * - * @param a - * @param b - * @param c - * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". - */ - new(a: number, b: number, c: number, colorSpace?: string): Color; + darken(f?: number): Color; - /** - * Create a color in the specified color space using a, b and c as color values and alpha as the alpha value. - * - * @param a - * @param b - * @param c - * @param alpha The alpha value of the color. - * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". - */ - new(a: number, b: number, c: number, alpha: number, colorSpace?: string): Color; + brighten(f?: number): Color; - /** - * Create a color in the specified color space using values. - * - * @param values An array of values (e.g. [r, g, b, a?]). - * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". - */ - new(values: number[], colorSpace: string): Color; + saturate(s?: number): Color; - /** - * Convert this color to CSS hex representation. - * - * @return this color's hex representation. - */ - hex(): string; + desaturate(s?: number): Color; + + set(modechan: string, v: number | string): Color; + + get(modechan: string): number; - /** - * @return the relative luminance of the color, which is a value between 0 (black) and 1 (white). - */ luminance(): number; - /** - * @return the X11 name of this color or its hex value if it does not have a name. - */ + luminance(l: number, mode?: string): Color; + + hex(): string; + name(): string; /** - * @return the alpha value of the color. - */ - alpha(): number; - - /** - * Set the alpha value. + * Create a color from a hex or string representation (as supported in CSS). * - * @param alpha The alpha value. - * @return this + * This is an alias of chroma.hex(). + * + * @param color The string to convert to a color. + * @return the color object. */ - alpha(alpha: number): Color; - css(mode?: string): string; - interpolate(color: Color, f: number, mode?: string): Color; - interpolate(color: string, f: number, mode?: string): Color; - - premultiply(): Color; - rgb(): number[]; + rgba(): number[]; + hsl(): number[]; + hsv(): number[]; - lab(): number[]; - lch(): number[]; + hsi(): number[]; + + lab(): number[]; + + lch(): number[]; + + hcl(): number[]; + + temperature(): number; + gl(): number[]; - - darken(amount?: number): Color; - darker(amount: number): Color; - brighten(amount?: number): Color; - brighter(amount: number): Color; - saturate(amount?: number): Color; - desaturate(amount?: number): Color; - - toString(): string; } export interface Scale { - /** - * Interpolate a color using the currently set range and domain. - * - * @param value The value to use for interpolation. - * @return the interpolated hex color OR a Color object (depending on the mode set on this Scale). - */ + (c: string[]): Scale; + (value: number): any; - /** - * Retreive all possible colors generated by this scale if it has distinct classes. - * - * @param mode The output mode to use. Must be one of Color's getters. Defaults to "hex". - * @return an array of colors in the type specified by mode. - */ - colors(mode?: string): any[]; + domain(d?: number[], n?: number, mode?: string): Scale; - correctLightness(): boolean; + mode(mode: string): Scale; - /** - * Enable or disable automatic lightness correction of this scale. - * - * @param Whether to enable or disable automatic lightness correction. - * @return this - */ - correctLightness(enable: boolean): Scale; + correctLightness(enable?: boolean): Scale; - /** - * Get the current domain. - * - * @return The current domain. - */ - domain(): number[]; + bezier(colors: string[]): Scale; - /** - * Set the domain. - * - * @param domain An Array of at least two numbers (min and max). - * @param classes The number of fixed classes to create between min and max. - * @param mode The scale to use. Examples: log, quantiles, k-means. - * @return this - */ - domain(domain: number[], classes?: number, mode?: string): Scale; + padding(p: number | number[]): Scale; - /** - * Specify in which color space the colors should be interpolated. Defaults to "rgb". - * You can use any of the following spaces: rgb, hsv, hsl, lab, lch - * - * @param colorSpace The color space to use for interpolation. - * @return this - */ - mode(colorSpace: string): Scale; + colors(c?: number): string[]; + + classes(c: number | number[]): (t: number) => Color; + + range(arg: string[]): Scale; + + scale(): Scale; - /** - * Set the output mode of this Scale. - * - * @param mode The output mode to use. Must be one of Color's getters. - * @return this - */ out(mode: string): Scale; - - /** - * Set the color range after initialization. - * - * @param colors An Array of at least two color names or hex values. - * @return this - */ - range(colors: string[]): Scale; } + export interface Cubehelix extends Scale { + start(s: number): Cubehelix; + + rotations(r: number): Cubehelix; + + gamma(g: number): Cubehelix; + + lightness(l: number[]): Cubehelix; + } } declare var chroma: Chroma.ChromaStatic; From c7bae3970a3c8e958fe8f6d1ba44381dbf27c538 Mon Sep 17 00:00:00 2001 From: Cao Jiannan Date: Sun, 24 Jul 2016 15:05:41 +0800 Subject: [PATCH 49/81] widen supertest-as-promised promise usable (#10070) --- promisify-supertest/promisify-supertest.d.ts | 21 +++--- superagent/superagent.d.ts | 53 ++++++++------- .../supertest-as-promised.d.ts | 64 +++++++++++-------- supertest/supertest.d.ts | 51 ++++++++------- 4 files changed, 103 insertions(+), 86 deletions(-) diff --git a/promisify-supertest/promisify-supertest.d.ts b/promisify-supertest/promisify-supertest.d.ts index 54a03f198f..2ef62ee729 100644 --- a/promisify-supertest/promisify-supertest.d.ts +++ b/promisify-supertest/promisify-supertest.d.ts @@ -22,19 +22,18 @@ declare module 'promisify-supertest' { interface SuperTest extends superagent.SuperAgent { } - interface Test extends superagent.Request { + interface Test extends superagent.Request { url: string; serverAddress(app: any, path: string): string; - expect(status: number, callback?: CallbackHandler): Test; - expect(status: number, body: string, callback?: CallbackHandler): Test; - expect(body: string, callback?: CallbackHandler): Test; - expect(body: RegExp, callback?: CallbackHandler): Test; - expect(body: Object, callback?: CallbackHandler): Test; - expect(field: string, val: string, callback?: CallbackHandler): Test; - expect(field: string, val: RegExp, callback?: CallbackHandler): Test; - expect(checker: (res: Response) => any): Test; - end(callback: CallbackHandler): Test; - end(): Promise; + expect(status: number, callback?: CallbackHandler): this; + expect(status: number, body: string, callback?: CallbackHandler): this; + expect(body: string, callback?: CallbackHandler): this; + expect(body: RegExp, callback?: CallbackHandler): this; + expect(body: Object, callback?: CallbackHandler): this; + expect(field: string, val: string, callback?: CallbackHandler): this; + expect(field: string, val: RegExp, callback?: CallbackHandler): this; + expect(checker: (res: Response) => any): this; + end(callback?: CallbackHandler): this & Promise; } interface Response extends superagent.Response { diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index fa0ac1827f..d16b13584f 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -13,6 +13,7 @@ declare module "superagent" { var request: request.SuperAgentStatic; namespace request { + interface SuperAgentRequest extends Request {} interface SuperAgentStatic extends SuperAgent { (url: string): SuperAgentRequest; (method: string, url: string): SuperAgentRequest; @@ -20,7 +21,7 @@ declare module "superagent" { agent(): SuperAgent; } - interface SuperAgent> extends stream.Stream { + interface SuperAgent extends stream.Stream { get(url: string, callback?: CallbackHandler): Req; post(url: string, callback?: CallbackHandler): Req; put(url: string, callback?: CallbackHandler): Req; @@ -79,38 +80,36 @@ declare module "superagent" { get(header: string): string; } - interface Request> /* extends NodeJS.WritableStream */ { + interface Request /* extends NodeJS.WritableStream */ { abort(): void; - accept(type: string): Req; - attach(field: string, file: string, filename?: string): Req; - auth(user: string, name: string): Req; - buffer(val: boolean): Req; - clearTimeout(): Req; - end(callback?: CallbackHandler): Req; - field(name: string, val: string): Req; + accept(type: string): this; + attach(field: string, file: string, filename?: string): this; + auth(user: string, name: string): this; + buffer(val: boolean): this; + clearTimeout(): this; + end(callback?: CallbackHandler): this; + field(name: string, val: string): this; get(field: string): string; - on(name: string, handler: Function): Req; - on(name: 'error', handler: (err: any) => void): Req; - part(): Req; + on(name: string, handler: Function): this; + on(name: 'error', handler: (err: any) => void): this; + part(): this; pipe(stream: NodeJS.WritableStream, options?: Object): stream.Writable; - query(val: Object): Req; - redirects(n: number): Req; - send(data: string): Req; - send(data: Object): Req; - send(): Req; - set(field: string, val: string): Req; - set(field: Object): Req; - timeout(ms: number): Req; - type(val: string): Req; - use(fn: Function): Req; - withCredentials(): Req; - write(data: string, encoding?: string): Req; - write(data: Buffer, encoding?: string): Req; + query(val: Object): this; + redirects(n: number): this; + send(data: string): this; + send(data: Object): this; + send(): this; + set(field: string, val: string): this; + set(field: Object): this; + timeout(ms: number): this; + type(val: string): this; + use(fn: Function): this; + withCredentials(): this; + write(data: string, encoding?: string): this; + write(data: Buffer, encoding?: string): this; } - interface SuperAgentRequest extends Request>>> {} } export = request; } - diff --git a/supertest-as-promised/supertest-as-promised.d.ts b/supertest-as-promised/supertest-as-promised.d.ts index a7256e5bbf..c16be4cb97 100644 --- a/supertest-as-promised/supertest-as-promised.d.ts +++ b/supertest-as-promised/supertest-as-promised.d.ts @@ -4,42 +4,56 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// +/// +/// declare module "supertest-as-promised" { - // Mostly copy-pasted from supertest.d.ts + import * as supertest from "supertest"; + import * as supersgent from "superagent"; + import { SuperTest, Response } from "supertest"; + import * as PromiseBlurbird from "bluebird"; - import * as superagent from 'superagent'; - import * as PromiseBluebird from 'bluebird'; + function supertestAsPromised(app: any): SuperTest; - function supertest(app: any): supertest.SuperTest; - - namespace supertest { - function agent(app?: any): supertest.SuperTest; - - interface SuperTest extends superagent.SuperAgent { + namespace supertestAsPromised { + interface Request extends supertest.Request { } - interface Promise extends PromiseBluebird { - toPromise(): PromiseBluebird; + interface Response extends supertest.Response { } - interface Test extends superagent.Request { - url: string; - serverAddress(app: any, path: string): string; - expect(status: number): Promise; - expect(status: number, body: string): Promise; - expect(body: string): Promise; - expect(body: RegExp): Promise; - expect(body: Object): Promise; - expect(field: string, val: string): Promise; - expect(field: string, val: RegExp): Promise; - expect(checker: (res: Response) => any): Promise; + interface Test extends Promise, supertest.Test, supersgent.Request { + toPromise(): PromiseBlurbird; } - interface Response extends superagent.Response { + function agent(app?: any): SuperTest; + + interface SuperTest extends supertest.SuperTest { } } + export = supertestAsPromised + + // from core-js.d.ts + /** + * Represents the completion of an asynchronous operation + */ + interface Promise { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + catch(onrejected?: (reason: any) => void): Promise; + } - export = supertest; } diff --git a/supertest/supertest.d.ts b/supertest/supertest.d.ts index 430c9f15c5..5793483300 100644 --- a/supertest/supertest.d.ts +++ b/supertest/supertest.d.ts @@ -6,35 +6,40 @@ /// declare module "supertest" { - import superagent = require('superagent'); + import * as superagent from "superagent" - type CallbackHandler = (err: any, res: supertest.Response) => void; - - function supertest(app: any): supertest.SuperTest; + function supertest(app: any): supertest.SuperTest; namespace supertest { - function agent(app?: any): supertest.SuperTest; - - interface SuperTest extends superagent.SuperAgent { - } - - interface Test extends superagent.Request { - url: string; - serverAddress(app: any, path: string): string; - expect(status: number, callback?: CallbackHandler): Test; - expect(status: number, body: string, callback?: CallbackHandler): Test; - expect(body: string, callback?: CallbackHandler): Test; - expect(body: RegExp, callback?: CallbackHandler): Test; - expect(body: Object, callback?: CallbackHandler): Test; - expect(field: string, val: string, callback?: CallbackHandler): Test; - expect(field: string, val: RegExp, callback?: CallbackHandler): Test; - expect(checker: (res: Response) => any): Test; - end(callback?: CallbackHandler): Test; - } - interface Response extends superagent.Response { } + + interface Request extends superagent.Request { + } + + type CallbackHandler = (err: any, res: Response) => void; + interface Test extends Request { + app?: any; + url: string; + serverAddress(app: any, path: string): string; + expect(status: number, callback?: CallbackHandler): this; + expect(status: number, body: string, callback?: CallbackHandler): this; + expect(body: string, callback?: CallbackHandler): this; + expect(body: RegExp, callback?: CallbackHandler): this; + expect(body: Object, callback?: CallbackHandler): this; + expect(field: string, val: string, callback?: CallbackHandler): this; + expect(fzield: string, val: RegExp, callback?: CallbackHandler): this; + expect(checker: (res: Response) => any): this; + end(callback?: CallbackHandler): this; + } + + function agent(app?: any): SuperTest; + + interface SuperTest extends superagent.SuperAgent { + } + } + export = supertest; } From 94d4f0e96e5b11f49708fb3fbce6b5c91e33d52d Mon Sep 17 00:00:00 2001 From: Andrey Kurdyumov Date: Sun, 24 Jul 2016 13:07:51 +0600 Subject: [PATCH 50/81] Make React-Redux work in UMD/Global setup (#10049) --- react-redux/react-redux.d.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/react-redux/react-redux.d.ts b/react-redux/react-redux.d.ts index 8c939859bd..cf203d2368 100644 --- a/react-redux/react-redux.d.ts +++ b/react-redux/react-redux.d.ts @@ -6,9 +6,13 @@ /// /// -declare module "react-redux" { - import { ComponentClass, Component, StatelessComponent, ReactNode } from 'react'; - import { Store, Dispatch, ActionCreator } from 'redux'; +declare namespace ReactRedux { + type ComponentClass

= __React.ComponentClass

; + type StatelessComponent

= __React.StatelessComponent

; + type ReactNode = __React.ReactNode; + type Store = Redux.Store; + type Dispatch = Redux.Dispatch; + type ActionCreator = Redux.ActionCreator; interface ComponentDecorator { (component: ComponentClass|StatelessComponent): ComponentClass; @@ -101,5 +105,9 @@ declare module "react-redux" { /** * Makes the Redux store available to the connect() calls in the component hierarchy below. */ - export class Provider extends Component { } + export class Provider extends __React.Component { } +} + +declare module "react-redux" { + export = ReactRedux; } From 301ae9717edd82d898da18211d0fbbd7fe59729c Mon Sep 17 00:00:00 2001 From: lucap86 Date: Sun, 24 Jul 2016 09:08:10 +0200 Subject: [PATCH 51/81] refs #9944 (#10043) --- howlerjs/howler.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/howlerjs/howler.d.ts b/howlerjs/howler.d.ts index c52b9c334f..9e245a8058 100644 --- a/howlerjs/howler.d.ts +++ b/howlerjs/howler.d.ts @@ -52,20 +52,20 @@ interface Howl { onpause: Function; onplay: Function; load(): Howl; - play(sprite?: string, callback?: (soundId: number) => void): Howl; - play(callback?: (soundId: number) => void): Howl; - pause(soundId?: number): Howl; - stop(soundId?: number): Howl; - mute(soundId?: number): Howl; - unmute(soundId?: number): Howl; - fade(from: number, to: number, duration: number, callback?: Function, soundId?: number): Howl; + play(sprite?: string, callback?: (soundId: string) => void): Howl; + play(callback?: (soundId: string) => void): Howl; + pause(soundId?: string): Howl; + stop(soundId?: string): Howl; + mute(soundId?: string): Howl; + unmute(soundId?: string): Howl; + fade(from: number, to: number, duration: number, callback?: Function, soundId?: string): Howl; loop(): boolean; loop(loop: boolean): Howl; - pos(position?: number, soundId?: number): number; - pos3d(x: number, y: number, z: number, soundId?: number): any; + pos(position?: number, soundId?: string): number; + pos3d(x: number, y: number, z: number, soundId?: string): any; sprite(definition?: IHowlSoundSpriteDefinition): IHowlSoundSpriteDefinition; volume(): number; - volume(volume?: number, soundId?: number): Howl; + volume(volume?: number, soundId?: string): Howl; urls(): string[]; urls(urls: string[]): Howl; on(event: string, listener?: Function): Howl; From 3f0988d6a0fa58d4decb57514e37bbb748998283 Mon Sep 17 00:00:00 2001 From: mbeauchamp7 Date: Sun, 24 Jul 2016 03:09:02 -0400 Subject: [PATCH 52/81] changed push command to fit react-router's push (#10041) --- react-router-redux/react-router-redux-2.x.d.ts | 2 +- react-router-redux/react-router-redux.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/react-router-redux/react-router-redux-2.x.d.ts b/react-router-redux/react-router-redux-2.x.d.ts index 5e38fe4bee..f02612a4ec 100644 --- a/react-router-redux/react-router-redux-2.x.d.ts +++ b/react-router-redux/react-router-redux-2.x.d.ts @@ -20,7 +20,7 @@ declare namespace ReactRouterRedux { const goForward: GoBackAction; const routeActions: RouteActions; - type LocationDescriptor = H.Location | H.Path; + type LocationDescriptor = H.LocationDescriptor; type PushAction = (nextLocation: LocationDescriptor) => void; type ReplaceAction = (nextLocation: LocationDescriptor) => void; type GoAction = (n: number) => void; diff --git a/react-router-redux/react-router-redux.d.ts b/react-router-redux/react-router-redux.d.ts index d91f1ad4e1..6a9d499b1f 100644 --- a/react-router-redux/react-router-redux.d.ts +++ b/react-router-redux/react-router-redux.d.ts @@ -20,7 +20,7 @@ declare namespace ReactRouterRedux { const goForward: GoBackAction; const routerActions: RouteActions; - type LocationDescriptor = H.Location | H.Path; + type LocationDescriptor = H.LocationDescriptor; type PushAction = (nextLocation: LocationDescriptor) => RouterAction; type ReplaceAction = (nextLocation: LocationDescriptor) => RouterAction; type GoAction = (n: number) => RouterAction; From 934e591c7a36e5b51e0723c1e1544b37eeb478d8 Mon Sep 17 00:00:00 2001 From: Jan Rapp Date: Sun, 24 Jul 2016 09:09:35 +0200 Subject: [PATCH 53/81] sqlite3: add overloads with params and callback (#10040) from: https://github.com/mapbox/node-sqlite3/wiki/API > Database#run(sql, [param, ...], [callback]) > ... There are three ways of passing bind parameters: directly in the function's arguments, as an array, and as an object for named parameters. ... We can support the last two parameter passing options even if a callback is given. --- sqlite3/sqlite3-tests.ts | 14 ++++++++++++-- sqlite3/sqlite3.d.ts | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sqlite3/sqlite3-tests.ts b/sqlite3/sqlite3-tests.ts index 7059a439af..1905b9efac 100644 --- a/sqlite3/sqlite3-tests.ts +++ b/sqlite3/sqlite3-tests.ts @@ -32,10 +32,17 @@ function readAllRows() { rows.forEach(function (row) { console.log(row.id + ": " + row.info); }); - closeDb(); + readSomeRows(); }); } +function readSomeRows() { + console.log("readAllRows lorem"); + db.each("SELECT rowid AS id, info FROM lorem WHERE rowid < ? ", 5, function(err, row) { + console.log(row.id + ": " + row.info); + }, closeDb); +} + function closeDb() { console.log("closeDb"); db.close(); @@ -64,7 +71,7 @@ db.serialize(function() { db.serialize(function() { // These two queries will run sequentially. db.run("CREATE TABLE foo (num)"); - db.run("INSERT INTO foo VALUES (?)", 1, function() { + db.run("INSERT INTO foo VALUES (?)", 1, function(err) { // These queries will run in parallel and the second query will probably // fail because the table might not exist yet. db.run("CREATE TABLE bar (num)"); @@ -83,6 +90,9 @@ db.run("UPDATE tbl SET name = $name WHERE id = $id", { $id: 2, $name: "bar" }); +db.run("UPDATE tbl SET name = $name WHERE id = $id", { $id: 2, $name: "bar" }, + function(err) { } +); db.run("UPDATE tbl SET name = ?5 WHERE id = ?", { 1: 2, diff --git a/sqlite3/sqlite3.d.ts b/sqlite3/sqlite3.d.ts index dbc205cc0e..d4f4225689 100644 --- a/sqlite3/sqlite3.d.ts +++ b/sqlite3/sqlite3.d.ts @@ -31,15 +31,19 @@ declare module "sqlite3" { public finalize(callback?: (err: Error) => void): Statement; public run(callback?: (err: Error) => void): Statement; + public run(params: any, callback?: (err: Error) => void): Statement; public run(...params: any[]): Statement; public get(callback?: (err: Error, row: any) => void): Statement; + public get(params: any, callback?: (err: Error, row: any) => void): Statement; public get(...params: any[]): Statement; public all(callback?: (err: Error, rows: any[]) => void): Statement; + public all(params: any, callback?: (err: Error, rows: any[]) => void): Statement; public all(...params: any[]): Statement; public each(callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Statement; + public each(params: any, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Statement; public each(...params: any[]): Statement; } @@ -50,20 +54,25 @@ declare module "sqlite3" { public close(callback?: (err: Error) => void): void; public run(sql: string, callback?: (err: Error) => void): Database; + public run(sql: string, params: any, callback?: (err: Error) => void): Database; public run(sql: string, ...params: any[]): Database; public get(sql: string, callback?: (err: Error, row: any) => void): Database; + public get(sql: string, params: any, callback?: (err: Error, row: any) => void): Database; public get(sql: string, ...params: any[]): Database; public all(sql: string, callback?: (err: Error, rows: any[]) => void): Database; + public all(sql: string, params: any, callback?: (err: Error, rows: any[]) => void): Database; public all(sql: string, ...params: any[]): Database; public each(sql: string, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Database; + public each(sql: string, params: any, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Database; public each(sql: string, ...params: any[]): Database; public exec(sql: string, callback?: (err: Error) => void): Database; public prepare(sql: string, callback?: (err: Error) => void): Statement; + public prepare(sql: string, params: any, callback?: (err: Error) => void): Statement; public prepare(sql: string, ...params: any[]): Statement; public serialize(callback?: () => void): void; From 1364c7f9e0388b616d43c7dba934b583f39b9bc0 Mon Sep 17 00:00:00 2001 From: hackerschoolau Date: Sun, 24 Jul 2016 17:11:55 +1000 Subject: [PATCH 54/81] Support Static Member (#10002) interface JQueryStatic { timer: JQueryTimer; } --- jquery.timer/jquery.timer.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jquery.timer/jquery.timer.d.ts b/jquery.timer/jquery.timer.d.ts index 6b8c5d6358..86cb3d4ec6 100644 --- a/jquery.timer/jquery.timer.d.ts +++ b/jquery.timer/jquery.timer.d.ts @@ -28,4 +28,9 @@ interface JQueryTimer { interface JQuery { timer: JQueryTimer; -} \ No newline at end of file +} + + +interface JQueryStatic { + timer: JQueryTimer; +} From d104e10960602f25b2a359fecd7a098cca897dc5 Mon Sep 17 00:00:00 2001 From: Pablo Ois Lagarde Date: Sun, 24 Jul 2016 04:31:44 -0300 Subject: [PATCH 55/81] nconf: allow nconf.get() without a key (#10059) --- nconf/nconf.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nconf/nconf.d.ts b/nconf/nconf.d.ts index e631fe86c5..005d129199 100644 --- a/nconf/nconf.d.ts +++ b/nconf/nconf.d.ts @@ -11,7 +11,7 @@ declare module "nconf" { export var sources: any[]; export function clear(key: string, callback?: ICallbackFunction): any; - export function get (key: string, callback?: ICallbackFunction): any; + export function get (key?: string, callback?: ICallbackFunction): any; export function merge(key: string, value: any, callback?: ICallbackFunction): any; export function set (key: string, value: any, callback?: ICallbackFunction): any; export function reset(callback?: ICallbackFunction): any; From 3df355a623d1fc588bbd1d49105422e25b1ab44c Mon Sep 17 00:00:00 2001 From: Logan Aube Date: Sun, 24 Jul 2016 03:32:24 -0400 Subject: [PATCH 56/81] Updated Consumer constructor signature (#10078) Changed the type of the constructor's `fetchRequests` argument from `Array` to `Array` --- kafka-node/kafka-node.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kafka-node/kafka-node.d.ts b/kafka-node/kafka-node.d.ts index 5af357021d..19d9bc3010 100644 --- a/kafka-node/kafka-node.d.ts +++ b/kafka-node/kafka-node.d.ts @@ -28,7 +28,7 @@ declare module 'kafka-node' { } export class Consumer { - constructor(client: Client, fetchRequests: Array, options: ConsumerOptions); + constructor(client: Client, fetchRequests: Array, options: ConsumerOptions); on(eventName: string, cb: (message: string) => any): void; on(eventName: string, cb: (error: any) => any): void; addTopics(topics: Array, cb: (error: any, added: boolean) => any): void; From 7d6547a8a0c3f35ce5de82ba58bfd143c0d20fab Mon Sep 17 00:00:00 2001 From: Pearson Henri Date: Sun, 24 Jul 2016 03:33:45 -0400 Subject: [PATCH 57/81] Update typings for WebdriverIO to 4.0.4 (#10186) * Add typings for API changes in 4.0.4 * Update wdio typings semver to 4.0.4 --- webdriverio/webdriverio.d.ts | 49 ++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/webdriverio/webdriverio.d.ts b/webdriverio/webdriverio.d.ts index b0aa6fb5be..8b1ffd5ac1 100644 --- a/webdriverio/webdriverio.d.ts +++ b/webdriverio/webdriverio.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webdriverio 3.3.0 +// Type definitions for webdriverio 4.0.4 // Project: http://www.webdriver.io/ // Definitions by: Nick Malaguti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -92,6 +92,14 @@ declare namespace WebdriverIO { callback: (err: any) => P ): Client

; + selectByAttribute(selector: string, attribute: string, value: string): Client; + selectByAttribute

( + selector: string, + attribute: string, + value: string, + callback: (err: any) => P + ): Client

; + selectByIndex(selectElem: string, index: number): Client; selectByIndex

( selectElem: string, @@ -204,6 +212,28 @@ declare namespace WebdriverIO { ): Client

; } + export interface Client { + session(action?: string, sessionId?: string): Client>; + session

( + callback: (err: any, result: RawResult) => P + ): Client

; + + getGridNodeDetails(): Client; + getGridNodeDetails

( + callback: (err: any, details: Object) => P + ): Client

; + + gridProxyDetails(): Client; + gridProxyDetails

( + callback: (err: any, result: Object) => P + ): Client

; + + gridTestSession(): Client; + gridProxyDetails

( + callback: (err: any, result: Object) => P + ): Client

; + } + // Mobile export interface Client { // flick @@ -946,22 +976,15 @@ declare namespace WebdriverIO { waitUntil( condition: () => boolean | Q.IPromise, timeout?: number, + timeoutMsg?: string, interval?: number ): Client; waitUntil

( condition: () => boolean | Q.IPromise, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitUntil

( - condition: () => boolean | Q.IPromise, - timeout: number, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitUntil

( - condition: () => boolean | Q.IPromise, - timeout: number, - interval: number, - callback: (err: any, enabled: boolean) => P + timeout?: number, + timeoutMsg?: string, + interval?: number, + callback?: (err: any, enabled: boolean) => P ): Client

; } From 675b216b6ad599a9dc649a8fb326f367a6dcf748 Mon Sep 17 00:00:00 2001 From: Amin Cheloh Date: Sun, 24 Jul 2016 17:13:33 +0700 Subject: [PATCH 58/81] Update Boom to 3.2.2 --- boom/boom.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/boom/boom.d.ts b/boom/boom.d.ts index 85c2e22b35..7495e3ae68 100644 --- a/boom/boom.d.ts +++ b/boom/boom.d.ts @@ -44,14 +44,17 @@ declare namespace Boom { export function rangeNotSatisfiable(message?: string, data?: any): BoomError; export function expectationFailed(message?: string, data?: any): BoomError; export function badData(message?: string, data?: any): BoomError; + export function locked(message?: string, data?: any): BoomError; + export function preconditionRequired(message?: string, data?: any): BoomError; export function tooManyRequests(message?: string, data?: any): BoomError; + export function illegal(message?: string, data?: any): BoomError; // 5xx + export function badImplementation(message?: string, data?: any): BoomError; export function notImplemented(message?: string, data?: any): BoomError; export function badGateway(message?: string, data?: any): BoomError; - export function serverTimeout(message?: string, data?: any): BoomError; + export function serverUnavailable(message?: string, data?: any): BoomError; export function gatewayTimeout(message?: string, data?: any): BoomError; - export function badImplementation(message?: string, data?: any): BoomError; } declare module "boom" { From 82e655b668ec2e69ac13baadd79c7b4464e91a56 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Sun, 24 Jul 2016 04:24:10 -0700 Subject: [PATCH 59/81] Fixing issue in webpack.d.ts --- webpack/webpack.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack/webpack.d.ts b/webpack/webpack.d.ts index e2ed2d1658..96a7c710df 100644 --- a/webpack/webpack.d.ts +++ b/webpack/webpack.d.ts @@ -102,7 +102,7 @@ declare module "webpack" { /** Include comments with information about the modules. */ pathinfo?: boolean; /** If set, export the bundle as library. output.library is the name. */ - library?: boolean; + library?: string; /** * Which format to export the library: *

    From a3359b33ec98d4054038af7589acca456ed96978 Mon Sep 17 00:00:00 2001 From: Birk Skyum Date: Sun, 24 Jul 2016 13:38:20 +0200 Subject: [PATCH 60/81] Fix export issues in parse.d.ts In node: Module '"parse/node"' resolves to a non-module entity and cannot be imported using this construct. In browser: Module '"parse"' resolves to a non-module entity and cannot be imported using this construct. Parse can now be imported like: import * as Parse from 'parse/node' --- parse/parse.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parse/parse.d.ts b/parse/parse.d.ts index 825eedf386..6cf51a98b4 100644 --- a/parse/parse.d.ts +++ b/parse/parse.d.ts @@ -1087,10 +1087,10 @@ declare namespace Parse { } declare module "parse/node" { - export = { Parse }; + export = Parse; } declare module "parse" { - import parse = require("parse/node"); + import * as parse from "parse/node"; export = parse } From f7163677f8c8436bac263beb455407351cf25686 Mon Sep 17 00:00:00 2001 From: Zhuohuan LI Date: Sun, 24 Jul 2016 20:19:34 +0800 Subject: [PATCH 61/81] add `protocol`, fix verifyClient callback defination --- ws/ws-tests.ts | 27 ++++++++++++++++++++++++++- ws/ws.d.ts | 12 +++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/ws/ws-tests.ts b/ws/ws-tests.ts index ec2bc431e0..0c1887527e 100644 --- a/ws/ws-tests.ts +++ b/ws/ws-tests.ts @@ -1,6 +1,9 @@ /// import WebSocket = require('ws'); +import http = require('http'); +// import * as http from 'http' + var WebSocketServer = WebSocket.Server; { @@ -29,7 +32,7 @@ var WebSocketServer = WebSocket.Server; { var wss = new WebSocketServer({port: 8080}); - function broadcast(data: any) { + const broadcast = function(data: any) { for(var i in wss.clients) wss.clients[i].send(data); }; @@ -51,3 +54,25 @@ var WebSocketServer = WebSocket.Server; }, 500); }); } + +{ + + const verifyClient = function( + info: { + origin: string + secure: boolean + req: http.ServerRequest + } + , callback: (res: boolean) => void + ): void { + callback(true) + } + + var wsv = new WebSocketServer({ + verifyClient + }) + + wsv.on('connection', function connection(ws) { + console.log(ws.protocol) + }) +} \ No newline at end of file diff --git a/ws/ws.d.ts b/ws/ws.d.ts index d9a1338d21..235b538030 100644 --- a/ws/ws.d.ts +++ b/ws/ws.d.ts @@ -22,6 +22,7 @@ declare module "ws" { url: string; supports: any; upgradeReq: http.ServerRequest; + protocol: string; CONNECTING: number; OPEN: number; @@ -91,11 +92,12 @@ declare module "ws" { host?: string; port?: number; server?: http.Server; - verifyClient?: { - (info: {origin: string; secure: boolean; req: http.ServerRequest}): boolean; - (info: {origin: string; secure: boolean; req: http.ServerRequest}, - callback: (res: boolean) => void): void; - }; + verifyClient?: ( + ((info: {origin: string; secure: boolean; req: http.ServerRequest}) => boolean) + | + ((info: {origin: string; secure: boolean; req: http.ServerRequest}, + callback: (res: boolean) => void) => void) + ); handleProtocols?: any; path?: string; noServer?: boolean; From c32177d0cdfd4e04102a845925bd012c7f33e3fd Mon Sep 17 00:00:00 2001 From: Zhuohuan LI Date: Sun, 24 Jul 2016 20:21:53 +0800 Subject: [PATCH 62/81] type alias for 2 callback, fix #10250 --- ws/ws.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ws/ws.d.ts b/ws/ws.d.ts index 235b538030..6b94bee19d 100644 --- a/ws/ws.d.ts +++ b/ws/ws.d.ts @@ -88,16 +88,16 @@ declare module "ws" { } namespace WebSocket { + + type VerifyClientCallbackSync = (info: {origin: string; secure: boolean; req: http.ServerRequest}) => boolean; + type VerifyClientCallbackAsync = (info: {origin: string; secure: boolean; req: http.ServerRequest} + , callback: (res: boolean) => void) => void; + export interface IServerOptions { host?: string; port?: number; server?: http.Server; - verifyClient?: ( - ((info: {origin: string; secure: boolean; req: http.ServerRequest}) => boolean) - | - ((info: {origin: string; secure: boolean; req: http.ServerRequest}, - callback: (res: boolean) => void) => void) - ); + verifyClient?: VerifyClientCallbackAsync | VerifyClientCallbackSync; handleProtocols?: any; path?: string; noServer?: boolean; From 6a6f78076bcc98d7c4150d1b294ae06a1f04d69c Mon Sep 17 00:00:00 2001 From: Zhuohuan LI Date: Sun, 24 Jul 2016 20:25:36 +0800 Subject: [PATCH 63/81] work with --target es6 --- ws/ws-tests.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ws/ws-tests.ts b/ws/ws-tests.ts index 0c1887527e..a8afa8cb99 100644 --- a/ws/ws-tests.ts +++ b/ws/ws-tests.ts @@ -1,8 +1,7 @@ /// -import WebSocket = require('ws'); -import http = require('http'); -// import * as http from 'http' +import * as WebSocket from 'ws'; +import * as http from'http'; var WebSocketServer = WebSocket.Server; @@ -56,7 +55,6 @@ var WebSocketServer = WebSocket.Server; } { - const verifyClient = function( info: { origin: string From 29e1a843c288692a5c4925721c0e9c95ea9aa188 Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Tue, 12 Jul 2016 01:09:21 +0900 Subject: [PATCH 64/81] let the following interfaces extend `ViewProperties`: - ActivityIndicatorIOSProperties - ActivityIndicatorProperties - DatePickerIOSProperties - DrawerLayoutAndroidProperties - PickerProperties - MapViewProperties - ProgressBarAndroidProperties - ProgressViewIOSProperties - RefreshControlProperties - ScrollViewProperties - ListViewProperties - SegmentedControlIOSProperties - SliderProperties - SliderIOSProperties - TabBarIOSProperties - TabBarItemProperties - SwitchProperties - SwitchPropertiesIOS - WebViewProperties --- react-native/react-native.d.ts | 91 +++++++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 23 deletions(-) diff --git a/react-native/react-native.d.ts b/react-native/react-native.d.ts index 0ffc6763a7..bfb977ffed 100644 --- a/react-native/react-native.d.ts +++ b/react-native/react-native.d.ts @@ -918,7 +918,7 @@ declare namespace __React { showWithText?: boolean } - export interface ToolbarAndroidProperties extends React.Props { + export interface ToolbarAndroidProperties extends ViewProperties, React.Props { actions?: ToolbarAndroidAction[] /** @@ -1000,6 +1000,8 @@ declare namespace __React { * Sets the toolbar title color. */ titleColor?: string + + ref?: Ref } export interface ToolbarAndroidStatic extends React.ComponentClass { @@ -1479,7 +1481,7 @@ declare namespace __React { /** * @see https://facebook.github.io/react-native/docs/webview.html#props */ - export interface WebViewProperties extends WebViewPropertiesAndroid, WebViewPropertiesIOS, React.Props { + export interface WebViewProperties extends ViewProperties, WebViewPropertiesAndroid, WebViewPropertiesIOS, React.Props { automaticallyAdjustContentInsets?: boolean @@ -1553,6 +1555,8 @@ declare namespace __React { * sets whether the webpage scales to fit the view and the user can change the scale */ scalesPageToFit?: boolean + + ref?: Ref } @@ -1590,7 +1594,7 @@ declare namespace __React { target: number } - export interface SegmentedControlIOSProperties extends React.Props { + export interface SegmentedControlIOSProperties extends ViewProperties, React.Props { /** * If false the user won't be able to interact with the control. Default value is true. @@ -1630,6 +1634,8 @@ declare namespace __React { * The labels for the control's segment buttons, in order. */ values?: string[] + + ref?: Ref } export interface SegmentedControlIOSStatic extends React.ComponentClass { @@ -1744,7 +1750,7 @@ declare namespace __React { /** * @see https://facebook.github.io/react-native/docs/activityindicator.html#props */ - export interface ActivityIndicatorProperties extends React.Props { + export interface ActivityIndicatorProperties extends ViewProperties, React.Props { /** * Whether to show the indicator (true, the default) or hide it (false). @@ -1770,6 +1776,8 @@ declare namespace __React { size?: 'small' | 'large' style?: ViewStyle + + ref?: Ref } export interface ActivityIndicatorStatic extends React.ComponentClass { @@ -1779,7 +1787,7 @@ declare namespace __React { /** * @see https://facebook.github.io/react-native/docs/activityindicatorios.html#props */ - export interface ActivityIndicatorIOSProperties extends React.Props { + export interface ActivityIndicatorIOSProperties extends ViewProperties, React.Props { /** * Whether to show the indicator (true, the default) or hide it (false). @@ -1810,6 +1818,8 @@ declare namespace __React { size?: 'small' | 'large' style?: ViewStyle + + ref?: Ref } /** @@ -1819,7 +1829,7 @@ declare namespace __React { } - export interface DatePickerIOSProperties extends React.Props { + export interface DatePickerIOSProperties extends ViewProperties, React.Props { /** * The currently selected date. @@ -1865,6 +1875,7 @@ declare namespace __React { */ timeZoneOffsetInMinutes?: number + ref?: Ref } export interface DatePickerIOSStatic extends React.ComponentClass { @@ -1876,7 +1887,7 @@ declare namespace __React { /** * @see DrawerLayoutAndroid.android.js */ - export interface DrawerLayoutAndroidProperties extends React.Props { + export interface DrawerLayoutAndroidProperties extends ViewProperties, React.Props { /** * Specifies the background color of the drawer. The default value @@ -1967,6 +1978,7 @@ declare namespace __React { */ statusBarBackgroundColor?: any + ref?: Ref } export interface DrawerLayoutAndroidStatic extends React.ComponentClass { @@ -2010,18 +2022,22 @@ declare namespace __React { export interface PickerItemStatic extends React.ComponentClass { } - export interface PickerPropertiesIOS extends React.Props { + export interface PickerPropertiesIOS extends ViewProperties, React.Props { itemStyle?: ViewStyle + + ref?: Ref } - export interface PickerPropertiesAndroid extends React.Props { + export interface PickerPropertiesAndroid extends ViewProperties, React.Props { enabled?: boolean mode?: "dialog" | "dropdown" prompt?: string + + ref?: Ref } /** @@ -2052,6 +2068,8 @@ declare namespace __React { * Used to locate this view in end-to-end tests. */ testId?: string + + ref?: Ref } /** @@ -2086,7 +2104,7 @@ declare namespace __React { * @see https://facebook.github.io/react-native/docs/progressbarandroid.html * @see ProgressBarAndroid.android.js */ - export interface ProgressBarAndroidProperties extends React.Props { + export interface ProgressBarAndroidProperties extends ViewProperties, React.Props { style?: ViewStyle @@ -2122,6 +2140,8 @@ declare namespace __React { * Used to locate this view in end-to-end tests. */ testID?: string + + ref?: Ref } export interface ProgressBarAndroidStatic extends React.ComponentClass { } @@ -2130,7 +2150,7 @@ declare namespace __React { * @see https://facebook.github.io/react-native/docs/progressviewios.html * @see ProgressViewIOS.ios.js */ - export interface ProgressViewIOSProperties extends React.Props { + export interface ProgressViewIOSProperties extends ViewProperties, React.Props { style?: ViewStyle @@ -2163,11 +2183,13 @@ declare namespace __React { * A stretchable image to display behind the progress bar. */ trackImage?: any + + ref?: Ref } export interface ProgressViewIOSStatic extends React.ComponentClass { } - export interface RefreshControlPropertiesIOS extends React.Props { + export interface RefreshControlPropertiesIOS extends ViewProperties, React.Props { /** * The color of the refresh indicator. @@ -2183,9 +2205,11 @@ declare namespace __React { * Title color. */ titleColor?: string + + ref?: Ref } - export interface RefreshControlPropertiesAndroid extends React.Props { + export interface RefreshControlPropertiesAndroid extends ViewProperties, React.Props { /** * The colors (at least one) that will be used to draw the refresh indicator. @@ -2212,6 +2236,8 @@ declare namespace __React { * @platform android */ progressViewOffset?: number + + ref?: Ref } export interface RefreshControlProperties extends RefreshControlPropertiesIOS, RefreshControlPropertiesAndroid, React.Props { @@ -2225,13 +2251,15 @@ declare namespace __React { * Whether the view should be indicating an active refresh. */ refreshing?: boolean + + ref?: Ref } export interface RefreshControlStatic extends React.ComponentClass { SIZE: Object // Undocumented } - export interface SliderPropertiesIOS extends React.Props { + export interface SliderPropertiesIOS extends ViewProperties, React.Props { /** * Assigns a maximum track image. Only static images are supported. @@ -2268,6 +2296,8 @@ declare namespace __React { * to fill the track. */ trackImage?: any + + ref?: Ref } export interface SliderProperties extends SliderPropertiesIOS, React.Props { @@ -2333,7 +2363,7 @@ declare namespace __React { /** * @see https://facebook.github.io/react-native/docs/sliderios.html */ - export interface SliderIOSProperties extends React.Props { + export interface SliderIOSProperties extends ViewProperties, React.Props { /** * If true the user won't be able to move the slider. Default value is false. @@ -2393,6 +2423,8 @@ declare namespace __React { * This is not a controlled component, e.g. if you don't update the value, the component won't be reset to its inital value. */ value?: number + + ref?: Ref } export interface SliderIOSStatic extends React.ComponentClass { @@ -2721,6 +2753,8 @@ declare namespace __React { * pixels. */ scrollRenderAheadDistance?: number + + ref?: Ref } export interface ListViewStatic extends React.ComponentClass { @@ -2815,7 +2849,7 @@ declare namespace __React { active?: boolean } - export interface MapViewProperties extends MapViewPropertiesIOS, MapViewPropertiesAndroid, Touchable, React.Props { + export interface MapViewProperties extends MapViewPropertiesIOS, MapViewPropertiesAndroid, Touchable, ViewProperties, React.Props { @@ -2884,6 +2918,8 @@ declare namespace __React { * Default value is true. */ zoomEnabled?: boolean + + ref?: Ref } /** @@ -3502,7 +3538,7 @@ declare namespace __React { /** * @see https://facebook.github.io/react-native/docs/tabbarios-item.html#props */ - export interface TabBarItemProperties extends React.Props { + export interface TabBarItemProperties extends ViewProperties, React.Props { /** * Little red bubble that sits at the top right of the icon. @@ -3549,6 +3585,7 @@ declare namespace __React { */ title?: string + ref?: Ref } export interface TabBarItemStatic extends React.ComponentClass { @@ -3557,7 +3594,7 @@ declare namespace __React { /** * @see https://facebook.github.io/react-native/docs/tabbarios.html#props */ - export interface TabBarIOSProperties extends React.Props { + export interface TabBarIOSProperties extends ViewProperties, React.Props { /** * Background color of the tab bar @@ -3580,6 +3617,8 @@ declare namespace __React { * Color of text on unselected tabs */ unselectedTintColor?: string + + ref?: Ref } export interface TabBarIOSStatic extends React.ComponentClass { @@ -3959,7 +3998,7 @@ declare namespace __React { } - export interface ScrollViewProperties extends ScrollViewPropertiesIOS, ScrollViewPropertiesAndroid, Touchable { + export interface ScrollViewProperties extends ViewProperties, ScrollViewPropertiesIOS, ScrollViewPropertiesAndroid, Touchable, React.Props { /** * These styles will be applied to the scroll view content container which @@ -4043,10 +4082,12 @@ declare namespace __React { * functionality for the ScrollView. */ refreshControl?: RefreshControl + + ref?: Ref } export interface ScrollViewProps extends ScrollViewProperties, React.Props { - + ref?: Ref } interface ScrollViewStatic extends React.ComponentClass { @@ -5084,7 +5125,7 @@ declare namespace __React { LONG: number } - export interface SwitchPropertiesIOS extends React.Props { + export interface SwitchPropertiesIOS extends ViewProperties, React.Props { /** * Background color when the switch is turned on. @@ -5100,9 +5141,11 @@ declare namespace __React { * Background color when the switch is turned off. */ tintColor?: string + + ref?: Ref } - export interface SwitchProperties extends React.Props { + export interface SwitchProperties extends ViewProperties, React.Props { /** * If true the user won't be able to toggle the switch. @@ -5126,7 +5169,9 @@ declare namespace __React { */ value?: boolean - style?: ViewStyle + style?: ViewStyle + + ref?: Ref } export interface SwitchStatic extends React.ComponentClass { From 037c33d5e03e4cea623915a260adccfdc557426b Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Mon, 25 Jul 2016 03:38:40 +0900 Subject: [PATCH 65/81] remove Promise from react-native --- react-native/react-native.d.ts | 96 ---------------------------------- 1 file changed, 96 deletions(-) diff --git a/react-native/react-native.d.ts b/react-native/react-native.d.ts index 0ffc6763a7..e4f942b474 100644 --- a/react-native/react-native.d.ts +++ b/react-native/react-native.d.ts @@ -24,102 +24,6 @@ import React = __React; //react-native "extends" react declare namespace __React { - /** - * Represents the completion of an asynchronous operation - * @see lib.es6.d.ts - */ - export interface Promise { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then( onfulfilled?: ( value: T ) => TResult | Promise, onrejected?: ( reason: any ) => TResult | Promise ): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch( onrejected?: ( reason: any ) => T | Promise ): Promise; - - - // not in lib.es6.d.ts but called by react-native - done( callback?: ( value: T ) => void ): void; - } - - export interface PromiseConstructor { - /** - * A reference to the prototype. - */ - prototype: Promise; - - /** - * Creates a new Promise. - * @param init A callback used to initialize the promise. This callback is passed two arguments: - * a resolve callback used resolve the promise with a value or the result of another promise, - * and a reject callback used to reject the promise with a provided reason or error. - */ - new ( init: ( resolve: ( value?: T | Promise ) => void, reject: ( reason?: any ) => void ) => void ): Promise; - - ( init: ( resolve: ( value?: T | Promise ) => void, reject: ( reason?: any ) => void ) => void ): Promise; - - /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises - * resolve, or rejected when any Promise is rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - all( values: (T | Promise)[] ): Promise; - - /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises - * resolve, or rejected when any Promise is rejected. - * @param values An array of values. - * @returns A new Promise. - */ - all( values: Promise[] ): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race( values: (T | Promise)[] ): Promise; - - /** - * Creates a new rejected promise for the provided reason. - * @param reason The reason the promise was rejected. - * @returns A new rejected Promise. - */ - reject( reason: any ): Promise; - - /** - * Creates a new rejected promise for the provided reason. - * @param reason The reason the promise was rejected. - * @returns A new rejected Promise. - */ - reject( reason: any ): Promise; - - /** - * Creates a new resolved promise for the provided value. - * @param value A promise. - * @returns A promise whose internal state matches the provided promise. - */ - resolve( value: T | Promise ): Promise; - - /** - * Creates a new resolved promise . - * @returns A resolved promise. - */ - resolve(): Promise; - } - - // @see lib.es6.d.ts - export var Promise: PromiseConstructor; - module NativeMethodsMixin { type MeasureOnSuccessCallback = ( x: number, From 4691d1a545cec7524fc7bc44a0dcc133238ecfdb Mon Sep 17 00:00:00 2001 From: ymkjp Date: Mon, 25 Jul 2016 16:27:13 +0900 Subject: [PATCH 66/81] Bump up version on JqueryUI comment --- jqueryui/jqueryui.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index d508eba8a9..7391de7824 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jQueryUI 1.9 +// Type definitions for jQueryUI 1.11 // Project: http://jqueryui.com/ // Definitions by: Boris Yankov , John Reilly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -625,9 +625,9 @@ declare namespace JQueryUI { interface Selectable extends Widget, SelectableOptions { } - + // SelectMenu ////////////////////////////////////////////////// - + interface SelectMenuOptions extends SelectMenuEvents { appendTo?: string; disabled?: boolean; @@ -1705,7 +1705,7 @@ interface JQuery { selectable(optionLiteral: string, optionName: string): any; selectable(optionLiteral: string, options: JQueryUI.SelectableOptions): any; selectable(optionLiteral: string, optionName: string, optionValue: any): JQuery; - + selectmenu(): JQuery; selectmenu(methodName: 'close'): JQuery; selectmenu(methodName: 'destroy'): JQuery; From 060060dc34ef700a6ea9e00ccee69b570ff3c242 Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Mon, 25 Jul 2016 09:33:51 +0200 Subject: [PATCH 67/81] Return intersection type when indexing IDocumentService (#10267) Typescript 2.0 starts checking the compatibility of the index signature with the base JQuery interface; Hence we are forced to return Document & HTMLElement to be compatible with the base. --- angularjs/angular.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 5aa6807605..bb028f3425 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -986,7 +986,8 @@ declare namespace angular { // see http://docs.angularjs.org/api/ng.$document /////////////////////////////////////////////////////////////////////////// interface IDocumentService extends JQuery { - [index: number]: Document; + // Must return intersection type for index signature compatibility with JQuery + [index: number]: HTMLElement & Document; } /////////////////////////////////////////////////////////////////////////// From bef1a95d0c6e1550a5992ad970c42c16922d5e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Pluci=C5=84ski?= Date: Mon, 25 Jul 2016 11:00:48 +0200 Subject: [PATCH 68/81] fix for #10271 jstree fix for #10271 jstree - get_path params not marked to be optional --- jstree/jstree-tests.ts | 5 +++++ jstree/jstree.d.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/jstree/jstree-tests.ts b/jstree/jstree-tests.ts index 1c8ef86c48..a6ea0eb290 100644 --- a/jstree/jstree-tests.ts +++ b/jstree/jstree-tests.ts @@ -109,3 +109,8 @@ var tree = $('a').jstree(); tree.move_node('a', 'b', 0, (node: any, new_par: any, pos: any) => { }, true, true); tree.copy_node('a', 'b', 0, (node: any, new_par: any, pos: any) => { }, true, true); +// #10271 jstree - get_path params not marked to be optional +tree.get_path('nodeId'); +tree.get_path('nodeId', '/'); +tree.get_path('nodeId', '/', true); + diff --git a/jstree/jstree.d.ts b/jstree/jstree.d.ts index f3961f7e3e..dde9a24b67 100644 --- a/jstree/jstree.d.ts +++ b/jstree/jstree.d.ts @@ -830,7 +830,7 @@ interface JSTree extends JQuery { * @param {Boolean} ids if set to true build the path using ID, otherwise node text is used * @return {mixed} */ - get_path: (obj: any, glue: string, ids: boolean) => any; + get_path: (obj: any, glue?: string, ids?: boolean) => any; /** * get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned. From b2213ab67d2cc6a324cd8bd87b196eee41f8bde5 Mon Sep 17 00:00:00 2001 From: Zipeng WU Date: Mon, 25 Jul 2016 11:20:53 +0200 Subject: [PATCH 69/81] Fix problem - Cannot find module 'nvd3' when install as globel dependency --- nvd3/nvd3.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nvd3/nvd3.d.ts b/nvd3/nvd3.d.ts index f0297abcb0..9e9c1fdc24 100644 --- a/nvd3/nvd3.d.ts +++ b/nvd3/nvd3.d.ts @@ -3349,3 +3349,7 @@ id(value: number|string): this; } } declare var nv : nv.Nvd3Static; + +declare module "nvd3" { + export = nv; +} From 3a1cb0f56587f76cfcd44b9361445d4a10d6be1d Mon Sep 17 00:00:00 2001 From: Michael McKenzie Date: Mon, 25 Jul 2016 14:20:13 +0100 Subject: [PATCH 70/81] Changing dojo/_base/lang mixin signature to match documentation --- dojo/dojo.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dojo/dojo.d.ts b/dojo/dojo.d.ts index 8a566a46f5..bca5721240 100644 --- a/dojo/dojo.d.ts +++ b/dojo/dojo.d.ts @@ -5686,7 +5686,7 @@ declare namespace dojo { * @param dest The object to which to copy/add all properties contained in source. If dest is falsy, thena new object is manufactured before copying/adding properties begins. * @param sources One of more objects from which to draw all properties to copy into dest. sources are processedleft-to-right and if more than one of these objects contain the same property name, the right-mostvalue "wins". */ - mixin(dest: Object, sources: Object[]): Object; + mixin(dest: Object, source: Object, sources?: Object[]): Object; /** * similar to hitch() except that the scope object is left to be * whatever the execution context eventually becomes. From 93e561501b57ce55569238e896a751d5fc37b1e4 Mon Sep 17 00:00:00 2001 From: Matt Jeanes Date: Mon, 25 Jul 2016 15:58:42 +0100 Subject: [PATCH 71/81] Add verify function to nodemailer.Transporter --- nodemailer/nodemailer.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nodemailer/nodemailer.d.ts b/nodemailer/nodemailer.d.ts index 1fb6b0396a..f921d226c3 100644 --- a/nodemailer/nodemailer.d.ts +++ b/nodemailer/nodemailer.d.ts @@ -46,7 +46,11 @@ declare module "nodemailer" { * @param pluginFunc is a function that takes two arguments: the mail object and a callback function */ use(step: string, plugin: Plugin): void; - + + /** + * Verifies connection with server + */ + verify(): Promise; /** * Close all connections From f25ec59073fc84bbaca1db6465da026b0da49533 Mon Sep 17 00:00:00 2001 From: Matt Jeanes Date: Mon, 25 Jul 2016 16:05:35 +0100 Subject: [PATCH 72/81] Add callback version of transporter.verify --- nodemailer/nodemailer.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nodemailer/nodemailer.d.ts b/nodemailer/nodemailer.d.ts index f921d226c3..48ddd2767d 100644 --- a/nodemailer/nodemailer.d.ts +++ b/nodemailer/nodemailer.d.ts @@ -50,6 +50,11 @@ declare module "nodemailer" { /** * Verifies connection with server */ + verify(callback: (error: Error, success?: boolean) => void): void; + + /** + * Verifies connection with server + */ verify(): Promise; /** From 984cc66fbff3313eb2f715e41b1281527a6a76ab Mon Sep 17 00:00:00 2001 From: Adam Greene Date: Mon, 25 Jul 2016 13:56:31 -0300 Subject: [PATCH 73/81] Fixed an issue with groupBy's compareSelector, it should be based on TKey not T. --- linq/linq.3.0.4-Beta5.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linq/linq.3.0.4-Beta5.d.ts b/linq/linq.3.0.4-Beta5.d.ts index a6c32690ce..b6ae876eee 100644 --- a/linq/linq.3.0.4-Beta5.d.ts +++ b/linq/linq.3.0.4-Beta5.d.ts @@ -157,7 +157,7 @@ declare module linqjs { groupBy(keySelector: (element: T) => TKey): IEnumerable>; groupBy(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement): IEnumerable>; groupBy(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, resultSelector: (key: TKey, element: IEnumerable) => TResult): IEnumerable; - groupBy(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, resultSelector: (key: TKey, element: IEnumerable) => TResult, compareSelector: (element: T) => TCompare): IEnumerable; + groupBy(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, resultSelector: (key: TKey, element: IEnumerable) => TResult, compareSelector: (element: TKey) => TCompare): IEnumerable; // :IEnumerable> partitionBy(keySelector: (element: T) => TKey): IEnumerable>; // :IEnumerable> From 78c2da12ebbb12e1c18fd6d7d07bf90e858b64e4 Mon Sep 17 00:00:00 2001 From: Phips Peter Date: Fri, 20 Nov 2015 18:15:30 -0800 Subject: [PATCH 74/81] Update React DnD types --- react-dnd/react-dnd-tests.ts | 4 ++-- react-dnd/react-dnd.d.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/react-dnd/react-dnd-tests.ts b/react-dnd/react-dnd-tests.ts index 59c0566664..d4e7053809 100644 --- a/react-dnd/react-dnd-tests.ts +++ b/react-dnd/react-dnd-tests.ts @@ -13,8 +13,8 @@ import DragSource = ReactDnd.DragSource; import DropTarget = ReactDnd.DropTarget; import DragLayer = ReactDnd.DragLayer; import DragDropContext = ReactDnd.DragDropContext; -import HTML5Backend, { getEmptyImage } from 'react-dnd/modules/backends/HTML5'; -import TestBackend = require('react-dnd/modules/backends/Test'); +import HTML5Backend, { getEmptyImage } from "react-dnd-html5-backend"; +import TestBackend from "react-dnd-test-backend"; // Game Component // ---------------------------------------------------------------------- diff --git a/react-dnd/react-dnd.d.ts b/react-dnd/react-dnd.d.ts index cfe5506afb..634bd77f65 100644 --- a/react-dnd/react-dnd.d.ts +++ b/react-dnd/react-dnd.d.ts @@ -179,13 +179,13 @@ declare module "react-dnd" { export = __ReactDnd; } -declare module "react-dnd/modules/backends/HTML5" { +declare module "react-dnd-html5-backend" { export enum NativeTypes { FILE, URL, TEXT } export function getEmptyImage(): any; // Image export default class HTML5Backend implements __ReactDnd.Backend {} } -declare module "react-dnd/modules/backends/Test" { +declare module "react-dnd-test-backend" { class TestBackend { setup(): void; teardown(): void; @@ -198,5 +198,5 @@ declare module "react-dnd/modules/backends/Test" { simulateEndDrag(): void; } - export = TestBackend; + export { TestBackend as default }; } From ad6ffc4b5c0d015dc4dd1336b2313728cfb846aa Mon Sep 17 00:00:00 2001 From: Phips Peter Date: Fri, 20 Nov 2015 18:53:07 -0800 Subject: [PATCH 75/81] Separate React DnD This makes it an easier user experience. --- react-dnd/react-dnd-html5-backend.d.ts | 12 ++++++++++++ react-dnd/react-dnd-test-backend.d.ts | 22 ++++++++++++++++++++++ react-dnd/react-dnd-tests.ts | 2 ++ react-dnd/react-dnd.d.ts | 24 +----------------------- 4 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 react-dnd/react-dnd-html5-backend.d.ts create mode 100644 react-dnd/react-dnd-test-backend.d.ts diff --git a/react-dnd/react-dnd-html5-backend.d.ts b/react-dnd/react-dnd-html5-backend.d.ts new file mode 100644 index 0000000000..9fbc580439 --- /dev/null +++ b/react-dnd/react-dnd-html5-backend.d.ts @@ -0,0 +1,12 @@ +// Type definitions for React DnD HTML 5 Backend v2.0.0 +// Project: https://github.com/gaearon/react-dnd +// Definitions by: Asana +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "react-dnd-html5-backend" { + export enum NativeTypes { FILE, URL, TEXT } + export function getEmptyImage(): any; // Image + export default class HTML5Backend implements __ReactDnd.Backend { } +} diff --git a/react-dnd/react-dnd-test-backend.d.ts b/react-dnd/react-dnd-test-backend.d.ts new file mode 100644 index 0000000000..4847976c15 --- /dev/null +++ b/react-dnd/react-dnd-test-backend.d.ts @@ -0,0 +1,22 @@ +// Type definitions for React DnD HTML 5 Backend v2.0.0 +// Project: https://github.com/gaearon/react-dnd +// Definitions by: Asana +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "react-dnd-test-backend" { + class TestBackend { + setup(): void; + teardown(): void; + connectDragSource(): void; + connectDropTarget(): void; + simulateBeginDrag(sourceIds: __ReactDnd.Identifier[], options?: {}): void; + simulatePublishDragSource(): void; + simulateHover(targetIds: __ReactDnd.Identifier[], options?: {}): void; + simulateDrop(): void; + simulateEndDrag(): void; + } + + export { TestBackend as default }; +} diff --git a/react-dnd/react-dnd-tests.ts b/react-dnd/react-dnd-tests.ts index d4e7053809..5270a8ba7a 100644 --- a/react-dnd/react-dnd-tests.ts +++ b/react-dnd/react-dnd-tests.ts @@ -1,4 +1,6 @@ /// +/// +/// "use strict"; // Test adapted from the ReactDnD chess game tutorial: diff --git a/react-dnd/react-dnd.d.ts b/react-dnd/react-dnd.d.ts index 634bd77f65..6da351d4ff 100644 --- a/react-dnd/react-dnd.d.ts +++ b/react-dnd/react-dnd.d.ts @@ -1,4 +1,4 @@ -// Type definitions for React DnD v1.1.4 +// Type definitions for React DnD v2.0.2 // Project: https://github.com/gaearon/react-dnd // Definitions by: Asana // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -178,25 +178,3 @@ declare module __ReactDnd { declare module "react-dnd" { export = __ReactDnd; } - -declare module "react-dnd-html5-backend" { - export enum NativeTypes { FILE, URL, TEXT } - export function getEmptyImage(): any; // Image - export default class HTML5Backend implements __ReactDnd.Backend {} -} - -declare module "react-dnd-test-backend" { - class TestBackend { - setup(): void; - teardown(): void; - connectDragSource(): void; - connectDropTarget(): void; - simulateBeginDrag(sourceIds: __ReactDnd.Identifier[], options?: {}): void; - simulatePublishDragSource(): void; - simulateHover(targetIds: __ReactDnd.Identifier[], options?: {}): void; - simulateDrop(): void; - simulateEndDrag(): void; - } - - export { TestBackend as default }; -} From b18345f63ef86ea81fc6efca418b110cdcaf2964 Mon Sep 17 00:00:00 2001 From: David Inglis Date: Mon, 25 Jul 2016 11:58:49 -0700 Subject: [PATCH 76/81] [ReactDnd] changes NativeTypes to use string typing --- react-dnd/react-dnd-html5-backend.d.ts | 10 +++++++--- react-dnd/react-dnd-tests.ts | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/react-dnd/react-dnd-html5-backend.d.ts b/react-dnd/react-dnd-html5-backend.d.ts index 9fbc580439..3844778b72 100644 --- a/react-dnd/react-dnd-html5-backend.d.ts +++ b/react-dnd/react-dnd-html5-backend.d.ts @@ -6,7 +6,11 @@ /// declare module "react-dnd-html5-backend" { - export enum NativeTypes { FILE, URL, TEXT } - export function getEmptyImage(): any; // Image - export default class HTML5Backend implements __ReactDnd.Backend { } + export namespace NativeTypes { + export const FILE: string; + export const URL: string; + export const TEXT: string; + } + export function getEmptyImage(): any; // Image + export default class HTML5Backend implements __ReactDnd.Backend { } } diff --git a/react-dnd/react-dnd-tests.ts b/react-dnd/react-dnd-tests.ts index 5270a8ba7a..b8723a4e7f 100644 --- a/react-dnd/react-dnd-tests.ts +++ b/react-dnd/react-dnd-tests.ts @@ -15,7 +15,7 @@ import DragSource = ReactDnd.DragSource; import DropTarget = ReactDnd.DropTarget; import DragLayer = ReactDnd.DragLayer; import DragDropContext = ReactDnd.DragDropContext; -import HTML5Backend, { getEmptyImage } from "react-dnd-html5-backend"; +import HTML5Backend, { getEmptyImage, NativeTypes } from "react-dnd-html5-backend"; import TestBackend from "react-dnd-test-backend"; // Game Component @@ -201,6 +201,7 @@ namespace BoardSquare { } export var DndBoardSquare = DropTarget(ItemTypes.KNIGHT, boardSquareTarget, boardSquareCollect)(BoardSquare); + export var fileDropTarget = DropTarget(NativeTypes.FILE, boardSquareTarget, boardSquareCollect)(BoardSquare); export var create = React.createFactory(DndBoardSquare); } From f92b6d38dffeead88c20a3c58dd402483d5b0a84 Mon Sep 17 00:00:00 2001 From: Mickael Burguet Date: Mon, 25 Jul 2016 16:31:23 -0400 Subject: [PATCH 77/81] [restify] add patch function definition --- restify/restify-tests.ts | 1 + restify/restify.d.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/restify/restify-tests.ts b/restify/restify-tests.ts index 767530d7aa..f9b0acfae1 100644 --- a/restify/restify-tests.ts +++ b/restify/restify-tests.ts @@ -312,6 +312,7 @@ client = restify.createStringClient({ client.head('test', function(err: any, req: restify.Request, res: restify.Response) { }); client.put('path', {}, function(err: any, req: restify.Request, res: restify.Response, obj: any) { }); +client.patch('path', {}, function(err: any, req: restify.Request, res: restify.Response, obj: any) { }); client.del('path', function(err: any, req: restify.Request, res: restify.Response) { }); client.post('/foo', { hello: 'world' }, function(err: any, req: restify.Request, res: restify.Response, obj: any) { diff --git a/restify/restify.d.ts b/restify/restify.d.ts index 2da1c6e0bd..fdb64f5e34 100644 --- a/restify/restify.d.ts +++ b/restify/restify.d.ts @@ -473,6 +473,7 @@ declare module "restify" { head: (path: string, callback?: (err: any, req: Request, res: Response) => any) => any; post: (path: string, object: any, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; put: (path: string, object: any, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; + patch: (path: string, object: any, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; del: (path: string, callback?: (err: any, req: Request, res: Response) => any) => any; basicAuth: (username: string, password: string) => any; } @@ -482,6 +483,7 @@ declare module "restify" { head: (path?:any, callback?: Function) => any; post: (opts?: any, callback?: Function) => any; put: (opts?: any, callback?: Function) => any; + patch: (opts?: any, callback?: Function) => any; del: (opts?: any, callback?: Function) => any; } From 77102fa5554c1fd71de450d3e549fa8d49534067 Mon Sep 17 00:00:00 2001 From: Matt Jeanes Date: Tue, 26 Jul 2016 00:38:34 +0100 Subject: [PATCH 78/81] Fix indentation --- nodemailer/nodemailer.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nodemailer/nodemailer.d.ts b/nodemailer/nodemailer.d.ts index 48ddd2767d..647566437f 100644 --- a/nodemailer/nodemailer.d.ts +++ b/nodemailer/nodemailer.d.ts @@ -48,14 +48,14 @@ declare module "nodemailer" { use(step: string, plugin: Plugin): void; /** - * Verifies connection with server - */ - verify(callback: (error: Error, success?: boolean) => void): void; - - /** - * Verifies connection with server - */ - verify(): Promise; + * Verifies connection with server + */ + verify(callback: (error: Error, success?: boolean) => void): void; + + /** + * Verifies connection with server + */ + verify(): Promise; /** * Close all connections From 51f709d4dfd10968b86f2bcd950639b4378b111d Mon Sep 17 00:00:00 2001 From: David Inglis Date: Mon, 25 Jul 2016 16:42:36 -0700 Subject: [PATCH 79/81] Fixes bad indentation issue Removes refernces to the test backend from the html5 backend tests - the two backends are distinct so it doesn't make sense to test one inside the other --- .../react-dnd-html5-backend-tests.ts | 8 ------- react-dnd/react-dnd-test-backend.d.ts | 24 +++++++++---------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts b/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts index c67f4b9ef5..6a94717e92 100644 --- a/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts +++ b/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts @@ -14,8 +14,6 @@ import DropTarget = ReactDnd.DropTarget; import DragLayer = ReactDnd.DragLayer; import DragDropContext = ReactDnd.DragDropContext; import HTML5Backend, { getEmptyImage } from 'react-dnd-html5-backend'; -import TestBackend = require('react-dnd/modules/backends/Test'); - // Game Component // ---------------------------------------------------------------------- @@ -285,7 +283,6 @@ namespace Board { } export var createWithHTMLBackend = React.createFactory(DragDropContext(HTML5Backend)(Board)); - export var createWithTestBackend = React.createFactory(DragDropContext(TestBackend)(Board)); } // Render the Board Component @@ -294,8 +291,3 @@ namespace Board { Board.createWithHTMLBackend({ knightPosition: [0, 0] }); - - -Board.createWithTestBackend({ - knightPosition: [0, 0] -}); diff --git a/react-dnd/react-dnd-test-backend.d.ts b/react-dnd/react-dnd-test-backend.d.ts index 4847976c15..a4e6ad0cc8 100644 --- a/react-dnd/react-dnd-test-backend.d.ts +++ b/react-dnd/react-dnd-test-backend.d.ts @@ -6,17 +6,17 @@ /// declare module "react-dnd-test-backend" { - class TestBackend { - setup(): void; - teardown(): void; - connectDragSource(): void; - connectDropTarget(): void; - simulateBeginDrag(sourceIds: __ReactDnd.Identifier[], options?: {}): void; - simulatePublishDragSource(): void; - simulateHover(targetIds: __ReactDnd.Identifier[], options?: {}): void; - simulateDrop(): void; - simulateEndDrag(): void; - } + class TestBackend { + setup(): void; + teardown(): void; + connectDragSource(): void; + connectDropTarget(): void; + simulateBeginDrag(sourceIds: __ReactDnd.Identifier[], options?: {}): void; + simulatePublishDragSource(): void; + simulateHover(targetIds: __ReactDnd.Identifier[], options?: {}): void; + simulateDrop(): void; + simulateEndDrag(): void; + } - export { TestBackend as default }; + export { TestBackend as default }; } From 34e87e1bca59853493ea2bc87014d31a3e501f85 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Tue, 26 Jul 2016 15:36:16 -0400 Subject: [PATCH 80/81] react-bootstrap-table: add cols and rows options to Editable --- react-bootstrap-table/react-bootstrap-table-tests.tsx | 2 +- react-bootstrap-table/react-bootstrap-table.d.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/react-bootstrap-table/react-bootstrap-table-tests.tsx b/react-bootstrap-table/react-bootstrap-table-tests.tsx index 9a22bf9df4..a9ae5908df 100644 --- a/react-bootstrap-table/react-bootstrap-table-tests.tsx +++ b/react-bootstrap-table/react-bootstrap-table-tests.tsx @@ -23,7 +23,7 @@ function priceFormatter(cell: any, row: any) { render( Product ID - Product Name + Product Name Product Price , document.getElementById("app") diff --git a/react-bootstrap-table/react-bootstrap-table.d.ts b/react-bootstrap-table/react-bootstrap-table.d.ts index ef71133841..4b05001a15 100644 --- a/react-bootstrap-table/react-bootstrap-table.d.ts +++ b/react-bootstrap-table/react-bootstrap-table.d.ts @@ -556,6 +556,12 @@ declare module "react-bootstrap-table" { */ options?: any; + + /** + Configuration for the textarea editable type + */ + cols?: number; + rows?: number; } export type FilterType = 'TextFilter' | 'RegexFilter' | 'SelectFilter' | 'NumberFilter' | 'DateFilter' | 'CustomFilter'; From 115b611e67f45d7680074942e3f2d80604b7e7d5 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Tue, 26 Jul 2016 15:39:56 -0400 Subject: [PATCH 81/81] react-bootstrap-table: add ianks to definition authors list --- react-bootstrap-table/react-bootstrap-table.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-bootstrap-table/react-bootstrap-table.d.ts b/react-bootstrap-table/react-bootstrap-table.d.ts index 4b05001a15..59accd8722 100644 --- a/react-bootstrap-table/react-bootstrap-table.d.ts +++ b/react-bootstrap-table/react-bootstrap-table.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-bootstrap-table v2.3.0 // Project: https://github.com/AllenFang/react-bootstrap-table -// Definitions by: Frank Laub , Michael Scharf +// Definitions by: Frank Laub , Michael Scharf , Ian Ker-Seymer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped ///