diff --git a/package.json b/package.json index 1be6d06c89..8e734f2b89 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "scripts": { "compile-scripts": "tsc -p scripts", "not-needed": "node scripts/not-needed.js", - "test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed --nProcesses 1", + "test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed --nProcesses 4", "lint": "dtslint types" }, "devDependencies": { diff --git a/types/ace/index.d.ts b/types/ace/index.d.ts index 90466c946e..58bf1c2bd8 100644 --- a/types/ace/index.d.ts +++ b/types/ace/index.d.ts @@ -474,7 +474,9 @@ declare namespace AceAjax { removeFold(arg: any): void; expandFold(arg: any): void; - + + foldAll(startRow?: number, endRow?: number, depth?: number): void + unfold(arg1: any, arg2: boolean): void; screenToDocumentColumn(row: number, column: number): void; diff --git a/types/angular-local-storage/angular-local-storage-tests.ts b/types/angular-local-storage/angular-local-storage-tests.ts index ead14e85fb..b3fdde8b9e 100644 --- a/types/angular-local-storage/angular-local-storage-tests.ts +++ b/types/angular-local-storage/angular-local-storage-tests.ts @@ -64,6 +64,7 @@ app.config(function (localStorageServiceProvider: ng.local.storage.ILocalStorage localStorageServiceProvider .setPrefix('myApp') .setStorageType('sessionStorage') + .setDefaultToCookie(false) .setNotify(true, true); }); diff --git a/types/angular-local-storage/index.d.ts b/types/angular-local-storage/index.d.ts index faa99065da..76ab65b1b5 100644 --- a/types/angular-local-storage/index.d.ts +++ b/types/angular-local-storage/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for angular-local-storage v0.1.6 +// Type definitions for angular-local-storage v0.6.0 // Project: https://github.com/grevory/angular-local-storage -// Definitions by: Ken Fukuyama +// Definitions by: Ken Fukuyama , Davide Donadello // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -27,12 +27,18 @@ declare module 'angular' { * @param storageType localstorage or sessionStorage. default: localStorage */ setStorageType(storageType: string): ILocalStorageServiceProvider; + /** + * If localStorage is not supported, the library will default to cookies instead. This behavior can be disabled + * @param shouldDefault default: true + */ + setDefaultToCookie(shouldDefault: boolean): ILocalStorageServiceProvider; /** * Setter for cookie config * @param exp number of days before cookies expire (0 = does not expire). default: 30 * @param path the web path the cookie represents. default: '/' + * @param secure to store cookies as secure. default: false */ - setStorageCookie(exp: number, path: string): ILocalStorageServiceProvider; + setStorageCookie(exp: number, path: string, secure: boolean): ILocalStorageServiceProvider; /** * Set the cookie domain, since this runs inside a the config() block, only providers and constants can be injected. As a result, $location service can't be used here, use a hardcoded string or window.location. * No default value diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index 6a601910d0..20de01f71f 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -627,11 +627,13 @@ function test_angular_forEach() { } // angular.element() tests -let element = angular.element('div.myApp'); +let element = angular.element('
'); let scope: ng.IScope = element.scope(); let isolateScope: ng.IScope = element.isolateScope(); -isolateScope = element.find('div.foo').isolateScope(); +isolateScope = element.find('div').isolateScope(); isolateScope = element.children().isolateScope(); +let element2 = angular.element(element); +let elementArray = angular.element(document.querySelectorAll('div')); // $timeout signature tests namespace TestTimeout { diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts index 4f8d55f9dc..3683c1aed6 100644 --- a/types/angular/index.d.ts +++ b/types/angular/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for Angular JS 1.6 // Project: http://angularjs.org -// Definitions by: Diego Vilar , Georgii Dolzhykov , Caleb St-Denis +// Definitions by: Diego Vilar +// Georgii Dolzhykov +// Caleb St-Denis +// Leonard Thieu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/angular/jqlite.d.ts b/types/angular/jqlite.d.ts index 36509143fa..150c50b5dd 100644 --- a/types/angular/jqlite.d.ts +++ b/types/angular/jqlite.d.ts @@ -1,3 +1,4 @@ +// Project: http://jquery.com/ // Definitions by: Boris Yankov // Christian Hoffmeister // Steve Fenton @@ -19,6 +20,8 @@ // Dick van den Brink // Thomas Schulz // Leonard Thieu +// Andre Wiggins +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Definitions copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0480c5ec87fab41aa23047a02b27f0ea71aaf975/types/jquery/v2/index.d.ts @@ -169,7 +172,7 @@ interface JQuery { * @param properties An object of property-value pairs to set. * @see {@link https://api.jquery.com/css/#css-properties} */ - css(properties: JQueryCssProperties): JQuery; + css(properties: JQLiteCssProperties): JQuery; /** * Store arbitrary data associated with the matched elements. @@ -664,7 +667,7 @@ interface JQuery { } interface JQueryStatic { - (element: string | Element): JQuery; + (element: string | Element | Document | JQuery | ArrayLike): JQuery; } /** @@ -796,7 +799,10 @@ interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObjec /** * The interface used to specify the properties parameter in css() */ -type cssPropertySetter = (index: number, value?: string) => string | number; -interface JQueryCssProperties { +// tslint:disable-next-line:class-name +interface cssPropertySetter { + (index: number, value?: string): string | number; +} +interface JQLiteCssProperties { [propertyName: string]: string | number | cssPropertySetter; } diff --git a/types/async.nexttick/async.nexttick-tests.ts b/types/async.nexttick/async.nexttick-tests.ts new file mode 100644 index 0000000000..90f6ae7f15 --- /dev/null +++ b/types/async.nexttick/async.nexttick-tests.ts @@ -0,0 +1,11 @@ +import {nextTick} from 'async.nexttick'; + +function calledOnNextTick(a: string): number { + return parseInt(a, 10); +} + +const aString = 'Hi!'; + +nextTick(() => { + calledOnNextTick(aString); +}); diff --git a/types/async.nexttick/index.d.ts b/types/async.nexttick/index.d.ts new file mode 100644 index 0000000000..a8572cc087 --- /dev/null +++ b/types/async.nexttick/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for async.nexttick 0.5 +// Project: https://www.npmjs.com/package/async.nexttick +// Definitions by: Damien "pyrho" Rajon +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function nextTick(callback: () => void, ...args: any[]): void; diff --git a/types/async.nexttick/tsconfig.json b/types/async.nexttick/tsconfig.json new file mode 100644 index 0000000000..68011bfd96 --- /dev/null +++ b/types/async.nexttick/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "async.nexttick-tests.ts" + ] +} + diff --git a/types/async.nexttick/tslint.json b/types/async.nexttick/tslint.json new file mode 100644 index 0000000000..d0858559ac --- /dev/null +++ b/types/async.nexttick/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/autoprefixer/index.d.ts b/types/autoprefixer/index.d.ts index b5249746d1..1957632053 100644 --- a/types/autoprefixer/index.d.ts +++ b/types/autoprefixer/index.d.ts @@ -7,7 +7,7 @@ import { Plugin, Transformer as PostcssTransformer } from 'postcss'; declare namespace autoprefixer { interface Options { - browsers?: string[]; + browsers?: string[] | string; env?: string; cascade?: boolean; add?: boolean; diff --git a/types/backbone.marionette/index.d.ts b/types/backbone.marionette/index.d.ts index 8b3d338293..ad623aa078 100644 --- a/types/backbone.marionette/index.d.ts +++ b/types/backbone.marionette/index.d.ts @@ -1265,17 +1265,17 @@ declare namespace Marionette { */ start(options?: any): void; - /** Deprecated! nstead of using the Application as the root of your view tree, you should use a Layout View.*/ - addRegions(regions: any): any; + /** Root region of the application*/ + region: string; - /** Deprecated! nstead of using the Application as the root of your view tree, you should use a Layout View.*/ - emptyRegions(): void; + /** Get the root region */ + getRegion(): Region; - /** Deprecated! nstead of using the Application as the root of your view tree, you should use a Layout View.*/ - removeRegion(region: Region): void; + /** Show a view in the root region */ + showView(view: Backbone.View): void; - /** Deprecated! nstead of using the Application as the root of your view tree, you should use a Layout View.*/ - getRegion(regionName: string): Region; + /** Get the view from the root region*/ + getView(): any; module(moduleNames: any, moduleDefinition: any): Module; diff --git a/types/bem-cn/bem-cn-tests.ts b/types/bem-cn/bem-cn-tests.ts new file mode 100644 index 0000000000..d57e138777 --- /dev/null +++ b/types/bem-cn/bem-cn-tests.ts @@ -0,0 +1,46 @@ +import * as block from "bem-cn"; + +// expected 'block' +block("block")(); + +// expected 'block__elem' +block("block")("elem")(); + +// expected 'block__elem block__elem_disabled block__elem_size_small' +block("block")("elem", { disabled: true, size: 'small' })(); + +// expected 'block block_disabled' +block("block")({ disabled: true})(); + +// expected 'block mix' +block("block").mix("mix"); + +// expected 'block mix mix2' +block("block").mix(["mix", "mix2"]); + +// expected 'block is-hidden' +block("block").state({ hidden: true }); + +// expected 'block' +block("block").state({ hidden: false }); + +// expected 'block is-hidden is-error' +block("block").state({ hidden: true, error: true }); + +// expected 'block is-loading' +block("block").is({ loading: true }); + +// expected 'block has-content' +block("block").has({ content: true }); + +block.setup({ + el: '~~', + mod: '--', + modValue: '-' +}); + +// expected 'block~~elem' +block("block")("elem"); + +// expected 'block block--mod-value' +block("block")({ mod: "value"}); diff --git a/types/bem-cn/index.d.ts b/types/bem-cn/index.d.ts new file mode 100644 index 0000000000..5a78df4435 --- /dev/null +++ b/types/bem-cn/index.d.ts @@ -0,0 +1,41 @@ +// Type definitions for bem-cn 2.1 +// Project: https://github.com/albburtsev/bem-cn +// Definitions by: Vitaly Selkin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type StateFn = (states: { [key: string]: boolean }) => Inner; + +interface Modifications { + [key: string]: (string | boolean); +} + +interface Block { + (name: string): Inner; + + reset(): void; + setup(settings?: Settings): void; +} + +interface Inner { + (elem: string | Modifications): Inner; + (elem: string, mods: Modifications): Inner; + (): string; + + mix(mixes: string | string[]): Inner; + has: StateFn; + state: StateFn; + is: StateFn; + toString(): string; + split(separator: string, limit?: number): string[]; +} + +interface Settings { + ns?: string; + el?: string; + mod?: string; + modValue?: string; + classMap?: { [className: string]: string } | null; +} + +declare const block: Block; +export = block; diff --git a/types/bem-cn/tsconfig.json b/types/bem-cn/tsconfig.json new file mode 100644 index 0000000000..a4c2cd86cb --- /dev/null +++ b/types/bem-cn/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bem-cn-tests.ts" + ] +} diff --git a/types/bem-cn/tslint.json b/types/bem-cn/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/bem-cn/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/bluebird/bluebird-tests.ts b/types/bluebird/bluebird-tests.ts index e616ae3f85..8aef9daa66 100644 --- a/types/bluebird/bluebird-tests.ts +++ b/types/bluebird/bluebird-tests.ts @@ -576,7 +576,6 @@ barProm = fooArrProm.spread((one: Foo, two: Bar, twotwo: Foo) => { //TODO fix collection inference barArrProm = fooProm.all(); -objProm = fooProm.props(); fooInspectionPromise = fooProm.reflect(); barProm = fooProm.any(); barArrProm = fooProm.some(num); @@ -584,6 +583,17 @@ barProm = fooProm.race(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +var propsValue: { num: number, str: string }; +Promise.resolve({ num: 1, str: Promise.resolve('a') }).props().then(val => { propsValue = val }); +Promise.props({ num: 1, str: Promise.resolve('a') }).then(val => { propsValue = val }); +Promise.props(Promise.props({ num: 1, str: Promise.resolve('a') })).then(val => { propsValue = val }); + +var propsMapValue: Map; +Promise.resolve(new Map>()).props().then(val => { propsMapValue = val }); +Promise.props(new Map>()).then(val => { propsMapValue = val }); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Promise.all([fooProm, barProm]).then(result => { result[0].foo(); result[1].bar(); diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 8482e5fe6e..844dad53d4 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -620,8 +620,8 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - // TODO how to model instance.props()? - props(): Bluebird; + props(this: PromiseLike | V>>): Bluebird>; + props(this: PromiseLike>): Bluebird; /** * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. @@ -806,11 +806,13 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * * *The original object is not modified.* */ - // TODO verify this is correct // trusted promise for object - static props(object: Bluebird): Bluebird; + static props(map: PromiseLike | V>>): Bluebird>; + static props(object: PromiseLike>): Bluebird; + // map + static props(map: Map | V>): Bluebird>; // object - static props(object: Object): Bluebird; + static props(object: Bluebird.ResolvableProps): Bluebird; /** * Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly. @@ -1074,6 +1076,8 @@ declare namespace Bluebird { /** @deprecated Use PromiseLike directly. */ export type Thenable = PromiseLike; + export type ResolvableProps = object & { [K in keyof T]: PromiseLike | T[K] }; + export interface Resolver { /** * Returns a reference to the controlled promise that can be passed to clients. diff --git a/types/browser-report/browser-report-tests.ts b/types/browser-report/browser-report-tests.ts new file mode 100644 index 0000000000..9f50b5b0f2 --- /dev/null +++ b/types/browser-report/browser-report-tests.ts @@ -0,0 +1,12 @@ +import 'browser-report'; + +function test_sync() { + var browserInfo = window.browserReportSync(); + console.log(browserInfo.browser.name); +} + +function test_async() { + window.browserReport((error, result) => { + console.log(result.ip + ' ' + result.browser.name); + }); +} \ No newline at end of file diff --git a/types/browser-report/index.d.ts b/types/browser-report/index.d.ts new file mode 100644 index 0000000000..c5852aae97 --- /dev/null +++ b/types/browser-report/index.d.ts @@ -0,0 +1,56 @@ +// Type definitions for browser-report v2.2.9 +// Project: https://github.com/JTOne123/browser-report +// Definitions by: Paul Datsiuk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Window { + browserReport(result: (error: ErrorEvent, report: ReportResult) => any): void; + browserReportSync(): ReportResult; +} + +interface ReportResult { + "browser": { + "name": string, + "version": string + }, + "cookies": boolean, + "flash": { + "version": string + }, + "ip": string, + "country": { + "name": string, + "code": string, + "city": string, + "latitude" : string, + "longitude": string, + "timezone": string + }, + "java": { + "version": string + }, + "lang": Array, + "os": { + "name": string, + "version": string + }, + "screen": { + "colors": number, + "dppx": number, + "height": number, + "width": number + }, + "scripts": boolean, + "timestamp": string, + "userAgent": string, + "viewport": { + "height": number, + "layout": { + "height": number, + "width": number + } + "width": number, + "zoom": number + } + "websockets": boolean +} \ No newline at end of file diff --git a/types/browser-report/tsconfig.json b/types/browser-report/tsconfig.json new file mode 100644 index 0000000000..997b307339 --- /dev/null +++ b/types/browser-report/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "browser-report-tests.ts" + ] +} \ No newline at end of file diff --git a/types/clndr/clndr-tests.ts b/types/clndr/clndr-tests.ts index d0939c3e80..07bff7f9e4 100644 --- a/types/clndr/clndr-tests.ts +++ b/types/clndr/clndr-tests.ts @@ -1,5 +1,4 @@ import * as Clndr from 'clndr'; -import $ = require('jquery'); const options: Clndr.ClndrOptions = { template: '', diff --git a/types/clndr/index.d.ts b/types/clndr/index.d.ts index 2c01d82518..6e0c22d2f3 100644 --- a/types/clndr/index.d.ts +++ b/types/clndr/index.d.ts @@ -2,6 +2,9 @@ // Project: https://github.com/kylestetz/CLNDR // Definitions by: jasperjn // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// import * as moment from 'moment'; diff --git a/types/clndr/tsconfig.json b/types/clndr/tsconfig.json index e2791aa5f0..47e9476079 100644 --- a/types/clndr/tsconfig.json +++ b/types/clndr/tsconfig.json @@ -12,11 +12,6 @@ "typeRoots": [ "../" ], - "paths": { - "jquery": [ - "jquery/v2" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/convict/convict-tests.ts b/types/convict/convict-tests.ts index 3bc0b4565f..daa07c6875 100644 --- a/types/convict/convict-tests.ts +++ b/types/convict/convict-tests.ts @@ -1,48 +1,41 @@ - -/// - import convict = require('convict'); import validator = require('validator'); // define a schema // straight from the convict tests -const format : convict.Format = { +const format: convict.Format = { name: 'float-percent', - validate: function(val) { + validate(val) { if (val !== 0 && (!val || val > 1 || val < 0)) { throw new Error('must be a float between 0 and 1, inclusive'); } }, - coerce: function(val) { - return +( val); + coerce(val) { + return parseFloat(val); } }; - - - convict.addFormat(format); convict.addFormats({ - prime: { - validate: function(val) { - function isPrime(n: number) { - if (n <= 1) return false; // zero and one are not prime - for (var i=2; i*i <= n; i++) { - if (n % i === 0) return false; - } - return true; - } - if (!isPrime(val)) throw new Error('must be a prime number'); - }, - coerce: function(val) { - return parseInt(val, 10); + prime: { + validate(val) { + function isPrime(n: number) { + if (n <= 1) return false; // zero and one are not prime + for (let i = 2; i * i <= n; i++) { + if (n % i === 0) return false; } + return true; } - }); + if (!isPrime(val)) throw new Error('must be a prime number'); + }, + coerce(val) { + return parseInt(val, 10); + } + } +}); - -var conf = convict({ +let conf = convict({ env: { doc: 'The applicaton environment.', format: ['production', 'development', 'test'], @@ -65,7 +58,11 @@ var conf = convict({ }, key: { doc: "API key", - format: (val: string) => validator.isUUID(val), + format: (val: string) => { + if (!validator.isUUID(val)) { + throw new Error('must be a valid UUID'); + } + }, default: '01527E56-8431-11E4-AF91-47B661C210CA' }, db: { @@ -81,7 +78,13 @@ var conf = convict({ default: 0, env: 'PORT', arg: 'port', - } + }, + password: { + doc: 'The database password.', + default: 'secret', + format: String, + sensitive: true, + }, }, primeNumber: { format: 'prime', @@ -91,14 +94,12 @@ var conf = convict({ format: 'float-percent', default: 0.5 }, - }); - // load environment dependent configuration -var env = conf.get('env'); -var dbip = conf.get('db.ip'); +let env = conf.get('env'); +let dbip = conf.get('db.ip'); conf.loadFile('./config/' + env + '.json'); conf.loadFile(['./configs/always.json', './configs/sometimes.json']); @@ -118,7 +119,7 @@ conf .validate({ allowed: 'warn' }) .toString(); -var port: number = conf.default('port'); +let port: number = conf.default('port'); if (conf.has('key')) { conf.set('the.awesome', true); diff --git a/types/convict/index.d.ts b/types/convict/index.d.ts index 82b22ba2db..183d91ed91 100644 --- a/types/convict/index.d.ts +++ b/types/convict/index.d.ts @@ -1,11 +1,11 @@ -// Type definitions for convict 3.0 +// Type definitions for convict 4.0 // Project: https://github.com/mozilla/node-convict -// Definitions by: Wim Looman , Vesa Poikajärvi +// Definitions by: Wim Looman +// Vesa Poikajärvi +// Eli Young // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - declare namespace convict { - type ValidationMethod = 'strict' | 'warn'; interface ValidateOptions { @@ -23,8 +23,8 @@ declare namespace convict { interface Format { name?: string; - validate?: (val: any) => void; - coerce?: (val: any) => any; + validate?(val: any): void; + coerce?(val: any): any; } interface Schema { @@ -35,16 +35,18 @@ declare namespace convict { * From the implementation: * * format can be a: - * - predefine type, as seen below + * - predefined type, as seen below * - an array of enumerated values, e.g. ["production", "development", "testing"] * - built-in JavaScript type, i.e. Object, Array, String, Number, Boolean - * - or if omitted, the Object.prototype.toString.call of the default value + * - function that performs validation and throws an Error on failure * - * The docs also state that any function that validates is ok too + * If omitted, format will be set to the value of Object.prototype.toString.call + * for the default value */ - format?: string | Array | Function; + format?: string | any[] | ((val: any) => void); env?: string; arg?: string; + sensitive?: boolean; }; } @@ -78,17 +80,11 @@ declare namespace convict { */ load(conf: Object): Config; /** - * Loads and merges one JSON configuration file into config + * Loads and merges JSON configuration file(s) into config * * @return {Config} instance */ - loadFile(file: string): Config; - /** - * Loads and merges multiple JSON configuration files into config - * - * @return {Config} instance - */ - loadFile(files: string[]): Config; + loadFile(files: string | string[]): Config; /** * Validates config against the schema used to initialize it * diff --git a/types/convict/tslint.json b/types/convict/tslint.json new file mode 100644 index 0000000000..09f94cd344 --- /dev/null +++ b/types/convict/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // ban-types needs to be disabled to support TypeScript <2.2 + "ban-types": false + } +} diff --git a/types/core-js/index.d.ts b/types/core-js/index.d.ts index 9593bc7a76..0a8f506df4 100644 --- a/types/core-js/index.d.ts +++ b/types/core-js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for core-js 0.9 // Project: https://github.com/zloirock/core-js/ -// Definitions by: Ron Buckton +// Definitions by: Ron Buckton , Michel Felipe // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -50,7 +50,10 @@ declare function $for(iterable: Iterable): $for; // ECMAScript 7 // Modules: es7.array.includes, es7.string.at, es7.string.pad-start, es7.string.pad-end, // es7.object.to-array, es7.object.get-own-property-descriptors, es7.regexp.escape, -// es7.map.to-json, and es7.set.to-json +// es7.map.to-json, es7.set.to-json, es7.reflect.define-metadata, es7.reflect.delete-metadata +// es7.reflect.get-metadata, es7.reflect.get-metadata-keys, es7.reflect.get-own-metadata, +// es7.reflect.get-own-metadata-keys, es7.reflect.has-metadata, es7.reflect.has-own-metadata +// es7.reflect.metadata // ############################################################################################# interface String { @@ -473,6 +476,202 @@ declare namespace core { function preventExtensions(target: any): boolean; function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: any, proto: any): boolean; + /** + * Define a unique metadata entry on the target. + * @param metadataKey A key used to store and retrieve metadata. + * @param metadataValue A value that contains attached metadata. + * @param target The target object on which to define metadata. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * Reflect.defineMetadata("custom:annotation", options, Example); + * + * // decorator factory as metadata-producing annotation. + * function MyAnnotation(options): ClassDecorator { + * return target => Reflect.defineMetadata("custom:annotation", options, target); + * } + * ``` + */ + function defineMetadata(metadataKey: any, metadataValue: any, target: Object, targetKey?: string | symbol): void; + /** + * Deletes the metadata entry from the target object with the provided key. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns `true` if the metadata entry was found and deleted; otherwise, false. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.deleteMetadata("custom:annotation", Example); + * ``` + */ + function deleteMetadata(metadataKey: any, target: Object, targetKey?: string | symbol): boolean; + /** + * Gets the metadata value for the provided metadata key on the target object or its prototype chain. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.getMetadata("custom:annotation", Example); + * ``` + */ + function getMetadata(metadataKey: any, target: Object, targetKey?: string | symbol): any; + /** + * Gets the metadata keys defined on the target object or its prototype chain. + * @param target The target object on which the metadata is defined. + * @returns An array of unique metadata keys. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.getMetadataKeys(Example); + * ``` + */ + function getMetadataKeys(target: Object, targetKey?: string | symbol): any[]; + /** + * Gets the metadata value for the provided metadata key on the target object. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.getOwnMetadata("custom:annotation", Example); + * ``` + */ + function getOwnMetadata(metadataKey: any, target: Object, targetKey?: string | symbol): any; + + /** + * Gets the unique metadata keys defined on the target object. + * @param target The target object on which the metadata is defined. + * @returns An array of unique metadata keys. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.getOwnMetadataKeys(Example); + * ``` + */ + function getOwnMetadataKeys(target: Object, targetKey?: string | symbol): any[]; + /** + * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`. + * @example + * + * ### Example + * + * ```typescript + * class Example { + * } + * + * // constructor + * result = Reflect.hasMetadata("custom:annotation", Example); + * ``` + */ + function hasMetadata(metadataKey: any, target: Object, targetKey?: string | symbol): boolean; + /** + * Gets a value indicating whether the target object has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns `true` if the metadata key was defined on the target object; otherwise, `false`. + * @example + * + * ### Example + * + * ```typescript + * + * class Example { + * } + * + * // constructor + * result = Reflect.hasOwnMetadata("custom:annotation", Example); + * ``` + */ + function hasOwnMetadata(metadataKey: any, target: Object, targetKey?: string | symbol): boolean; + /** + * A default metadata decorator factory that can be used on a class, class member, or parameter. + * @param metadataKey The key for the metadata entry. + * @param metadataValue The value for the metadata entry. + * @returns A decorator function. + * @remarks + * If `metadataKey` is already defined for the target and target key, the + * metadataValue for that key will be overwritten. + * @example + * + * ### Example + * + * ```typescript + * // constructor + * @Reflect.metadata(key, value) + * class Example { + * } + * + * // property (on constructor, TypeScript only) + * class Example { + * @Reflect.metadata(key, value) + * static staticProperty; + * } + * + * // property (on prototype, TypeScript only) + * class Example { + * @Reflect.metadata(key, value) + * property; + * } + * + * // method (on constructor) + * class Example { + * @Reflect.metadata(key, value) + * static staticMethod() { } + * } + * + * // method (on prototype) + * class Example { + * @Reflect.metadata(key, value) + * method() { } + * } + * ``` + */ + function metadata(metadataKey: any, metadataValue: any): { + (target: Function): void; + (target: Object, targetKey: string | symbol): void; + }; } const Object: { @@ -1991,6 +2190,42 @@ declare module "core-js/library/fn/reflect/set-prototype-of" { const setPrototypeOf: typeof core.Reflect.setPrototypeOf; export = setPrototypeOf; } +declare module "core-js/library/fn/reflect/es7/define-metadata" { + const defineMetadata: typeof core.Reflect.defineMetadata; + export = defineMetadata; +} +declare module "core-js/library/fn/reflect/es7/delete-metadata" { + const deleteMetadata: typeof core.Reflect.deleteMetadata; + export = deleteMetadata; +} +declare module "core-js/library/fn/reflect/es7/get-metadata" { + const getMetadata: typeof core.Reflect.getMetadata; + export = getMetadata; +} +declare module "core-js/library/fn/reflect/es7/get-metadata-keys" { + const getMetadataKeys: typeof core.Reflect.getMetadataKeys; + export = getMetadataKeys; +} +declare module "core-js/library/fn/reflect/es7/get-own-metadata" { + const getOwnMetadata: typeof core.Reflect.getOwnMetadata; + export = getOwnMetadata; +} +declare module "core-js/library/fn/reflect/es7/get-own-metadata-keys'" { + const getOwnMetadataKeys: typeof core.Reflect.getOwnMetadataKeys; + export = getOwnMetadataKeys; +} +declare module "core-js/library/fn/reflect/es7/has-metadata'" { + const hasMetadata: typeof core.Reflect.hasMetadata; + export = hasMetadata; +} +declare module "core-js/library/fn/reflect/es7/has-own-metadata'" { + const hasOwnMetadata: typeof core.Reflect.hasOwnMetadata; + export = hasOwnMetadata; +} +declare module "core-js/library/fn/reflect/es7/metadata'" { + const metadata: typeof core.Reflect.metadata; + export = metadata; +} declare module "core-js/library/fn/regexp" { const RegExp: typeof core.RegExp; export = RegExp; diff --git a/types/datatables.net/index.d.ts b/types/datatables.net/index.d.ts index 37c57198c9..68e26ee048 100644 --- a/types/datatables.net/index.d.ts +++ b/types/datatables.net/index.d.ts @@ -7,7 +7,7 @@ // missing: // - Static methods that are defined in JQueryStatic.fn are not typed. // - Plugin and extension definitions are not typed. -// - Some return types are not fully wokring +// - Some return types are not fully working /// diff --git a/types/dockerode/dockerode-tests.ts b/types/dockerode/dockerode-tests.ts index 8dd9a380de..ef2ed924d1 100644 --- a/types/dockerode/dockerode-tests.ts +++ b/types/dockerode/dockerode-tests.ts @@ -145,3 +145,36 @@ secret.remove((err, response) => { secret.update((err, response) => { // NOOP }); + +const node = docker.getNode('nodeName'); +node.inspect((err, reponse) => { + // NOOP +}); + +node.inspect().then(response => { + // NOOP +}); + +node.update({}, (err, response) => { + // NOOP +}); + +node.update((err, response) => { + // NOOP +}); + +node.update({}).then(response => { + // NOOP; +}); + +node.remove({}, (err, response) => { + // NOOP +}); + +node.remove((err, response) => { + // NOOP +}); + +node.remove({}).then(response => { + // NOOP; +}); diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts index a4a1144872..1b456e8f45 100644 --- a/types/dockerode/index.d.ts +++ b/types/dockerode/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/apocas/dockerode // Definitions by: Carl Winkler , Nicolas Laplante // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// @@ -169,6 +170,14 @@ declare namespace Dockerode { inspect(callback: Callback): void; inspect(): Promise; + update(options: {}, callback: Callback): void; + update(callback: Callback): void; + update(options?: {}): Promise; + + remove(options: {}, callback: Callback): void; + remove(callback: Callback): void; + remove(options?: {}): Promise; + modem: any; id?: string; } @@ -637,7 +646,7 @@ declare namespace Dockerode { interface DockerOptions { socketPath?: string; host?: string; - port?: number; + port?: number | string; ca?: string; cert?: string; key?: string; diff --git a/types/draft-js/index.d.ts b/types/draft-js/index.d.ts index a3c14b73b4..f7f389ea33 100644 --- a/types/draft-js/index.d.ts +++ b/types/draft-js/index.d.ts @@ -54,7 +54,7 @@ declare namespace Draft { * These props are analagous to `value` and `onChange` in controlled React * text inputs. */ - interface DraftEditorProps { + export interface DraftEditorProps { editorState: EditorState; onChange(editorState: EditorState): void; diff --git a/types/ej.web.all/ej.web.all-tests.ts b/types/ej.web.all/ej.web.all-tests.ts index c7d5521f1c..ae504eb752 100644 --- a/types/ej.web.all/ej.web.all-tests.ts +++ b/types/ej.web.all/ej.web.all-tests.ts @@ -1,7 +1,5 @@ /* tslint:disable */ -import $ = require('jquery'); - module AccordionComponent { $(function () { var sample = new ej.Accordion($("#basicAccordion"), { diff --git a/types/ej.web.all/index.d.ts b/types/ej.web.all/index.d.ts index ed36a800f6..9f46649c3e 100644 --- a/types/ej.web.all/index.d.ts +++ b/types/ej.web.all/index.d.ts @@ -2,6 +2,9 @@ // Project: http://help.syncfusion.com/js/typescript // Definitions by: Syncfusion // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// /*! * filename: ej.web.all.d.ts @@ -66684,7 +66687,7 @@ interface JQueryPromise { */ cancel?: boolean; } -interface JQueryDeferred extends JQueryPromise { +interface JQueryDeferred { /** * Returns the cancel option value. */ diff --git a/types/ej.web.all/tsconfig.json b/types/ej.web.all/tsconfig.json index 0dad85ed26..e187b54f67 100644 --- a/types/ej.web.all/tsconfig.json +++ b/types/ej.web.all/tsconfig.json @@ -12,11 +12,6 @@ "typeRoots": [ "../" ], - "paths": { - "jquery": [ - "jquery/v2" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index a0606a4961..34be61f5b0 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -13,75 +13,75 @@ declare module Elasticsearch { nodes: Nodes; snapshot: Snapshot; tasks: Tasks; - bulk(params: BulkIndexDocumentsParams): PromiseLike; + bulk(params: BulkIndexDocumentsParams): Promise; bulk(params: BulkIndexDocumentsParams, callback: (error: any, response: any) => void): void; clearScroll(params: ClearScrollParams, callback: (error: any, response: any) => void): void; - clearScroll(params: ClearScrollParams): PromiseLike; + clearScroll(params: ClearScrollParams): Promise; count(params: CountParams, callback: (error: any, response: CountResponse) => void): void; - count(params: CountParams): PromiseLike; - create(params: CreateDocumentParams): PromiseLike; + count(params: CountParams): Promise; + create(params: CreateDocumentParams): Promise; create(params: CreateDocumentParams, callback: (err: any, response: CreateDocumentResponse, status: any) => void): void; - delete(params: DeleteDocumentParams): PromiseLike; + delete(params: DeleteDocumentParams): Promise; delete(params: DeleteDocumentParams, callback: (error: any, response: DeleteDocumentResponse) => void): void; - deleteByQuery(params: DeleteDocumentByQueryParams): PromiseLike; + deleteByQuery(params: DeleteDocumentByQueryParams): Promise; deleteByQuery(params: DeleteDocumentByQueryParams, callback: (error: any, response: DeleteDocumentByQueryResponse) => void): void; - deleteScript(params: DeleteScriptParams): PromiseLike; + deleteScript(params: DeleteScriptParams): Promise; deleteScript(params: DeleteScriptParams, callback: (error: any, response: any) => void): void; - deleteTemplate(params: DeleteTemplateParams): PromiseLike; + deleteTemplate(params: DeleteTemplateParams): Promise; deleteTemplate(params: DeleteTemplateParams, callback: (error: any, response: any) => void): void; - exists(params: ExistsParams): PromiseLike; + exists(params: ExistsParams): Promise; exists(params: ExistsParams, callback: (error: any, response: any, status?: any) => void): void; - explain(params: ExplainParams): PromiseLike; + explain(params: ExplainParams): Promise; explain(params: ExplainParams, callback: (error: any, response: ExplainResponse) => void): void; - fieldStats(params: FieldStatsParams): PromiseLike; + fieldStats(params: FieldStatsParams): Promise; fieldStats(params: FieldStatsParams, callback: (error: any, response: FieldStatsResponse) => void): void; get(params: GetParams, callback: (error: any, response: GetResponse) => void): void; - get(params: GetParams): PromiseLike>; - getScript(params: GetScriptParams): PromiseLike; + get(params: GetParams): Promise>; + getScript(params: GetScriptParams): Promise; getScript(params: GetScriptParams, callback: (error: any, response: any) => void): void; - getSource(params: GetSourceParams): PromiseLike; + getSource(params: GetSourceParams): Promise; getSource(params: GetSourceParams, callback: (error: any, response: any) => void): void; - getTemplate(params: GetTemplateParams): PromiseLike; + getTemplate(params: GetTemplateParams): Promise; getTemplate(params: GetTemplateParams, callback: (error: any, response: any) => void): void; - index(params: IndexDocumentParams): PromiseLike; + index(params: IndexDocumentParams): Promise; index(params: IndexDocumentParams, callback: (error: any, response: any) => void): void; - info(params: InfoParams): PromiseLike; + info(params: InfoParams): Promise; info(params: InfoParams, callback: (error: any, response: any) => void): void; mget(params: MGetParams, callback: (error: any, response: MGetResponse) => void): void; - mget(params: MGetParams): PromiseLike>; + mget(params: MGetParams): Promise>; msearch(params: MSearchParams, callback: (error: any, response: MSearchResponse) => void): void; - msearch(params: MSearchParams): PromiseLike>; + msearch(params: MSearchParams): Promise>; msearchTemplate(params: MSearchTemplateParams, callback: (error: any, response: MSearchResponse) => void): void; - msearchTemplate(params: MSearchTemplateParams): PromiseLike>; - mtermvectors(params: MTermVectorsParams): PromiseLike; + msearchTemplate(params: MSearchTemplateParams): Promise>; + mtermvectors(params: MTermVectorsParams): Promise; mtermvectors(params: MTermVectorsParams, callback: (error: any, response: any) => void): void; - ping(params: PingParams): PromiseLike; + ping(params: PingParams): Promise; ping(params: PingParams, callback: (err: any, response: any, status: any) => void): void; - putScript(params: PutScriptParams): PromiseLike; + putScript(params: PutScriptParams): Promise; putScript(params: PutScriptParams, callback: (err: any, response: any, status: any) => void): void; - putTemplate(params: PutTemplateParams): PromiseLike; + putTemplate(params: PutTemplateParams): Promise; putTemplate(params: PutTemplateParams, callback: (err: any, response: any, status: any) => void): void; - reindex(params: ReindexParams): PromiseLike; + reindex(params: ReindexParams): Promise; reindex(params: ReindexParams, callback: (error: any, response: ReindexResponse) => void): void; - reindexRethrottle(params: ReindexRethrottleParams): PromiseLike; + reindexRethrottle(params: ReindexRethrottleParams): Promise; reindexRethrottle(params: ReindexRethrottleParams, callback: (error: any, response: any) => void): void; - renderSearchTemplate(params: RenderSearchTemplateParams): PromiseLike; + renderSearchTemplate(params: RenderSearchTemplateParams): Promise; renderSearchTemplate(params: RenderSearchTemplateParams, callback: (error: any, response: any) => void): void; - scroll(params: ScrollParams): PromiseLike; - scroll(params: ScrollParams, callback: (error: any, response: any) => void): void; - search(params: SearchParams): PromiseLike>; + scroll(params: ScrollParams): Promise>; + scroll(params: ScrollParams, callback: (error: any, response: SearchResponse) => void): void; + search(params: SearchParams): Promise>; search(params: SearchParams, callback: (error: any, response: SearchResponse) => void): void; - searchShards(params: SearchShardsParams): PromiseLike; + searchShards(params: SearchShardsParams): Promise; searchShards(params: SearchShardsParams, callback: (error: any, response: SearchShardsResponse) => void): void; - searchTemplate(params: SearchTemplateParams): PromiseLike; + searchTemplate(params: SearchTemplateParams): Promise; searchTemplate(params: SearchTemplateParams, callback: (error: any, response: any) => void): void; - suggest(params: SuggestParams): PromiseLike; + suggest(params: SuggestParams): Promise; suggest(params: SuggestParams, callback: (error: any, response: any) => void): void; - termvectors(params: TermvectorsParams): PromiseLike; + termvectors(params: TermvectorsParams): Promise; termvectors(params: TermvectorsParams, callback: (error: any, response: any) => void): void; - update(params: UpdateDocumentParams): PromiseLike; + update(params: UpdateDocumentParams): Promise; update(params: UpdateDocumentParams, callback: (error: any, response: any) => void): void; - updateByQuery(params: UpdateDocumentByQueryParams): PromiseLike; + updateByQuery(params: UpdateDocumentByQueryParams): Promise; updateByQuery(params: UpdateDocumentByQueryParams, callback: (error: any, response: any) => void): void; } @@ -774,43 +774,43 @@ declare module Elasticsearch { export interface Cat { aliases(params: CatAliasesParams, callback: (error: any, response: any) => void): void; - aliases(params: CatAliasesParams): PromiseLike; + aliases(params: CatAliasesParams): Promise; allocation(params: CatAllocationParams, callback: (error: any, response: any) => void): void; - allocation(params: CatAllocationParams): PromiseLike; + allocation(params: CatAllocationParams): Promise; count(params: CatCountParams, callback: (error: any, response: any) => void): void; - count(params: CatAllocationParams): PromiseLike; + count(params: CatAllocationParams): Promise; fielddata(params: CatFielddataParams, callback: (error: any, response: any) => void): void; - fielddata(params: CatFielddataParams): PromiseLike; + fielddata(params: CatFielddataParams): Promise; health(params: CatHealthParams, callback: (error: any, response: any) => void): void; - health(params: CatHealthParams): PromiseLike; + health(params: CatHealthParams): Promise; help(params: CatHelpParams, callback: (error: any, response: any) => void): void; - help(params: CatHelpParams): PromiseLike; + help(params: CatHelpParams): Promise; indices(params: CatIndicesParams, callback: (error: any, response: any) => void): void; - indices(params: CatIndicesParams): PromiseLike; + indices(params: CatIndicesParams): Promise; master(params: CatCommonParams, callback: (error: any, response: any) => void): void; - master(params: CatCommonParams): PromiseLike; + master(params: CatCommonParams): Promise; nodeattrs(params: CatCommonParams, callback: (error: any, response: any) => void): void; - nodeattrs(params: CatCommonParams): PromiseLike; + nodeattrs(params: CatCommonParams): Promise; nodes(params: CatCommonParams, callback: (error: any, response: any) => void): void; - nodes(params: CatCommonParams): PromiseLike; + nodes(params: CatCommonParams): Promise; pendingTasks(params: CatCommonParams, callback: (error: any, response: any) => void): void; - pendingTasks(params: CatCommonParams): PromiseLike; + pendingTasks(params: CatCommonParams): Promise; plugins(params: CatCommonParams, callback: (error: any, response: any) => void): void; - plugins(params: CatCommonParams): PromiseLike; + plugins(params: CatCommonParams): Promise; recovery(params: CatRecoveryParams, callback: (error: any, response: any) => void): void; - recovery(params: CatRecoveryParams): PromiseLike; + recovery(params: CatRecoveryParams): Promise; repositories(params: CatCommonParams, callback: (error: any, response: any) => void): void; - repositories(params: CatCommonParams): PromiseLike; + repositories(params: CatCommonParams): Promise; segments(params: CatSegmentsParams, callback: (error: any, response: any) => void): void; - segments(params: CatSegmentsParams): PromiseLike; + segments(params: CatSegmentsParams): Promise; shards(params: CatShardsParams, callback: (error: any, response: any) => void): void; - shards(params: CatShardsParams): PromiseLike; + shards(params: CatShardsParams): Promise; snapshots(params: CatSnapshotsParams, callback: (error: any, response: any) => void): void; - snapshots(params: CatSnapshotsParams): PromiseLike; + snapshots(params: CatSnapshotsParams): Promise; tasks(params: CatTasksParams, callback: (error: any, response: any) => void): void; - tasks(params: CatTasksParams): PromiseLike; + tasks(params: CatTasksParams): Promise; threadPool(params: CatThreadPoolParams, callback: (error: any, response: any) => void): void; - threadPool(params: CatThreadPoolParams): PromiseLike; + threadPool(params: CatThreadPoolParams): Promise; } export type CatBytes = "b" | "k" | "kb" | "m" | "mb" | "g" | "gb" | "t" | "tb" | "p" | "pb"; @@ -907,21 +907,21 @@ declare module Elasticsearch { export interface Cluster { allocationExplain(params: ClusterAllocationExplainParams, callback: (error: any, response: any) => void): void; - allocationExplain(params: ClusterAllocationExplainParams): PromiseLike; + allocationExplain(params: ClusterAllocationExplainParams): Promise; getSettings(params: ClusterGetSettingsParams, callback: (error: any, response: any) => void): void; - getSettings(params: ClusterGetSettingsParams): PromiseLike; + getSettings(params: ClusterGetSettingsParams): Promise; health(params: ClusterHealthParams, callback: (error: any, response: any) => void): void; - health(params: ClusterHealthParams): PromiseLike; + health(params: ClusterHealthParams): Promise; pendingTasks(params: ClusterPendingTasksParams, callback: (error: any, response: any) => void): void; - pendingTasks(params: ClusterPendingTasksParams): PromiseLike; + pendingTasks(params: ClusterPendingTasksParams): Promise; putSettings(params: ClusterPutSettingsParams, callback: (error: any, response: any) => void): void; - putSettings(params: ClusterPutSettingsParams): PromiseLike; + putSettings(params: ClusterPutSettingsParams): Promise; reroute(params: ClusterRerouteParams, callback: (error: any, response: any) => void): void; - reroute(params: ClusterRerouteParams): PromiseLike; + reroute(params: ClusterRerouteParams): Promise; state(params: ClusterStateParams, callback: (error: any, response: any) => void): void; - state(params: ClusterStateParams): PromiseLike; + state(params: ClusterStateParams): Promise; stats(params: ClusterStatsParams, callback: (error: any, response: any) => void): void; - stats(params: ClusterStatsParams): PromiseLike; + stats(params: ClusterStatsParams): Promise; } export interface ClusterAllocationExplainParams extends GenericParams { @@ -988,77 +988,77 @@ declare module Elasticsearch { export class Indices { analyze(params: IndicesAnalyzeParams, callback: (error: any, response: any, status: any) => void): void; - analyze(params: IndicesAnalyzeParams): PromiseLike; + analyze(params: IndicesAnalyzeParams): Promise; clearCache(params: IndicesClearCacheParams, callback: (error: any, response: any, status: any) => void): void; - clearCache(params: IndicesClearCacheParams): PromiseLike; + clearCache(params: IndicesClearCacheParams): Promise; close(params: IndicesCloseParams, callback: (error: any, response: any, status: any) => void): void; - close(params: IndicesCloseParams): PromiseLike; + close(params: IndicesCloseParams): Promise; create(params: IndicesCreateParams, callback: (error: any, response: any, status: any) => void): void; - create(params: IndicesCreateParams): PromiseLike; + create(params: IndicesCreateParams): Promise; delete(params: IndicesDeleteParams, callback: (error: any, response: any, status: any) => void): void; - delete(params: IndicesDeleteParams): PromiseLike; + delete(params: IndicesDeleteParams): Promise; deleteAlias(params: IndicesDeleteAliasParams, callback: (error: any, response: any, status: any) => void): void; - deleteAlias(params: IndicesDeleteAliasParams): PromiseLike; + deleteAlias(params: IndicesDeleteAliasParams): Promise; deleteTemplate(params: IndicesDeleteTemplateParams, callback: (error: any, response: any, status: any) => void): void; - deleteTemplate(params: IndicesDeleteTemplateParams): PromiseLike; + deleteTemplate(params: IndicesDeleteTemplateParams): Promise; exists(params: IndicesExistsParams, callback: (error: any, response: any, status: any) => void): void; - exists(params: IndicesExistsParams): PromiseLike; + exists(params: IndicesExistsParams): Promise; existsAlias(params: IndicesExistsAliasParams, callback: (error: any, response: any, status: any) => void): void; - existsAlias(params: IndicesExistsAliasParams): PromiseLike; + existsAlias(params: IndicesExistsAliasParams): Promise; existsTemplate(params: IndicesExistsTemplateParams, callback: (error: any, response: any, status: any) => void): void; - existsTemplate(params: IndicesExistsTemplateParams): PromiseLike; + existsTemplate(params: IndicesExistsTemplateParams): Promise; existsType(params: IndicesExistsTypeParams, callback: (error: any, response: any, status: any) => void): void; - existsType(params: IndicesExistsTypeParams): PromiseLike; + existsType(params: IndicesExistsTypeParams): Promise; flush(params: IndicesFlushParams, callback: (error: any, response: any, status: any) => void): void; - flush(params: IndicesFlushParams): PromiseLike; + flush(params: IndicesFlushParams): Promise; flushSynced(params: IndicesFlushSyncedParams, callback: (error: any, response: any, status: any) => void): void; - flushSynced(params: IndicesFlushSyncedParams): PromiseLike; + flushSynced(params: IndicesFlushSyncedParams): Promise; forcemerge(params: IndicesForcemergeParams, callback: (error: any, response: any, status: any) => void): void; - forcemerge(params: IndicesForcemergeParams): PromiseLike; + forcemerge(params: IndicesForcemergeParams): Promise; get(params: IndicesGetParams, callback: (error: any, response: any, status: any) => void): void; - get(params: IndicesGetParams): PromiseLike; + get(params: IndicesGetParams): Promise; getAlias(params: IndicesGetAliasParams, callback: (error: any, response: any, status: any) => void): void; - getAlias(params: IndicesGetAliasParams): PromiseLike; + getAlias(params: IndicesGetAliasParams): Promise; getFieldMapping(params: IndicesGetFieldMappingParams, callback: (error: any, response: any, status: any) => void): void; - getFieldMapping(params: IndicesGetFieldMappingParams): PromiseLike; + getFieldMapping(params: IndicesGetFieldMappingParams): Promise; getMapping(params: IndicesGetMappingParams, callback: (error: any, response: any, status: any) => void): void; - getMapping(params: IndicesGetMappingParams): PromiseLike; + getMapping(params: IndicesGetMappingParams): Promise; getSettings(params: IndicesGetSettingsParams, callback: (error: any, response: any, status: any) => void): void; - getSettings(params: IndicesGetSettingsParams): PromiseLike; + getSettings(params: IndicesGetSettingsParams): Promise; getTemplate(params: IndicesGetTemplateParams, callback: (error: any, response: any, status: any) => void): void; - getTemplate(params: IndicesGetTemplateParams): PromiseLike; + getTemplate(params: IndicesGetTemplateParams): Promise; getUpgrade(params: IndicesGetUpgradeParams, callback: (error: any, response: any, status: any) => void): void; - getUpgrade(params: IndicesGetUpgradeParams): PromiseLike; + getUpgrade(params: IndicesGetUpgradeParams): Promise; open(params: IndicesOpenParams, callback: (error: any, response: any, status: any) => void): void; - open(params: IndicesOpenParams): PromiseLike; + open(params: IndicesOpenParams): Promise; putAlias(params: IndicesPutAliasParams, callback: (error: any, response: any, status: any) => void): void; - putAlias(params: IndicesPutAliasParams): PromiseLike; + putAlias(params: IndicesPutAliasParams): Promise; putMapping(params: IndicesPutMappingParams, callback: (error: any, response: any, status: any) => void): void; - putMapping(params: IndicesPutMappingParams): PromiseLike; + putMapping(params: IndicesPutMappingParams): Promise; putSettings(params: IndicesPutSettingsParams, callback: (error: any, response: any, status: any) => void): void; - putSettings(params: IndicesPutSettingsParams): PromiseLike; + putSettings(params: IndicesPutSettingsParams): Promise; putTemplate(params: IndicesPutTemplateParams, callback: (error: any, response: any) => void): void; - putTemplate(params: IndicesPutTemplateParams): PromiseLike; + putTemplate(params: IndicesPutTemplateParams): Promise; recovery(params: IndicesRecoveryParams, callback: (error: any, response: any) => void): void; - recovery(params: IndicesRecoveryParams): PromiseLike; + recovery(params: IndicesRecoveryParams): Promise; refresh(params: IndicesRefreshParams, callback: (error: any, response: any) => void): void; - refresh(params: IndicesRefreshParams): PromiseLike; + refresh(params: IndicesRefreshParams): Promise; rollover(params: IndicesRolloverParams, callback: (error: any, response: IndicesRolloverResponse) => void): void; - rollover(params: IndicesRolloverParams): PromiseLike; + rollover(params: IndicesRolloverParams): Promise; segments(params: IndicesSegmentsParams, callback: (error: any, response: any) => void): void; - segments(params: IndicesSegmentsParams): PromiseLike; + segments(params: IndicesSegmentsParams): Promise; shardStores(params: IndicesShardStoresParams, callback: (error: any, response: any) => void): void; - shardStores(params: IndicesShardStoresParams): PromiseLike; + shardStores(params: IndicesShardStoresParams): Promise; shrink(params: IndicesShrinkParams, callback: (error: any, response: any) => void): void; - shrink(params: IndicesShrinkParams): PromiseLike; + shrink(params: IndicesShrinkParams): Promise; stats(params: IndicesStatsParams, callback: (error: any, response: any) => void): void; - stats(params: IndicesStatsParams): PromiseLike; + stats(params: IndicesStatsParams): Promise; updateAliases(params: IndicesUpdateAliasesParams, callback: (error: any, response: any) => void): void; - updateAliases(params: IndicesUpdateAliasesParams): PromiseLike; + updateAliases(params: IndicesUpdateAliasesParams): Promise; upgrade(params: IndicesUpgradeParams, callback: (error: any, response: any) => void): void; - upgrade(params: IndicesUpgradeParams): PromiseLike; + upgrade(params: IndicesUpgradeParams): Promise; validateQuery(params: IndicesValidateQueryParams, callback: (error: any, response: any) => void): void; - validateQuery(params: IndicesValidateQueryParams): PromiseLike; + validateQuery(params: IndicesValidateQueryParams): Promise; } export interface IndicesAnalyzeParams extends GenericParams { @@ -1416,13 +1416,13 @@ declare module Elasticsearch { export class Ingest { deletePipeline(params: IngestDeletePipelineParams, callback: (error: any, response: any, status: any) => void): void; - deletePipeline(params: IngestDeletePipelineParams): PromiseLike; + deletePipeline(params: IngestDeletePipelineParams): Promise; getPipeline(params: IngestGetPipelineParams, callback: (error: any, response: any, status: any) => void): void; - getPipeline(params: IngestGetPipelineParams): PromiseLike; + getPipeline(params: IngestGetPipelineParams): Promise; putPipeline(params: IngestPutPipelineParams, callback: (error: any, response: any, status: any) => void): void; - putPipeline(params: IngestPutPipelineParams): PromiseLike; + putPipeline(params: IngestPutPipelineParams): Promise; simulate(params: IngestSimulateParams, callback: (error: any, response: any, status: any) => void): void; - simulate(params: IngestSimulateParams): PromiseLike; + simulate(params: IngestSimulateParams): Promise; } export interface IngestDeletePipelineParams extends GenericParams { @@ -1450,11 +1450,11 @@ declare module Elasticsearch { export class Nodes { hotThreads(params: NodesHotThreadsParams, callback: (error: any, response: any, status: any) => void): void; - hotThreads(params: NodesHotThreadsParams): PromiseLike; + hotThreads(params: NodesHotThreadsParams): Promise; info(params: NodesInfoParams, callback: (error: any, response: any, status: any) => void): void; - info(params: NodesInfoParams): PromiseLike; + info(params: NodesInfoParams): Promise; stats(params: NodesStatsParams, callback: (error: any, response: any, status: any) => void): void; - stats(params: NodesStatsParams): PromiseLike; + stats(params: NodesStatsParams): Promise; } export interface NodesHotThreadsParams extends GenericParams { @@ -1491,23 +1491,23 @@ declare module Elasticsearch { export class Snapshot { create(params: SnapshotCreateParams, callback: (error: any, response: any, status: any) => void): void; - create(params: SnapshotCreateParams): PromiseLike; + create(params: SnapshotCreateParams): Promise; createRepository(params: SnapshotCreateRepositoryParams, callback: (error: any, response: any, status: any) => void): void; - createRepository(params: SnapshotCreateRepositoryParams): PromiseLike; + createRepository(params: SnapshotCreateRepositoryParams): Promise; delete(params: SnapshotDeleteParams, callback: (error: any, response: any, status: any) => void): void; - delete(params: SnapshotDeleteParams): PromiseLike; + delete(params: SnapshotDeleteParams): Promise; deleteRepository(params: SnapshotDeleteRepositoryParams, callback: (error: any, response: any, status: any) => void): void; - deleteRepository(params: SnapshotDeleteRepositoryParams): PromiseLike; + deleteRepository(params: SnapshotDeleteRepositoryParams): Promise; get(params: SnapshotGetParams, callback: (error: any, response: any, status: any) => void): void; - get(params: SnapshotGetParams): PromiseLike; + get(params: SnapshotGetParams): Promise; getRepository(params: SnapshotGetRepositoryParams, callback: (error: any, response: any, status: any) => void): void; - getRepository(params: SnapshotGetRepositoryParams): PromiseLike; + getRepository(params: SnapshotGetRepositoryParams): Promise; restore(params: SnapshotRestoreParams, callback: (error: any, response: any, status: any) => void): void; - restore(params: SnapshotRestoreParams): PromiseLike; + restore(params: SnapshotRestoreParams): Promise; status(params: SnapshotStatusParams, callback: (error: any, response: any, status: any) => void): void; - status(params: SnapshotStatusParams): PromiseLike; + status(params: SnapshotStatusParams): Promise; verifyRepository(params: SnapshotVerifyRepositoryParams, callback: (error: any, response: any, status: any) => void): void; - verifyRepository(params: SnapshotVerifyRepositoryParams): PromiseLike; + verifyRepository(params: SnapshotVerifyRepositoryParams): Promise; } export interface SnapshotCreateParams extends GenericParams { @@ -1571,11 +1571,11 @@ declare module Elasticsearch { export class Tasks { cancel(params: TasksCancelParams, callback: (error: any, response: any, status: any) => void): void; - cancel(params: TasksCancelParams): PromiseLike; + cancel(params: TasksCancelParams): Promise; get(params: TasksGetParams, callback: (error: any, response: any, status: any) => void): void; - get(params: TasksGetParams): PromiseLike; + get(params: TasksGetParams): Promise; list(params: TasksListParams, callback: (error: any, response: any, status: any) => void): void; - list(params: TasksListParams): PromiseLike; + list(params: TasksListParams): Promise; } export interface TasksCancelParams extends GenericParams { diff --git a/types/enzyme-to-json/enzyme-to-json-tests.tsx b/types/enzyme-to-json/enzyme-to-json-tests.tsx new file mode 100644 index 0000000000..13827a3cdb --- /dev/null +++ b/types/enzyme-to-json/enzyme-to-json-tests.tsx @@ -0,0 +1,6 @@ +import * as React from 'react'; +import { shallow } from 'enzyme'; +import toJson from 'enzyme-to-json'; + +const wrapper = shallow(Hello World!); +const result: object = toJson(wrapper); diff --git a/types/enzyme-to-json/index.d.ts b/types/enzyme-to-json/index.d.ts new file mode 100644 index 0000000000..cba4561649 --- /dev/null +++ b/types/enzyme-to-json/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for enzyme-to-json 1.5 +// Project: https://github.com/adriantoine/enzyme-to-json#readme +// Definitions by: Joscha Feth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { ReactWrapper, ShallowWrapper } from 'enzyme'; + +export default function toJson(wrapper: ShallowWrapper | ReactWrapper | Cheerio): object; diff --git a/types/enzyme-to-json/tsconfig.json b/types/enzyme-to-json/tsconfig.json new file mode 100644 index 0000000000..257f8797e0 --- /dev/null +++ b/types/enzyme-to-json/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "enzyme-to-json-tests.tsx" + ] +} diff --git a/types/enzyme-to-json/tslint.json b/types/enzyme-to-json/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/enzyme-to-json/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/fabric/index.d.ts b/types/fabric/index.d.ts index 1596d7d428..96c4ec4e5a 100644 --- a/types/fabric/index.d.ts +++ b/types/fabric/index.d.ts @@ -3086,7 +3086,7 @@ interface ITextOptions extends IObjectOptions { textBackgroundColor?: string; path?: string; - useNative?: Boolean; + useNative?: boolean; text?: string; } export interface Text extends ITextOptions {} diff --git a/types/flexslider/flexslider-tests.ts b/types/flexslider/flexslider-tests.ts index 967a351604..80421e1a99 100644 --- a/types/flexslider/flexslider-tests.ts +++ b/types/flexslider/flexslider-tests.ts @@ -1,21 +1,17 @@ -import $ = require('jquery'); - -// Can also be used with $(document).ready() -$(window).load(function() { +$(function() { $('.flexslider').flexslider({ animation: "slide" }); }); -// Can also be used with $(document).ready() -$(window).load(function() { +$(function() { $('.flexslider').flexslider({ animation: "slide", controlNav: "thumbnails" }); }); -$(window).load(function() { +$(function() { // The slider being synced must be initialized first $('#carousel').flexslider({ animation: "slide", @@ -36,7 +32,7 @@ $(window).load(function() { }); }); -$(window).load(function() { +$(function() { $('.flexslider').flexslider({ animation: "slide", animationLoop: false, @@ -45,8 +41,7 @@ $(window).load(function() { }); }); -// Can also be used with $(document).ready() -$(window).load(function() { +$(function() { $('.flexslider').flexslider({ animation: "slide", animationLoop: false, @@ -57,12 +52,10 @@ $(window).load(function() { }); }); -// Can also be used with $(document).ready() -$(window).load(function() { +$(function() { // Vimeo API nonsense - var player = document.getElementById('player_1'); - $(player).on('ready', ready); + $(ready); function addEvent(element:any, eventName:any, callback:any) { if (element.addEventListener) { @@ -72,8 +65,8 @@ $(window).load(function() { } } - function ready(player_id: any) { - var froogaloop = $(player_id); + function ready() { + var froogaloop = $('#player_1'); froogaloop.on('play', function(data) { $('.flexslider').flexslider({ pauseText: "pause" }); }); diff --git a/types/flexslider/index.d.ts b/types/flexslider/index.d.ts index cf38995f94..d9110a26f5 100644 --- a/types/flexslider/index.d.ts +++ b/types/flexslider/index.d.ts @@ -4,6 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 +/// + interface SliderObject { //Object: The slider element itself container: Object; //Object: The ul.slides within the slider slides: Object; //Object: The slides of the slider diff --git a/types/flexslider/tsconfig.json b/types/flexslider/tsconfig.json index a2425d596e..12c0cc9692 100644 --- a/types/flexslider/tsconfig.json +++ b/types/flexslider/tsconfig.json @@ -12,11 +12,6 @@ "typeRoots": [ "../" ], - "paths": { - "jquery": [ - "jquery/v2" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/fs-extra-promise/fs-extra-promise-tests.ts b/types/fs-extra-promise/fs-extra-promise-tests.ts index 9f5a8b32bf..c50115871b 100644 --- a/types/fs-extra-promise/fs-extra-promise-tests.ts +++ b/types/fs-extra-promise/fs-extra-promise-tests.ts @@ -205,7 +205,7 @@ readStream = fs.createReadStream(path, { writeStream = fs.createWriteStream(path); writeStream = fs.createWriteStream(path, { flags: str, - encoding: str + defaultEncoding: str }); let isDirectoryCallback = (err: Error, isDirectory: boolean) => { diff --git a/types/gapi.drive/index.d.ts b/types/gapi.drive/index.d.ts index ad8c64aa50..e0d4037ec9 100644 --- a/types/gapi.drive/index.d.ts +++ b/types/gapi.drive/index.d.ts @@ -6,8 +6,24 @@ /// -declare namespace gapi.client.drive { - export namespace files { +declare namespace gapi.client { + export module drive { + const files: { + get: (parameters: GetParameters) => HttpRequest; + patch: (parameters: PatchParameters) => HttpRequest; + copy: (parameters: CopyParameters) => HttpRequest; + delete: (parameters: DeleteParameters) => HttpRequest; + emptyTrash: () => HttpRequest; + export: (parameters: ExportParameters) => HttpRequest; + generateIds: (parameters: GenerateIdsParameters) => HttpRequest; + insert: (parameters: InsertParameters) => HttpRequest; + list: (parameters: ListParameters) => HttpRequest; + touch: (parameters: TouchParameters) => HttpRequest; + trash: (parameters: TrashParameters) => HttpRequest; + untrash: (parameters: UntrashParameters) => HttpRequest; + watch: (parameters: WatchParameters) => HttpRequest; + } + interface GetParameters { fileId: string; acknowledgeAbuse?: boolean; @@ -17,8 +33,6 @@ declare namespace gapi.client.drive { updateViewedDate?: boolean; } - export function get(parameters: GetParameters): HttpRequest; - interface PatchParameters { fileId: string; resource?: FileResource @@ -37,8 +51,6 @@ declare namespace gapi.client.drive { useContentAsIndexableText?: boolean; } - export function patch(parameters: PatchParameters): HttpRequest; - interface CopyParameters { fileId: string; resource?: FileResource; @@ -52,13 +64,39 @@ declare namespace gapi.client.drive { visibility?: string; } - export function copy(parameters: CopyParameters): HttpRequest; + interface DeleteParameters { + fileId: string; + supportsTeamDrives?: boolean; + } + + interface ExportParameters { + fileId: string; + mimeType: string; + } + + interface GenerateIdsParameters { + maxResults?: number; + space?: string; + } + + interface InsertParameters { + uploadType: string; + convert?: boolean; + ocr?: boolean; + ocrLanguage?: string; + pinned?: boolean; + supportsTeamDrives?: boolean; + timedTextLanguage?: string; + timedTextTrackName?: string; + usecontentAsIndexableText?: boolean; + visibility?: string; + } interface ListParameters { corpora?: string; corpus?: string; includeTeamDriveItems?: boolean; - maxResults: number; + maxResults?: number; orderBy?: string; pageToken?: string; projection?: string; @@ -68,28 +106,22 @@ declare namespace gapi.client.drive { teamDriveId?: string; } - export function list(parameters: ListParameters): HttpRequest; - interface TouchParameters { fileId: string; supportsTeamDrives?: boolean; } - export function touch(parameters: TouchParameters): HttpRequest; - interface TrashParameters { fileId: string; supportsTeamDrives?: boolean; } - export function trash(parameters: TrashParameters): HttpRequest; interface UntrashParameters { fileId: string; supportsTeamDrives?: boolean; } - export function untrash(parameters: UntrashParameters): HttpRequest; interface WatchParameters { fileId: string; @@ -98,239 +130,243 @@ declare namespace gapi.client.drive { supportsTeamDrives?: boolean; } - export function watch(parameters: WatchParameters): HttpRequest; - } - - export interface FileResource { - kind: 'drive#file'; - id?: string; - // etag - selfLink?: string; - webContentLink?: string; - webViewLink?: string; - alternateLink?: string; - embedLink?: string; - // openWithLinks - defaultOpenWithLink?: string; - iconLink?: string; - hasThumbnail?: boolean; - thumbnailLink?: string; - thumbnail?: { - image: Uint8Array; - mimType: string; - }; - title?: string; - mimeType?: string; - description?: string; - labels?: { - starred?: boolean; - hidden?: boolean; - trashed?: boolean; - restricted?: boolean; - viewed?: boolean; - modified?: boolean; - }; - createdDate?: Date; - modifiedDate?: Date; - modifiedByMeDate?: Date; - lastViewedByMeDate?: Date; - markedViewedByMeDate?: Date; - sharedWithMeDate?: Date; - version?: number; - sharingUser?: { - kind: 'drive#user'; - displayName?: string; - picture?: { - url: string; + interface FileResource { + kind: 'drive#file'; + id: string; + etag: string; + selfLink: string; + webContentLink: string; + webViewLink: string; + alternateLink: string; + embedLink: string; + // openWithLinks + defaultOpenWithLink: string; + iconLink: string; + hasThumbnail: boolean; + thumbnailLink: string; + thumbnail: { + image: Uint8Array; + mimType: string; }; - isAuthenticatedUser?: boolean; - permissionId?: string; - emailAddress?: string; - }; - parents?: ParentResource[]; - downloadUrl?: string; - // exportLinks - indexableText?: { - text: string; - }; - userPermission?: PermissionResource; - permissions?: PermissionResource[]; - hasAugmentedPermissions?: boolean; - originalFilename?: string; - fileExtension?: string; - fullFileExtension?: string; - md5Checksum?: string; - fileSize?: number; - quotaBytesUsed?: number; - ownerNames?: string[]; - owners?: { - kind: 'drive#user'; - displayName?: string; - picture?: { - url: string; + title: string; + mimeType: string; + description: string; + labels: { + starred: boolean; + hidden: boolean; + trashed: boolean; + restricted: boolean; + viewed: boolean; + modified: boolean; }; - isAuthenticatedUser?: boolean; - permissionId?: string; - emailAddress?: string; - }[]; - teamDriveId?: string; - lastModifyingUserName?: string; - lastModifyingUser?: { - kind: 'drive#user'; - displayName?: string; - picture?: { - url: string; + createdDate: Date; + modifiedDate: Date; + modifiedByMeDate: Date; + lastViewedByMeDate: Date; + markedViewedByMeDate: Date; + sharedWithMeDate: Date; + version: number; + sharingUser: { + kind: 'drive#user'; + displayName: string; + picture: { + url: string; + }; + isAuthenticatedUser: boolean; + permissionId: string; + emailAddress: string; }; - isAuthenticatedUser?: boolean; - permissionId?: string; - emailAddress?: string; - }; - ownedByMe?: boolean; - capabilities?: { - canAddChildren?: boolean; - canChangeRestrictedDownload?: boolean; - canComment?: boolean; - canCopy?: boolean; - canDelete?: boolean; - canDownload?: boolean; - canEdit?: boolean; - canListChildren?: boolean; - canMoveItemIntoTeamDrive?: boolean; - canMoveTeamDriveItem?: boolean; - canReadRevisions?: boolean; - canReadTeamDrive?: boolean; - canRemoveChildren?: boolean; - canRename?: boolean; - canShare?: boolean; - canTrash?: boolean; - canUntrash?: boolean; - }; - editable?: boolean; - canComment?: boolean; - canReadRevisions?: boolean; - shareable?: boolean; - copyable?: boolean; - writersCanShare?: boolean; - shared?: boolean; - explicitlyTrashed?: boolean; - trashingUser?: { - kind: 'drive#user'; - displayName?: string; - picture?: { - url: string; + parents: ParentResource[]; + downloadUrl: string; + // exportLinks + indexableText: { + text: string; }; - isAuthenticatedUser?: boolean; - permissionId?: string; - emailAddress?: string; - }; - trashedDate?: Date; - appDataContents?: boolean; - headRevisionId?: string; - properties?: PropertiesResource[]; - folderColorRgb?: string; - imageMediaMetadata?: { - width?: number; - height?: number; - rotation?: number; - location?: { - latitude?: number; - longitude?: number; - altitude?: number; + userPermission: PermissionResource; + permissions: PermissionResource[]; + hasAugmentedPermissions: boolean; + originalFilename: string; + fileExtension: string; + fullFileExtension: string; + md5Checksum: string; + fileSize: number; + quotaBytesUsed: number; + ownerNames: string[]; + owners: { + kind: 'drive#user'; + displayName: string; + picture: { + url: string; + }; + isAuthenticatedUser: boolean; + permissionId: string; + emailAddress: string; + }[]; + teamDriveId: string; + lastModifyingUserName: string; + lastModifyingUser: { + kind: 'drive#user'; + displayName: string; + picture: { + url: string; + }; + isAuthenticatedUser: boolean; + permissionId: string; + emailAddress: string; }; - date?: string; - cameraMake?: string; - cameraModel?: string; - exposureTime?: number; - aperture?: number; - flashUsed?: boolean; - focalLength?: number; - isoSpeed?: number; - meteringMode?: string; - sensor?: string; - exposureMode?: string; - colorSpace?: string; - whiteBalance?: string; - exposureBias?: number; - maxApertureValue?: number; - subjectDistance?: number; - lens?: string; - }; - videoMediaMetadata?: { - width?: number; - height?: number; - durationMillis?: number; - }; - spaces?: string[]; - isAppAuthorized?: boolean; - } + ownedByMe: boolean; + capabilities: { + canAddChildren: boolean; + canChangeRestrictedDownload: boolean; + canComment: boolean; + canCopy: boolean; + canDelete: boolean; + canDownload: boolean; + canEdit: boolean; + canListChildren: boolean; + canMoveItemIntoTeamDrive: boolean; + canMoveTeamDriveItem: boolean; + canReadRevisions: boolean; + canReadTeamDrive: boolean; + canRemoveChildren: boolean; + canRename: boolean; + canShare: boolean; + canTrash: boolean; + canUntrash: boolean; + }; + editable: boolean; + canComment: boolean; + canReadRevisions: boolean; + shareable: boolean; + copyable: boolean; + writersCanShare: boolean; + shared: boolean; + explicitlyTrashed: boolean; + trashingUser: { + kind: 'drive#user'; + displayName: string; + picture: { + url: string; + }; + isAuthenticatedUser: boolean; + permissionId: string; + emailAddress: string; + }; + trashedDate: Date; + appDataContents: boolean; + headRevisionId: string; + properties: PropertiesResource[]; + folderColorRgb: string; + imageMediaMetadata: { + width: number; + height: number; + rotation: number; + location: { + latitude: number; + longitude: number; + altitude: number; + }; + date: string; + cameraMake: string; + cameraModel: string; + exposureTime: number; + aperture: number; + flashUsed: boolean; + focalLength: number; + isoSpeed: number; + meteringMode: string; + sensor: string; + exposureMode: string; + colorSpace: string; + whiteBalance: string; + exposureBias: number; + maxApertureValue: number; + subjectDistance: number; + lens: string; + }; + videoMediaMetadata: { + width: number; + height: number; + durationMillis: number; + }; + spaces: string[]; + isAppAuthorized: boolean; + } - export interface FileListResource { - kind: 'drive#fileList'; - // etag - selfLink?: string; - nextPageToken?: string; - nextLink?: string; - incompleteSearch?: boolean; - items: FileResource[]; - } + interface FileListResource { + kind: 'drive#fileList'; + etag: string; + selfLink: string; + nextPageToken: string; + nextLink: string; + incompleteSearch: boolean; + items: FileResource[]; + } - export interface ParentResource { - kind: 'drive#parentReference'; - id?: string; - selfLink?: string; - parentLink?: string; - isRoot?: boolean; - } + interface ParentResource { + kind: 'drive#parentReference'; + id: string; + selfLink: string; + parentLink: string; + isRoot: boolean; + } - export interface PermissionResource { - kind: 'drive#permission'; - // etag - id?: string; - selfLink?: string; - name?: string; - emailAddress?: string; - domain?: string; - role?: string; - additionalRoles?: string[]; - type?: string; - value?: string; - authKey?: string; - withLink?: boolean; - photoLink?: string; - expirationDate?: Date; - teamDrivePermissionDetails?: { - teamDrivePermissionType?: string; - role?: string; - additionalRoles?: string[]; - inheritedFrom?: string; - inherited?: boolean; - }[]; - deleted?: boolean; - } + interface PermissionResource { + kind: 'drive#permission'; + etag: string; + id: string; + selfLink: string; + name: string; + emailAddress: string; + domain: string; + role: string; + additionalRoles: string[]; + type: string; + value: string; + authKey: string; + withLink: boolean; + photoLink: string; + expirationDate: Date; + teamDrivePermissionDetails: { + teamDrivePermissionType: string; + role: string; + additionalRoles: string[]; + inheritedFrom: string; + inherited: boolean; + }[]; + deleted: boolean; + } - export interface PropertiesResource { - kind: 'drive$property'; - // etag - selfLink?: string; - key?: string; - visibility?: string; - value?: string; - } + interface PropertiesResource { + kind: 'drive$property'; + etag: string; + selfLink: string; + key: string; + visibility: string; + value: string; + } - export interface WatchResource { - id?: string; - expiration?: number; - token?: string; - type?: string; - address?: string; - } + interface WatchResource { + id: string; + expiration: number; + token: string; + type: string; + address: string; + } - export interface ChannelResource { - kind: 'api#channel'; - id?: string; - resourceId?: string; - resourceUri?: string; - token?: string; - expiration?: number; + interface ChannelResource { + kind: 'api#channel'; + id: string; + resourceId: string; + resourceUri: string; + token: string; + expiration: number; + } + + interface IdsResource { + kind: 'drive#generatedIds'; + space: string; + ids: string[]; + } } } diff --git a/types/globby/globby-tests.ts b/types/globby/globby-tests.ts new file mode 100644 index 0000000000..0722b5fb37 --- /dev/null +++ b/types/globby/globby-tests.ts @@ -0,0 +1,24 @@ +import { IOptions } from 'glob'; + +import * as globby from "globby"; + +(async () => { + let result: string[]; + result = await globby('*.tmp'); + result = await globby(['a.tmp', '*.tmp', '!{c,d,e}.tmp']); + + result = globby.sync('*.tmp'); + result = globby.sync(['a.tmp', '*.tmp', '!{c,d,e}.tmp']); + + result = await globby('*.tmp', Object.freeze({ignore: Object.freeze([])})); + result = globby.sync('*.tmp', Object.freeze({ignore: Object.freeze([])})); +})(); + +const tasks: Array<{ + pattern: string, + options: IOptions +}> = globby.generateGlobTasks(['*.tmp', '!b.tmp'], {ignore: ['c.tmp']}); + +console.log(globby.hasMagic('**') === true); +console.log(globby.hasMagic(['**', 'path1', 'path2']) === true); +console.log(globby.hasMagic(['path1', 'path2']) === false); diff --git a/types/globby/index.d.ts b/types/globby/index.d.ts new file mode 100644 index 0000000000..d06091551c --- /dev/null +++ b/types/globby/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for globby 0.6 +// Project: https://github.com/sindresorhus/globby#readme +// Definitions by: Douglas Duteil +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { IOptions } from 'glob'; + +declare function globby(patterns: string | string[], options?: IOptions): Promise; + +declare namespace globby { + function sync(patterns: string | string[], options?: IOptions): string[]; + function generateGlobTasks(patterns: string | string[], options?: IOptions): Array<{pattern: string, options: IOptions}>; + function hasMagic(patterns: string | string[], options?: IOptions): boolean; +} + +export = globby; diff --git a/types/globby/tsconfig.json b/types/globby/tsconfig.json new file mode 100644 index 0000000000..fd75c832f1 --- /dev/null +++ b/types/globby/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "globby-tests.ts" + ] +} diff --git a/types/globby/tslint.json b/types/globby/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/globby/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/google-map-react/google-map-react-tests.tsx b/types/google-map-react/google-map-react-tests.tsx index 959bb8e68a..c01d1e3cab 100644 --- a/types/google-map-react/google-map-react-tests.tsx +++ b/types/google-map-react/google-map-react-tests.tsx @@ -1,6 +1,9 @@ -import GoogleMapReact from 'google-map-react'; +import GoogleMapReact, { BootstrapURLKeys } from 'google-map-react'; import * as React from 'react'; const center = { lat: 0, lng: 0 }; -; +const key: BootstrapURLKeys = { key: 'my-google-maps-key' }; +const client: BootstrapURLKeys = { client: 'my-client-identifier', v: '3.28' , language: 'en' }; + +; diff --git a/types/google-map-react/index.d.ts b/types/google-map-react/index.d.ts index c1898a9e3f..5e54c4e5aa 100644 --- a/types/google-map-react/index.d.ts +++ b/types/google-map-react/index.d.ts @@ -6,10 +6,7 @@ import * as React from 'react'; -export interface BootstrapURLKeys { - key: string; - language?: string; -} +export type BootstrapURLKeys = ({ key: string; } | { client: string; v: string; }) & { language?: string }; export interface Options { styles?: any[]; diff --git a/types/graphql/error/formatError.d.ts b/types/graphql/error/formatError.d.ts index 712c68c77b..5b974d5461 100644 --- a/types/graphql/error/formatError.d.ts +++ b/types/graphql/error/formatError.d.ts @@ -8,11 +8,11 @@ export function formatError(error: GraphQLError): GraphQLFormattedError; export type GraphQLFormattedError = { message: string, - locations: Array, - path: Array + locations?: Array, + path?: Array }; export type GraphQLErrorLocation = { line: number, column: number -}; \ No newline at end of file +}; diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index f0ed602864..91432e1d1f 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1935,10 +1935,11 @@ export class Request extends Podium { /** same as pre but represented as the response object created by the pre method. */ preResponses: Object; /** - * an object containing the query parameters. - * TODO update with outcome of: https://github.com/hapijs/hapi/pull/3479 + * by default the object outputted from [node's URL parse()](https://nodejs.org/docs/latest/api/url.html#url_urlobject_query) method. + * Might also be set indirectly via [request.setUrl](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17354#requestseturlurl-striptrailingslash) in which case it may be + * a string (if url is set to an object with the query attribute as an unparsed string). */ - query: Object; + query: any; /** an object containing the Node HTTP server objects. **Direct interaction with these raw objects is not recommended.** */ raw: { req: http.IncomingMessage; // Or http.ClientRequest http://www.apetuts.com/tutorial/node-js-http-client-request-class/ ? diff --git a/types/hapi/test/request/query.ts b/types/hapi/test/request/query.ts new file mode 100644 index 0000000000..c6507c2da0 --- /dev/null +++ b/types/hapi/test/request/query.ts @@ -0,0 +1,14 @@ +// Added test in addition to docs, for request.query + +import * as Hapi from 'hapi'; + +interface GetThingQuery { + name: string; +} + +const handler: Hapi.RouteHandler = function (request, reply) { + + const query = request.query as GetThingQuery; + + return reply(`You asked for ${query.name}`); +}; diff --git a/types/hapi/tsconfig.json b/types/hapi/tsconfig.json index 01c5a12c89..39ff8e810c 100644 --- a/types/hapi/tsconfig.json +++ b/types/hapi/tsconfig.json @@ -35,6 +35,7 @@ "test/request/generate-response.ts", "test/request/get-log.ts", "test/request/log.ts", + "test/request/query.ts", "test/request/set-method.ts", "test/request/set-url.ts", "test/request/tail.ts", diff --git a/types/heremaps/heremaps-tests.ts b/types/heremaps/heremaps-tests.ts index 01360c1bdf..d3e161cb74 100644 --- a/types/heremaps/heremaps-tests.ts +++ b/types/heremaps/heremaps-tests.ts @@ -44,7 +44,7 @@ let map = new H.Map(mapContainer, defaultLayers.normal.map, { // initial center and zoom level of the map zoom: 16, // Champs-Elysees - center: {lat: 48.869145, lng: 2.314298} + center: { lat: 48.869145, lng: 2.314298 } }); // Step 3: make the map interactive @@ -85,3 +85,78 @@ let polyline = new H.map.Polyline(new H.geo.Strip()); // tslint:disable-next-line:array-type let clipArr: Array>; clipArr = polyline.clip(new H.geo.Rect(5, 5, 5, 5)); + +let router = platform.getRoutingService(); +let calculateRouteParams = { + waypoint0: 'geo!52.5,13.4', + waypoint1: 'geo!52.5,13.45', + mode: 'fastest;car;traffic:disabled' +}; +router.calculateRoute( + calculateRouteParams, + (result) => { + console.log(result.response.route[0]); + }, + (error) => { + console.log(error); + } +); + +let places = platform.getPlacesService(); +let entryPoint = H.service.PlacesService.EntryPoint; +places.request( + entryPoint.SEARCH, + { + at: '52.5044,13.3909', + q: 'pizza' + }, + (response) => { + console.log(response); + let items = response.results.items; + places.follow( + items[0].href, + (resp) => { + console.log(resp); + }, + (resp) => { + console.log('ERROR: ' + resp); + } + ); + }, + (error) => { + console.log('ERROR: ' + error); + } +); + +let geocoder = platform.getGeocodingService(); +let geocodingParams: H.service.ServiceParameters = { + searchText: '425 W Randolph Street, Chicago' +}; +geocoder.geocode( + geocodingParams, + (result) => { + console.log(result); + console.log(result.Response.View[0].Result[0].Location.DisplayPosition); + }, + (error) => { + console.log(error); + } +); + +// deprecated but w/e +let enterprieseRouter = platform.getEnterpriseRoutingService(); +let calculateIsoline: H.service.ServiceParameters = { + start: 'geo!52.5,13.4', + distance: '1000,2000', + mode: 'fastest;car;traffic:disabled' +}; +enterprieseRouter.calculateIsoline( + calculateIsoline, + (result) => { + console.log(result); + console.log(result.Response.isolines[0]); + }, + (error) => { + console.log(error); + } +); diff --git a/types/heremaps/index.d.ts b/types/heremaps/index.d.ts index 206a932e68..ca32173bed 100644 --- a/types/heremaps/index.d.ts +++ b/types/heremaps/index.d.ts @@ -4301,14 +4301,15 @@ declare namespace H { /** * This is generic method to query places RestAPI. - * @param entryPoint {string} - can be one of available entry points H.service.PlacesService.EntryPoint i.e value of H.service.PlacesService.EntryPoint.SEARCH + * @param entryPoint {H.service.PlacesService.EntryPoint} - can be one of available entry points H.service.PlacesService.EntryPoint i.e value of H.service.PlacesService.EntryPoint.SEARCH * @param entryPointParams {Object} - parameter map key value pairs will be transformed into the url key=value parametes. For entry point parameters description please refer to places * restful api documentation documentation for available parameters for chose entry point * @param onResult {Function} - callback which is called when result is returned * @param onError {Function} - callback which is called when error occured (i.e request timeout) * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - request(entryPoint: string, entryPointParams: {}, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + request(entryPoint: H.service.PlacesService.EntryPoint, entryPointParams: {}, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): + H.service.JsonpRequestHandle; /** * Function triggers places api 'search' entry point. Please refer to documentation for parameter specification and response handling. @@ -4317,7 +4318,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - search(searchParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + search(searchParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * Function triggers places api 'suggestions' entry point. Please refer to documentation for parameter specification and response handling. @@ -4326,7 +4327,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - suggest(suggestParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + suggest(suggestParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * Function triggers places api 'explore' entry point. Please refer to documentation for parameter specification and response handling. @@ -4335,7 +4336,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - explore(exploreParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + explore(exploreParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * Function triggers places api 'around' entry point. Please refer to documentation for parameter specification and response handling. @@ -4344,7 +4345,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - around(aroundParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + around(aroundParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * Function triggers places api 'here' entry point. Please refer to documentation for parameter specification and response handling. @@ -4353,7 +4354,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - here(hereParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + here(hereParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * Function triggers places api 'categories' entry point. Please refer to documentation for parameter specification and response handling. @@ -4362,7 +4363,7 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - categories(categoriesParams: H.service.ServiceParameters, onResult: () => void, onError: () => void): H.service.JsonpRequestHandle; + categories(categoriesParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * This method should be used to follow hyperlinks available in results returned by dicovery queries. @@ -4372,7 +4373,7 @@ declare namespace H { * @param opt_additionalParameters {Object=} - additional parameters to send with request * @returns {H.service.JsonpRequestHandle} - jsonp resquest handle */ - follow(hyperlink: string, onResult: () => void, onError: () => void, opt_additionalParameters?: {}): H.service.JsonpRequestHandle; + follow(hyperlink: string, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void, opt_additionalParameters?: {}): H.service.JsonpRequestHandle; } namespace PlacesService { @@ -4605,7 +4606,140 @@ declare namespace H { * This type encapsulates a response object provider by a HERE platform service. */ interface ServiceResult { - [key: string]: string; + [key: string]: any; + response?: { + language?: string, + route?: Array<{ + leg: Array<{ + maneuver: Array<{ + id: string, + instruction: string, + length: number, + note: string[], + position: { + latitude: number, + longitude: number + }, + shape: string[], + travelTime: number, + _type: string + }> + }>, + mode: { + feature: any[], + trafficMode: string, + transportModes: string[], + type: string + } + shape: string[], + summary: { + baseTime: number, + distance: number, + flags: string[], + text: string, + trafficTime: number, + travelTime: number + } + waypoint: Array<{ + label: string, + linkId: string, + mappedPosition: { + latitude: number, + longitude: number + }, + mappedRoadName: string, + originalPosition: { + latitude: number, + longitude: number + }, + shapeIndex: number, + sideOfStreet: string, + spot: number, + type: string + }> + }>, + metaInfo: {} + }; + results?: { + items?: any[], + next?: string + }; + search?: { + context: { + href: string, + location: { + address: { + city: string, + country: string, + countryCode: string, + county: string, + district: string, + house: string, + postalCode: string, + stateCode: string, + street: string, + text: string + }, + position: number[] + }, + type: string + } + }; + Response?: { + MetaInfo: { + Timestamp: string + }, + View: Array<{ + Result: Array<{ + Location: { + Address: { + AdditionalData: Array<{ + key: string, + value: string + }>, + City: string, + Country: string, + County: string, + District: string, + HouseNumber: string, + Label: string, + PostalCode: string, + State: string, + Street: string + }, + DisplayPosition: { + Latitude: number, + Longitude: number + }, + LocationId: string, + LocationType: string, + MapView: { + BottomRight: { + Latitude: number, + Longitude: number + }, + TopLeft: { + Latitude: number, + Longitude: number + } + }, + NavigationPosition: Array<{ + Latitude: number, + Longitude: number + }> + }, + MatchLevel: string, + MatchQuality: { + City: number, + HouseNumber: number, + Street: number[] + }, + MatchType: string, + Relevance: number + }> + }>, + isolines: any[] + }; } /** @@ -4634,7 +4768,7 @@ declare namespace H { * @param onError {function()} * @returns {H.service.JsonpRequestHandle} */ - requestIncidents(serviceParams: H.service.ServiceParameters, onResponse: (result: H.service.ServiceResult) => void, onError: () => void): H.service.JsonpRequestHandle; + requestIncidents(serviceParams: H.service.ServiceParameters, onResponse: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; /** * This method requests traffic incident information by tile coordinates @@ -4646,8 +4780,8 @@ declare namespace H { * @param opt_serviceParams {H.service.ServiceParameters=} - optional service parameters to be added to the request * @returns {H.service.JsonpRequestHandle} */ - requestIncidentsByTile(x: number, y: number, z: number, onResponse: (result: H.service.ServiceResult) => void, onError: () => void, opt_serviceParams?: H.service.ServiceParameters): - H.service.JsonpRequestHandle; + requestIncidentsByTile(x: number, y: number, z: number, onResponse: (result: H.service.ServiceResult) => void, onError: (error: Error) => void, + opt_serviceParams?: H.service.ServiceParameters): H.service.JsonpRequestHandle; } namespace TrafficIncidentsService { diff --git a/types/iframe-resizer/iframe-resizer-tests.ts b/types/iframe-resizer/iframe-resizer-tests.ts new file mode 100644 index 0000000000..d127f8bf36 --- /dev/null +++ b/types/iframe-resizer/iframe-resizer-tests.ts @@ -0,0 +1,32 @@ +import {IFrameComponent, IFrameOptions, iframeResizer} from "iframe-resizer"; + +function testOne(): void { + let iframe: HTMLIFrameElement = document.createElement('iframe'); + let options: IFrameOptions = {log: true}; + let components: IFrameComponent[] = iframeResizer(options, iframe); + if (components) { + components.forEach(component => console.log(component.iFrameResizer)); + } else { + console.log("No components"); + } +} + +function testTwo(): void { + let iframe: HTMLIFrameElement = document.createElement('iframe'); + let components: IFrameComponent[] = iframeResizer({ + initCallback: () => { + console.log('Init'); + }, + closedCallback: () => { + console.log('Closed'); + } + }, iframe); + if (components) { + components.forEach(component => console.log(component.iFrameResizer)); + } else { + console.log("No components"); + } +} + +testOne(); +testTwo(); diff --git a/types/iframe-resizer/index.d.ts b/types/iframe-resizer/index.d.ts new file mode 100644 index 0000000000..1a05833692 --- /dev/null +++ b/types/iframe-resizer/index.d.ts @@ -0,0 +1,196 @@ +// Type definitions for iframe-resizer 3.5 +// Project: https://github.com/davidjbradshaw/iframe-resizer +// Definitions by: Armin Baljic +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// tslint:disable:prefer-method-signature +// tslint:disable-next-line:no-single-declare-module +declare module 'iframe-resizer' { + // tslint:disable-next-line:interface-name + interface IFrameObject { + close(): void; + moveToAnchor(anchor: string): void; + resize(): void; + sendMessage(message: any): void; + } + + // tslint:disable-next-line:interface-name + interface IFrameComponent extends HTMLIFrameElement { + iFrameResizer: IFrameObject; + } + + // tslint:disable-next-line:interface-name + interface IFrameOptions { + /** + * When enabled changes to the Window size or the DOM will cause the iFrame to resize to the new content size. + * Disable if using size method with custom dimensions. + */ + autoResize?: boolean; + /** + * Override the body background style in the iFrame. + */ + bodyBackground?: string; + /** + * Override the default body margin style in the iFrame. A string can be any valid value for the + * CSS margin attribute, for example '8px 3em'. A number value is converted into px. + */ + bodyMargin?: number; + /** + * When set to true, only allow incoming messages from the domain listed in the src property of the iFrame tag. + * If your iFrame navigates between different domains, ports or protocols; then you will need to + * provide an array of URLs or disable this option. + */ + checkOrigin?: boolean; + /** + * When enabled in page linking inside the iFrame and from the iFrame to the parent page will be enabled. + */ + inPageLinks?: boolean; + /** + * Height calculation method. + */ + heightCalculationMethod?: string; + /** + * Set iFrame Id + */ + id?: string; + /** + * In browsers that don't support mutationObserver, such as IE10, the library falls back to using + * setInterval, to check for changes to the page size. + */ + interval?: number; + /** + * Setting the log option to true will make the scripts in both the host page and the iFrame output + * everything they do to the JavaScript console so you can see the communication between the two scripts. + */ + log?: boolean; + /** + * Set maximum height of iFrame. + */ + maxHeight?: number; + /** + * Set maximum width of iFrame. + */ + maxWidth?: number; + /** + * Set minimum height of iFrame. + */ + minHeight?: number; + /** + * Set minimum width of iFrame. + */ + minWidth?: number; + /** + * Listen for resize events from the parent page, or the iFrame. Select the 'child' value if the iFrame + * can be resized independently of the browser window. Selecting this value can cause issues with some + * height calculation methods on mobile devices. + */ + resizeFrom?: string; + /** + * Enable scroll bars in iFrame. + */ + scrolling?: boolean; + /** + * Resize iFrame to content height. + */ + sizeHeight?: boolean; + /** + * Resize iFrame to content width. + */ + sizeWidth?: boolean; + /** + * Set the number of pixels the iFrame content size has to change by, before triggering a resize of the iFrame. + */ + tolerance?: number; + /** + * Width calculation method. + */ + widthCalculationMethod?: string; + /** + * Called when iFrame is closed via parentIFrame.close() or iframe.iframeResizer.close() methods. + */ + closedCallback?: (iframeId?: string) => void; + /** + * Initial setup callback function. + */ + initCallback?: (iframe?: IFrameComponent) => void; + /** + * Receive message posted from iFrame with the parentIFrame.sendMessage() method. + */ + messageCallback?: (data: IFrameMessageData) => void; + /** + * Function called after iFrame resized. Passes in messageData object containing the iFrame, height, width + * and the type of event that triggered the iFrame to resize. + */ + resizedCallback?: (data: IFrameResizedData) => void; + /** + * Called before the page is repositioned after a request from the iFrame, due to either an in page link, + * or a direct request from either parentIFrame.scrollTo() or parentIFrame.scrollToOffset(). + * If this callback function returns false, it will stop the library from repositioning the page, so that + * you can implement your own animated page scrolling instead. + */ + scrollCallback?: (data: IFrameScrollData) => boolean; + } + + // tslint:disable-next-line:interface-name + interface IFramePageOptions { + /** + * This option allows you to restrict the domain of the parent page, + * to prevent other sites mimicking your parent page. + */ + targetOrigin?: string; + /** + * Receive message posted from the parent page with the iframe.iFrameResizer.sendMessage() method. + */ + messageCallback?: (message: any) => void; + /** + * This function is called once iFrame-Resizer has been initialized after receiving a call from the parent page. + */ + readyCallback?: () => void; + /** + * These option can be used to override the option set in the parent page + */ + heightCalculationMethod?: string; + /** + * These option can be used to override the option set in the parent page + */ + widthCalculationMethod?: string; + } + + // tslint:disable-next-line:interface-name + interface IFramePage { + autoResize(resize?: boolean): boolean; + close(): void; + getId(): string; + getPageInfo(callback: (data: any) => void | false): void; + scrollTo(x: number, y: number): void; + scrollToOffset(x: number, y: number): void; + sendMessage(message: any, targetOrigin: string): void; + setHeightCalculationMethod(method: string): void; + setWidthCalculationMethod(method: string): void; + setTargetOrigin(targetOrigin: string): void; + size(customHeight: string, customWidth: string): void; + } + + // tslint:disable-next-line:interface-name + interface IFrameResizedData { + iframe: IFrameComponent; + height: number; + width: number; + type: string; + } + + // tslint:disable-next-line:interface-name + interface IFrameMessageData { + iframe: IFrameComponent; + message: string; + } + + // tslint:disable-next-line:interface-name + interface IFrameScrollData { + x: number; + y: number; + } + + function iframeResizer(options: IFrameOptions, target: HTMLElement): IFrameComponent[]; +} +// tslint:enable:prefer-method-signature diff --git a/types/iframe-resizer/tsconfig.json b/types/iframe-resizer/tsconfig.json new file mode 100644 index 0000000000..d2b812a1f7 --- /dev/null +++ b/types/iframe-resizer/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "exclude": [ + "node_modules" + ], + "files": [ + "index.d.ts", + "iframe-resizer-tests.ts" + ] +} \ No newline at end of file diff --git a/types/iframe-resizer/tslint.json b/types/iframe-resizer/tslint.json new file mode 100644 index 0000000000..30a1bdde2e --- /dev/null +++ b/types/iframe-resizer/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/imagemapster/imagemapster-tests.ts b/types/imagemapster/imagemapster-tests.ts index 8ee3942fd4..9712cb4e1a 100644 --- a/types/imagemapster/imagemapster-tests.ts +++ b/types/imagemapster/imagemapster-tests.ts @@ -1,5 +1,3 @@ -import $ = require('jquery'); - const areaOptions: ImageMapster.AreaRenderingOptions = { key: "foo", includeKeys: "foo", diff --git a/types/imagemapster/index.d.ts b/types/imagemapster/index.d.ts index 0ab0991f7e..101191baca 100644 --- a/types/imagemapster/index.d.ts +++ b/types/imagemapster/index.d.ts @@ -3,992 +3,996 @@ // Definitions by: delphinus // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace ImageMapster { +import jQuery = require('jquery'); - type Select = "select"; - type Deselect = "deselect"; - type Set = "set"; - type Get = "get"; - type Highlight = "highlight"; - type Unbind = "unbind"; - type Resize = "resize"; - type Snapshot = "snapshot"; - type Rebind = "rebind"; - type Keys = "keys"; - type SetOptions = "set_options"; - type GetOptions = "get_options"; - type Tooltip = "tooltip"; - type ToolTipCloseEvent = "area-mouseout" | "area-click" | "tooltip-click" | "image-mouseout"; - type State = "highlight" | "select"; +declare global { + namespace ImageMapster { - interface RenderingOptions { + type Select = "select"; + type Deselect = "deselect"; + type Set = "set"; + type Get = "get"; + type Highlight = "highlight"; + type Unbind = "unbind"; + type Resize = "resize"; + type Snapshot = "snapshot"; + type Rebind = "rebind"; + type Keys = "keys"; + type SetOptions = "set_options"; + type GetOptions = "get_options"; + type Tooltip = "tooltip"; + type ToolTipCloseEvent = "area-mouseout" | "area-click" | "tooltip-click" | "image-mouseout"; + type State = "highlight" | "select"; - /** - * fade effect - can only be applied to "render_highlight". - * - * Use a fade effect when highlighting areas on mouseover. - */ - fade?: boolean; + interface RenderingOptions { - /** - * The duration of the fade-in effect, in milliseconds. - */ - fadeDuration?: number; + /** + * fade effect - can only be applied to "render_highlight". + * + * Use a fade effect when highlighting areas on mouseover. + */ + fade?: boolean; - /** - * highlight areas on mouseover. When null (default), the behavior is - * disabled for mobile browsers. You can explicitly enable or disable - * it by setting this option to a boolean value. - */ - highlight?: boolean; + /** + * The duration of the fade-in effect, in milliseconds. + */ + fadeDuration?: number; - /** - * the map or an area on the map can be selected (or deselected). - * - * When true, the image map will function like a multiple-select menu. - * Users can click any area to select or deselect it. When applied to - * the entire map, it determines whether or not the click-selection - * functionality is enabled. When applied to an area, it determines - * whether that individual area (or group) can be selected. By default, - * the map and all areas are selectable. - */ - isSelectable?: boolean; + /** + * highlight areas on mouseover. When null (default), the behavior is + * disabled for mobile browsers. You can explicitly enable or disable + * it by setting this option to a boolean value. + */ + highlight?: boolean; - /** - * the map or area on the map can be deselected. - * - * Normally true, this option can be used to prevent users from - * unselecting items once they have been selected. When combined with - * singleSelect, the effect is that one and only one option can be - * selected at any given time. Users cannot deselect the active option. - * This provides a menu-like functionality. It is possible for zero - * items to be selected if this is the default state (or the only - * selected item is deselected programatically). - */ - isDeselectable?: boolean; + /** + * the map or an area on the map can be selected (or deselected). + * + * When true, the image map will function like a multiple-select menu. + * Users can click any area to select or deselect it. When applied to + * the entire map, it determines whether or not the click-selection + * functionality is enabled. When applied to an area, it determines + * whether that individual area (or group) can be selected. By default, + * the map and all areas are selectable. + */ + isSelectable?: boolean; - /** - * only one area can be selected at a time - * - * When true, only one or zero areas can be selected at any given time. - * If an area is selected and the user selects another area, the - * previously selected area will become deselected. Unlike - * "staticState", this property cannot be overridden by setting areas - * programatically, only one (or zero) areas can ever be selected when - * this option is true. - */ - singleSelect?: boolean; + /** + * the map or area on the map can be deselected. + * + * Normally true, this option can be used to prevent users from + * unselecting items once they have been selected. When combined with + * singleSelect, the effect is that one and only one option can be + * selected at any given time. Users cannot deselect the active option. + * This provides a menu-like functionality. It is possible for zero + * items to be selected if this is the default state (or the only + * selected item is deselected programatically). + */ + isDeselectable?: boolean; - /** - * the map or area is permanently in a selected or deselected state. - * - * When true or false, the map or area to which this option applies - * will be permanently selected or deselected. Typically this is more - * useful applied to individual areas that you want to exclude from the - * interactive part of the map. - * - * staticState forces an area to be always selected or deselected. If - * set, this will supercede isSelectable. Something with a staticState - * will always be in that state and it cannot be changed by the user. - * Note that when setting states programatically, this option will not - * be honored; it only affects user interaction. - */ - staticState?: boolean; + /** + * only one area can be selected at a time + * + * When true, only one or zero areas can be selected at any given time. + * If an area is selected and the user selects another area, the + * previously selected area will become deselected. Unlike + * "staticState", this property cannot be overridden by setting areas + * programatically, only one (or zero) areas can ever be selected when + * this option is true. + */ + singleSelect?: boolean; - /** - * initial selection state of an area. - * - * The area in question is selected. To set default selections when - * creating a new mapster, use this option for a specific area (see - * above). - */ - selected?: boolean; + /** + * the map or area is permanently in a selected or deselected state. + * + * When true or false, the map or area to which this option applies + * will be permanently selected or deselected. Typically this is more + * useful applied to individual areas that you want to exclude from the + * interactive part of the map. + * + * staticState forces an area to be always selected or deselected. If + * set, this will supercede isSelectable. Something with a staticState + * will always be in that state and it cannot be changed by the user. + * Note that when setting states programatically, this option will not + * be honored; it only affects user interaction. + */ + staticState?: boolean; - /** - * Use an alternate image of the same size as the imagemap as the - * source for highlight or select effects. - * - * When specified, the mapster will highlight areas using the image - * data obtained from the same area in an alternate image, instead of - * using a fill effect to highlight or select the area. This feature is - * currently available in browsers with HTML5 canvas support. In - * practical terms, this means it will work in all commonly used - * browsers except IE 8 or lower. - * - * If this feature is enabled when an unsupported browser is used, it - * will fall back to the normal highlight method. - * - * The fill, stroke and opacity effects can be specified independently - * from those used for the normal higlight effect. This ensures that - * when your page is viewed with a non-supported browser, you can still - * control the rendering as would be appropriate for a normal - * fill/stroke effect, which may be different from when you're using an - * alternate image. - */ - altImage?: string; - altImageFill?: boolean; - altImageStroke?: boolean; - altImageOpacity?: number; + /** + * initial selection state of an area. + * + * The area in question is selected. To set default selections when + * creating a new mapster, use this option for a specific area (see + * above). + */ + selected?: boolean; - /** - * Areas should be flood-filled when moused over or highlighted. - */ - fill?: boolean; + /** + * Use an alternate image of the same size as the imagemap as the + * source for highlight or select effects. + * + * When specified, the mapster will highlight areas using the image + * data obtained from the same area in an alternate image, instead of + * using a fill effect to highlight or select the area. This feature is + * currently available in browsers with HTML5 canvas support. In + * practical terms, this means it will work in all commonly used + * browsers except IE 8 or lower. + * + * If this feature is enabled when an unsupported browser is used, it + * will fall back to the normal highlight method. + * + * The fill, stroke and opacity effects can be specified independently + * from those used for the normal higlight effect. This ensures that + * when your page is viewed with a non-supported browser, you can still + * control the rendering as would be appropriate for a normal + * fill/stroke effect, which may be different from when you're using an + * alternate image. + */ + altImage?: string; + altImageFill?: boolean; + altImageStroke?: boolean; + altImageOpacity?: number; - /** - * The color used for flood fill. - */ - fillColor?: string; - fillColorMask?: string; + /** + * Areas should be flood-filled when moused over or highlighted. + */ + fill?: boolean; - /** - * The opacity of the fill. This is a number from 0 to 1. - */ - fillOpacity?: number; + /** + * The color used for flood fill. + */ + fillColor?: string; + fillColorMask?: string; - /** - * Areas should be outlined when moused over or highlighted. - */ - stroke?: boolean; + /** + * The opacity of the fill. This is a number from 0 to 1. + */ + fillOpacity?: number; - /** - * The color of the outline. - */ - strokeColor?: string; + /** + * Areas should be outlined when moused over or highlighted. + */ + stroke?: boolean; - /** - * The opacity of the outline. - */ - strokeOpacity?: number; + /** + * The color of the outline. + */ + strokeColor?: string; - /** - * The width of the outline. - */ - strokeWidth?: number; + /** + * The opacity of the outline. + */ + strokeOpacity?: number; - /** - * The options below control the way highlighted areas are rendered. - * Each can be applied globally to the map, or to each element, using - * the areas option to pass area-specific options. These options apply - * to either highlighted or selected areas. Highlighting occurs when - * the mouse enters an area on the image map. Selection occurs when an - * area is clicked, and selection is enabled. These options will be - * applied to both situations if present in the root of the options - * object. They can also be applied to one or the other situations - * specifically using the render_highlight and render_select options. - */ - render_highlight?: string | RenderingOptions; - render_select?: string | RenderingOptions; + /** + * The width of the outline. + */ + strokeWidth?: number; + + /** + * The options below control the way highlighted areas are rendered. + * Each can be applied globally to the map, or to each element, using + * the areas option to pass area-specific options. These options apply + * to either highlighted or selected areas. Highlighting occurs when + * the mouse enters an area on the image map. Selection occurs when an + * area is clicked, and selection is enabled. These options will be + * applied to both situations if present in the root of the options + * object. They can also be applied to one or the other situations + * specifically using the render_highlight and render_select options. + */ + render_highlight?: string | RenderingOptions; + render_select?: string | RenderingOptions; + } + + interface AreaRenderingOptions extends RenderingOptions { + + key: string; + + /** + * when rendering an area or area group, also render the areas in the + * other group (or groups) specified + * + * This is an area-specific option that allows you to create + * supergroups. A supergroup is a collection of groups that will all be + * highlighted simultaneously, but only when the area that defines the + * supergroup is moused over or activated through code. + * + * When the area for which this option has been set is activated, all + * the areas specified in the includeKeys list will also be rendered. + * This is a one-way relationship. Defining a supergroup in an area + * causes all the other groups to be highlighted, but not the other way + * around. + * + * A typical use of this is to define areas that you want to be + * highlighted when the mouse enters some specific area, but that you + * do not want to be highlighted on their own if the target area is + * moused over. This could be a hidden menu, for example: you want the + * menu to display when the hotspot is moused over, but when it's + * hidden, mousing over the menu area itself should have no effect. + */ + includeKeys?: string; + + /** + * the area is a mask rather than a highlighted area. + * + * Normally, every area in an imagemap is an active area, and would be + * highlighted when moused over (unless its behavior was otherwise + * specified with staticState). The isMask option allows you to + * identify an area as being a mask. When a mask is part of an area + * group, the masked area will be specifically excluded from the + * rendering of a highlight or selected state. + * + * This is usually used in conjunction, or instead of, the nohref + * attribute of the area tag. When nohref is specified on an area tag, + * that area is specifically excluded from the hotspot of any area that + * encompasses it. It will not respond to mouse events, and will not be + * highlighted. This can be used to create "holes" in hotspots. By + * default, ImageMapster will treat any area with nohref or no href tag + * as masks, the same as if this option had been applied. + * + * Sometimes you won't be able to use nohref to identify something as a + * mask, for example, if you intend to re-use an area has both a mask, + * and an independent hotspot. This would be typical if you wanted to a + * selectable area that was completely included within another + * selectable area, but functioned independently, such as concentric + * circles. In this case, you would need to identify the inner circle + * as both a mask, and a hotspot. The nohref attribute would make it + * not act as a hotspot, and only function as a mask. You couldn't also + * select the inner area. You can solve this problem by including the + * inner circle in two different groups - one group which is a mask for + * the main area, and another which is an independent selectable area. + * You can specify different options for each group, so even though + * it's just one area, it can function as two completely independent + * ones. + * + * There may also be situations where you do not want an area marked + * with nohref to be treated as a mask. For example, given "area1" and + * "area2," you may want to create a configuration where mousing over + * "area1" causes both "area1" and "area2" to be highlighted, but + * "area2" should not be highlighted on its own when it is moused over. + * In this situation, you'll need to use "nohref" to prevent the hover + * behavior for the area, but you still want it to be treated normally + * when it's rendered as a result of mousing over "area1." You can + * accomplish this using the noHrefIsMask global option, below. + * + * Generally, masked areas will appear as a window to the underlying + * image. If stroke is in effect, the stroke will be rendered for the + * mask as well as the areas, to create both inner and outer borders. + * You can always specifically enable or disable this, or any other + * effect, for any area as desired. + * + */ + isMask?: boolean; + + /** + * tool tip data for an area + * + * When this area-specific option is present and showToolTips = true, a + * toolTipContainer will be created this will be inserted into it, + * either as inner text (if only text as passed) or as HTML if a jQuery + * object is passed. In order to pass anything other than plain text + * using this option you must use a jQuery object. Any string will be + * treated as plain text (and special characters rendered correctly). + */ + toolTip?: string; + } + + interface OnClickData { + + /** + * $(item) from boundList + */ + listTarget?: JQuery; + + /** + * mapKey for this area + */ + key: string; + + e: JQueryEventObject; + selected: boolean; + } + + interface OnStateChangeData { + + /** + * map key + */ + key: string; + + state: "highlight" | "select"; + + /** + * indicating the current state (following the event) + */ + selected: boolean; + } + + interface OnMouseData { + + /** + * area key + */ + key: string; + + /** + * true if area is currently selected + */ + selected: boolean; + + e: JQueryEventObject; + options: AreaRenderingOptions; + } + + interface OnGetListData { + + /** + * primary mapKey for this area or area group + */ + key: string; + + /** + * mapValue for this area or group + */ + value: string; + + /** + * array of areas that make up this group + */ + area: any[]; + + options: AreaRenderingOptions; + } + + interface OnShowToolTipData { + + /** + * jQuery object of the tooltip container + */ + toolTip: JQuery; + + /** + * map key for this area + */ + key: string; + + /** + * current state of the area + */ + selected: boolean; + + areaOptions: AreaRenderingOptions; + } + + interface Options extends RenderingOptions { + + /** + * an attribute identifying each imagemap area. + * + * If specified, this refers to an attribute on the area tags that will + * be used to group them logically. Any areas containing the same + * mapKey will be considered part of a group, and rendered together + * when any of these areas is activated. If you don't want this + * functionality, ensure each key is unique. When mapKey is omitted, + * then each area is considered to be independent from the other and no + * grouping is applied. + * + * When mapKey is present, any area tags that are missing this + * attribute will be excluded from the image map e ntirely. This is + * functionally identical to setting staticState=false for these areas, + * except they will be inaccessible through the API. + * + * ImageMapster will work with any attribute you identify as a key. If + * you wish to maintain HTML compliance, it's recommeded that you use + * attribute names starting with "data-", for example, data-mapkey. Any + * such names are legal for the HTML5 document type. If you are using + * older document types, the class attribute is part of the HTML spec + * for area and will not cause any visual effects, so this is also a + * good choice. It is not recommended to use id, since the values of + * this attribute must be unique. title and alt also will cause + * possibly undesired side effects. + * + * You can specify more than one value in the mapKey attribute, + * separated by commas. This will cause an area to be a member of more + * than one group. The area may have different options in the context + * of each group. When the area is physically moused over, the first + * key listed will identify the group that's effective for that action. + */ + mapKey?: string; + + /** + * an attribute on each area tag containing additional descriptive + * information about an area. + * + * This option is applicable only when using onGetList. When set, the + * data provided to the callback function will include the value of + * this attribute for each group. This can be used to simplify building + * a list with associated information, without having to match against + * another resource. It also ties this information to the image map + * itself. It is not required to use this option when using onGetList. + * + * For example, you could set mapValue: 'data-statename' to an imagemap + * of the united states, and add an attribute to your areas that + * provided the full name of each state, e.g. data-statename="Alaska". + * This text would be included in the onGetList callback, and so you + * could use it to construct an external list of states. + * + * If there are grouped areas (areas with the same key), then the value + * from the first area found with data in this attribute will be used. + */ + mapValue?: string; + + /** + * Clicking on a link should cause the browser to navigate to the href + * whenever it's not a hash sign (#). Version 1.2.4.050 and later + * + * By default, ImageMapster will prevent the default browser behavior + * in image maps, and "select" areas when they are clicked. If you want + * to navigate to the url for an area, use this option. When enabled, + * all areas that have an href attribute, and its value is not empty or + * "#" (just a hashtag). + * + * When area grouping is used, if an href is present for any area in + * the primary group, this will be used as the navigation target. This + * way you don't need to copy the url for every area in groups, rather, + * you can include it on just one, and clicking any area will cause the + * appropraite navigation. + */ + clickNavigate?: boolean; + + /** + * an attribute on items in a boundList that corresponds to the value + * of the mapKey attributes. + * + * This is used to synchronize the actions on the imagemap with the + * actions on a boundList. Each value should match a value from the + * imageMap mapKey tag. Any item in the boundList with missing or + * mismatched data will be ignored. + */ + listKey?: string; + + /** + * attribute to set or remove when an area is selected or deselected + * + * If boundList is present, when a map area is selected, set or remove + * this attribute on the list element that matches that area based on + * their respective keys. + */ + listSelectedAttribute?: string; + + /** + * a class to add or remove when an area is selected or deselected + * + * If a boundList is present, when a map area is selected, this class + * is added or removed from the corresponding list element. This can be + * used to easily create any kind of associated action when areas on + * the map are changed. + */ + listSelectedClass?: string; + + /** + * + * define area-specific options; each object in the array must contain + * a "key" property identifying a valid mapKey, and additional + * rendering options specific to that area or group + */ + areas?: AreaRenderingOptions[], + + /** + * add "classname" class to the wrapper created around the image, or + * copy classes from the image if "true" + */ + wrapClass?: string | boolean; + + /** + * add CSS to the wrapper created around the image + */ + wrapCss?: string | boolean; + + /** + * delay removing highlight when mouse exits an area (1.2.5b36) + * + * Normally, when the user's mouse pointer exits an area, the highlight + * effect is removed immediately. This behavior can be changed with + * this option. Setting it to a positive number causes a delay of n + * milliseconds before the effect is removed. Setting to -1 causes the + * effect to remain active until another hotspot is entered (e.g., it + * will only be removed when superceded by a different area being + * highlighted). + * + * When using mouseoutDelay, the onMouseover event will still be fired + * at the time the user's mouse pointer leaves the area. However, the + * onStateChange event will be delayed until the highlight is actually + * removed. + * + * Whether or not you are using mouseoutDelay, only one area can be + * highlighted at a time. That is, whenever the mouse pointer moves + * onto a new active area, any previously highlighted area will become + * un-highlighted, regardless of any delay in effect. Hovering over a + * new area will always supercede any delay and cause the new area (and + * only the new area) to be highlighted at that time. So, for dense + * imagemaps where most areas adjoin one another, this option may not + * have much effect within the boundaries of the imagemap. Rather, it + * is intended to help keep the higlights active for imagemaps that are + * sparse, or have very small areas. + */ + mouseoutDelay?: number; + + /** + * sort the values before calling onGetList + * + * If a non-false value or "asc" is passed, the list will be sorted in + * ascending order by the area value from mapValue. If "desc" is + * passed, the list will be sorted in descending order. + */ + sortList?: boolean | "asc" | "desc"; + + /** + * time (in milliseconds) to wait for images to load before giving up + * + * When first bound, ImageMapster has to wait for the source image,and + * any altImage images to load before it can finish binding. This is + * necessary because otherwise it's not alwasy possible to know the + * native size of the images. After this period of time, ImageMapster + * will give up. If you have particularly large pages or images, you + * may want to increase this to account for long load times. + */ + configTimeout?: number; + + /** + * Automatically scale imagemaps to match the size of a + * dynamically-scaled image. + * + * When you render an image, you can optionally define a size through + * CSS or using the "height" and "width" attributes. If omitted, the + * image will be displayed in its native size. If included, browsers + * will automatically resize the image to display in the dimensions you + * have provided. + * + * Starting with 1.1.3, ImageMapster will automatically recalculate all + * area data to match the effective size of the image. This means that + * you can set the size of your image to anything you want and + * ImageMapster will work with no changes at all needed to the "area" + * data. + * + * If this behavior is not desired for some reason, this can be + * disabled by setting this option to false. + */ + scaleMap?: boolean; + + /** + * Treat areas containing the onhref attribute (or missing the href + * attribute) as masks. This is true by default. + * + * Set this to "false" to disable automatic masking of these areas. You + * can control them explicitly by creating independent groups for areas + * you wish to mask and assigning the isMask area-specific option when + * using this option. + * + * There are some things to be aware of when using nohref and masking: + * + * * You must put the area that include the nohref attribute before + * other areas that overlap it, or it will be ignored. + * + * * You should also explicitly omit the href tag when using nohref. + * + * * Due to limitations in rendering with VML (e.g. Internet Explorer + * 6-8), it is not possible to create a true mask, which would allow + * the underlying image to show through the masked area. Instead, the + * "masked" areas are rendered on top of the highlighted area in a + * different color. This can be specified for each area (see the + * fillColorMask option below) to create the best possible effect. + */ + noHrefIsMask?: boolean; + + /** + * a jQuery object whose elements are bound to the map. + * + * boundList can be any list of objects. To be bound to the map, they + * must contain an attribute whose name is identified by the option + * listKey, and whose value matches the value in an area tag's mapKey + * attribute. If more than one element in the list has the same value, + * the action will affect all matching elements. + */ + boundList?: JQuery; + + /** + * enable tooltips + * + * When showToolTip is true, mapster will look for a property called + * toolTip in the areas option for a an area. If present, a tool tip + * dialog will be shown on mouseover for that area. It will + * automatically be closed according to the behavior specified by + * toolTipClose. This option does not apply at the item level, but + * rather enables tooltips for the entire map. At the item level, only + * the presence of tooltip data is necessary for a tooltip to appear. + */ + showToolTip?: boolean; + + /** + * HTML describing the popup that will be created for tooltips. + * + * A div with some simple styling is included as the default tooltip + * container. This can be replaced with anything using this option. + * + * When tooltips are rendered, the code attempts to determine the best + * place for it. It will try to position it in near the top-left part + * of the area, and continue to try other corners in order to render it + * within the confines of the container where the image map resides. If + * it can't be placed within the image, it will be placed in the + * lower-right corner and extend outside the image. + */ + toolTipContainer?: string | JQuery; + + /** + * specify the behavior that causes a toolTip to close. + * + * This option should be passed an array of strings that define the + * events that cause active tooltips to close. The array can include + * one or more of the following stings: + * + * 'area-mouseout' - tooltips close when the mouse pointer leaves the + * area that activated it. This is the default. + * + * 'area-click' - tooltips close when another area (or the same one) is + * clicked + * + * 'tooltip-click' - tooltips close when the tooltip itself is clicked + * anywhere + * + * 'image-mouseout' - tooltips close when the mouse pointer leaves the + * image itself. + * + * Under any circumstances, active tooltip will disappear when a new + * one is created. You don't have to define an automatic closing + * behavior; setting this option to an empty array will result in + * tooltips never closing, leaving it to you to close them manually + * though the tooltip method. + */ + toolTipClose?: ToolTipCloseEvent[]; + + /** + * callback when a hotspot area is clicked. Return false to cancel + * default select action, or true to navigate to the 'href' + */ + + /** + * a callback when an area is clicked.:silent doautocmd FocusLost % + * + * This event occurs when the usual click event happens, but includes + * data from the mapster about the area: + * + * This can be used to perform additional actions on a click without + * binding another event and having to obtain information manually. + */ + onClick?: (data: OnClickData) => void; + + /** + * callback when mouse enters a bound area. + * + * This function is called when the mouse enters a bound area. + */ + onMouseover?: (data: OnMouseData) => void; + + /** + * callback when mouse leavesd a bound area. + * + * Callback when the mouse leaves a bound area. The data structure + * passed to the callback is the same as onMouseover. + */ + onMouseout?: (data: OnMouseData) => void; + + /** + * a callback on mapster initialization that provides summary data + * about the image map, and expects a jQuery list to be returned. + * + * This callback allows you to dynamically provide a boundList based on + * summary data from the imagemap itself, rather than providing the + * list up front. The event passes an array of AreaData objects + * + * The client should return a jQuery object containing all the elements + * that make up the bound list, the same as if it was assigned + * manually. + */ + onGetList?: (data: OnGetListData) => JQuery; + + /** + * a callback when the mapster has finished initial configuration + * + * This event is fired when the mapster configuration completes. When + * control execution continues after a first-time bind operation, the + * mapster is not guaranteed to be configured, because images are + * loaded asynchronously by web browsers. If a mapster is bound to an + * image that is not yet loaded, it will attempt to rebind every 200 + * milliseconds. This event will be fired when it is eventually + * successful, or the length of time specified by configTimeout is + * exceeded (default of ten seconds). + * + * The altImage option will also increase the time needed to configure, + * because the alternate image is loaded by the client at configure + * time to ensure it is available immediately when needed. + */ + onConfigured?: (success: boolean) => void; + + /** + * callback when area state is changed (either highlight or select). + * + * onStateChange can be used to get more specific information than the + * mouseover or click events. + */ + onStateChange?: (data: OnStateChangeData) => void; + + /** + * callback when a toolTip is created + * + * This can be used to control tooltip closing behavior directly, if + * desired. + */ + onShowToolTip?: (data: OnShowToolTipData) => void; + } } - interface AreaRenderingOptions extends RenderingOptions { - - key: string; + interface JQuery { /** - * when rendering an area or area group, also render the areas in the - * other group (or groups) specified * - * This is an area-specific option that allows you to create - * supergroups. A supergroup is a collection of groups that will all be - * highlighted simultaneously, but only when the area that defines the - * supergroup is moused over or activated through code. + * All images in the jQuery object will be bound. The specific example + * above will attempt to bind to all images present on the page. Each image + * must be bound to an image map identified with the usemap attribute. If + * there is no usemap attribute, or it does not refer to a valid map, then + * the image will be ignored. Therefore you can use this syntax to activate + * all imagemaps on a page. Because pages often contain many images, + * though, it will be faster to select just the image you are targeting + * using a more specific selector. * - * When the area for which this option has been set is activated, all - * the areas specified in the includeKeys list will also be rendered. - * This is a one-way relationship. Defining a supergroup in an area - * causes all the other groups to be highlighted, but not the other way - * around. + * Images are often not completely loaded when script execution begins. + * ImageMapster will ensure that all images are loaded before it permits + * interaction from the client. If an alternate image is specified, this + * will also be preloaded. * - * A typical use of this is to define areas that you want to be - * highlighted when the mouse enters some specific area, but that you - * do not want to be highlighted on their own if the target area is - * moused over. This could be a hidden menu, for example: you want the - * menu to display when the hotspot is moused over, but when it's - * hidden, mousing over the menu area itself should have no effect. + * Because images are loaded asynchronously, code execution will often + * return to your script before the ImageMapster is available. If you apply + * other methods to it (such as selecting or deselecting areas), these + * commands will be queued until the image has been loaded, and then + * executed automatically. So you don't need to worry about using callbacks + * for initial configuration. You can assign a function to a callback when + * configuration is complete if needed to perform other setup activities on + * the page. */ - includeKeys?: string; + mapster(options?: ImageMapster.Options): JQuery; /** - * the area is a mask rather than a highlighted area. + * select: Cause an area to become selected. This is similar to a user + * click, but will not cause a click event to be fired. * - * Normally, every area in an imagemap is an active area, and would be - * highlighted when moused over (unless its behavior was otherwise - * specified with staticState). The isMask option allows you to - * identify an area as being a mask. When a mask is part of an area - * group, the masked area will be specifically excluded from the - * rendering of a highlight or selected state. + * Programatically select elements from the image map. The programmatic + * selection/deselection methods will not honor the staticState property. + */ + mapster(method: ImageMapster.Select): void; + + /** + * deselect: Cause an area to become deselected * - * This is usually used in conjunction, or instead of, the nohref - * attribute of the area tag. When nohref is specified on an area tag, - * that area is specifically excluded from the hotspot of any area that - * encompasses it. It will not respond to mouse events, and will not be - * highlighted. This can be used to create "holes" in hotspots. By - * default, ImageMapster will treat any area with nohref or no href tag - * as masks, the same as if this option had been applied. + * The opposite of select, this causes an area to become deselected. If it + * was not previously selected, nothing changes. + */ + mapster(method: ImageMapster.Deselect): void; + + /** + * set: select or deselect an area * - * Sometimes you won't be able to use nohref to identify something as a - * mask, for example, if you intend to re-use an area has both a mask, - * and an independent hotspot. This would be typical if you wanted to a - * selectable area that was completely included within another - * selectable area, but functioned independently, such as concentric - * circles. In this case, you would need to identify the inner circle - * as both a mask, and a hotspot. The nohref attribute would make it - * not act as a hotspot, and only function as a mask. You couldn't also - * select the inner area. You can solve this problem by including the - * inner circle in two different groups - one group which is a mask for - * the main area, and another which is an independent selectable area. - * You can specify different options for each group, so even though - * it's just one area, it can function as two completely independent - * ones. + * Select or deselect elements from jQuery objects wrapping "area" tags on + * the map based on truthiness of selected. If the area represents a bound + * area on the imagemap, it will be selected or deselected. The method can + * be called from an AREA, or from a bound image, passing a specific key as + * a 2nd parameter * - * There may also be situations where you do not want an area marked - * with nohref to be treated as a mask. For example, given "area1" and - * "area2," you may want to create a configuration where mousing over - * "area1" causes both "area1" and "area2" to be highlighted, but - * "area2" should not be highlighted on its own when it is moused over. - * In this situation, you'll need to use "nohref" to prevent the hover - * behavior for the area, but you still want it to be treated normally - * when it's rendered as a result of mousing over "area1." You can - * accomplish this using the noHrefIsMask global option, below. + * If the selected parameter is omitted (or anything other than "true" or + * "false") then the state of each area will be toggled. * - * Generally, masked areas will appear as a window to the underlying - * image. If stroke is in effect, the stroke will be rendered for the - * mask as well as the areas, to create both inner and outer borders. - * You can always specifically enable or disable this, or any other - * effect, for any area as desired. + * You can include an object containing rendering options as the last + * parameter. When present, these will supercede the default and + * area-specific rendering options. + */ + mapster(method: ImageMapster.Set, selected: boolean, options: ImageMapster.RenderingOptions): JQuery; + mapster(method: ImageMapster.Set, options: ImageMapster.RenderingOptions): JQuery; + + /** + * get: get keys for all selected areas * + * When no "key" parameter is included, returns a comma-separated list of + * keys representing the areas currently selected. If specified, returns + * true or false indicating whether the area specified is selected. */ - isMask?: boolean; + mapster(method: ImageMapster.Get, key?: string): string | boolean; /** - * tool tip data for an area + * highlight: highlight, clear, or return highlight state * - * When this area-specific option is present and showToolTips = true, a - * toolTipContainer will be created this will be inserted into it, - * either as inner text (if only text as passed) or as HTML if a jQuery - * object is passed. In order to pass anything other than plain text - * using this option you must use a jQuery object. Any string will be - * treated as plain text (and special characters rendered correctly). - */ - toolTip?: string; - } - - interface OnClickData { - - /** - * $(item) from boundList - */ - listTarget?: JQuery; - - /** - * mapKey for this area - */ - key: string; - - e: JQueryEventObject; - selected: boolean; - } - - interface OnStateChangeData { - - /** - * map key - */ - key: string; - - state: "highlight" | "select"; - - /** - * indicating the current state (following the event) - */ - selected: boolean; - } - - interface OnMouseData { - - /** - * area key - */ - key: string; - - /** - * true if area is currently selected - */ - selected: boolean; - - e: JQueryEventObject; - options: AreaRenderingOptions; - } - - interface OnGetListData { - - /** - * primary mapKey for this area or area group - */ - key: string; - - /** - * mapValue for this area or group - */ - value: string; - - /** - * array of areas that make up this group - */ - area: any[]; - - options: AreaRenderingOptions; - } - - interface OnShowToolTipData { - - /** - * jQuery object of the tooltip container - */ - toolTip: JQuery; - - /** - * map key for this area - */ - key: string; - - /** - * current state of the area - */ - selected: boolean; - - areaOptions: AreaRenderingOptions; - } - - interface Options extends RenderingOptions { - - /** - * an attribute identifying each imagemap area. + * This method is used to control or obtain the current highlight state. + * Setting the highlight does not mimic a mouseover, rather, it only sets + * the highlight. Events and tooltips will not be activated. Even using + * these methods, it is not possible to highlight more than one area at a + * time. If another area is highlighted programatically, any existing + * highlight will be removed. * - * If specified, this refers to an attribute on the area tags that will - * be used to group them logically. Any areas containing the same - * mapKey will be considered part of a group, and rendered together - * when any of these areas is activated. If you don't want this - * functionality, ensure each key is unique. When mapKey is omitted, - * then each area is considered to be independent from the other and no - * grouping is applied. - * - * When mapKey is present, any area tags that are missing this - * attribute will be excluded from the image map e ntirely. This is - * functionally identical to setting staticState=false for these areas, - * except they will be inaccessible through the API. - * - * ImageMapster will work with any attribute you identify as a key. If - * you wish to maintain HTML compliance, it's recommeded that you use - * attribute names starting with "data-", for example, data-mapkey. Any - * such names are legal for the HTML5 document type. If you are using - * older document types, the class attribute is part of the HTML spec - * for area and will not cause any visual effects, so this is also a - * good choice. It is not recommended to use id, since the values of - * this attribute must be unique. title and alt also will cause - * possibly undesired side effects. - * - * You can specify more than one value in the mapKey attribute, - * separated by commas. This will cause an area to be a member of more - * than one group. The area may have different options in the context - * of each group. When the area is physically moused over, the first - * key listed will identify the group that's effective for that action. + * Once set this way, the highlight will be removed when any user-event + * that would normally cause a highlight to be removed occurs (e.g. moving + * the mouse into any area), or it is removed programatically. */ - mapKey?: string; + mapster(method: ImageMapster.Highlight, flag?: string | boolean): void; /** - * an attribute on each area tag containing additional descriptive - * information about an area. + * unbind: unbind ImageMapster from an image * - * This option is applicable only when using onGetList. When set, the - * data provided to the callback function will include the value of - * this attribute for each group. This can be used to simplify building - * a list with associated information, without having to match against - * another resource. It also ties this information to the image map - * itself. It is not required to use this option when using onGetList. - * - * For example, you could set mapValue: 'data-statename' to an imagemap - * of the united states, and add an attribute to your areas that - * provided the full name of each state, e.g. data-statename="Alaska". - * This text would be included in the onGetList callback, and so you - * could use it to construct an external list of states. - * - * If there are grouped areas (areas with the same key), then the value - * from the first area found with data in this attribute will be used. - */ - mapValue?: string; - - /** - * Clicking on a link should cause the browser to navigate to the href - * whenever it's not a hash sign (#). Version 1.2.4.050 and later - * - * By default, ImageMapster will prevent the default browser behavior - * in image maps, and "select" areas when they are clicked. If you want - * to navigate to the url for an area, use this option. When enabled, - * all areas that have an href attribute, and its value is not empty or - * "#" (just a hashtag). - * - * When area grouping is used, if an href is present for any area in - * the primary group, this will be used as the navigation target. This - * way you don't need to copy the url for every area in groups, rather, - * you can include it on just one, and clicking any area will cause the - * appropraite navigation. - */ - clickNavigate?: boolean; - - /** - * an attribute on items in a boundList that corresponds to the value - * of the mapKey attributes. - * - * This is used to synchronize the actions on the imagemap with the - * actions on a boundList. Each value should match a value from the - * imageMap mapKey tag. Any item in the boundList with missing or - * mismatched data will be ignored. - */ - listKey?: string; - - /** - * attribute to set or remove when an area is selected or deselected - * - * If boundList is present, when a map area is selected, set or remove - * this attribute on the list element that matches that area based on - * their respective keys. - */ - listSelectedAttribute?: string; - - /** - * a class to add or remove when an area is selected or deselected - * - * If a boundList is present, when a map area is selected, this class - * is added or removed from the corresponding list element. This can be - * used to easily create any kind of associated action when areas on - * the map are changed. - */ - listSelectedClass?: string; - - /** - * - * define area-specific options; each object in the array must contain - * a "key" property identifying a valid mapKey, and additional - * rendering options specific to that area or group - */ - areas?: AreaRenderingOptions[], - - /** - * add "classname" class to the wrapper created around the image, or - * copy classes from the image if "true" - */ - wrapClass?: string | boolean; - - /** - * add CSS to the wrapper created around the image - */ - wrapCss?: string | boolean; - - /** - * delay removing highlight when mouse exits an area (1.2.5b36) - * - * Normally, when the user's mouse pointer exits an area, the highlight - * effect is removed immediately. This behavior can be changed with - * this option. Setting it to a positive number causes a delay of n - * milliseconds before the effect is removed. Setting to -1 causes the - * effect to remain active until another hotspot is entered (e.g., it - * will only be removed when superceded by a different area being - * highlighted). - * - * When using mouseoutDelay, the onMouseover event will still be fired - * at the time the user's mouse pointer leaves the area. However, the - * onStateChange event will be delayed until the highlight is actually + * Removes the ImageMapster binding from an image and restores it to its + * original state. All visible elements (selections, tooltips) will be * removed. * - * Whether or not you are using mouseoutDelay, only one area can be - * highlighted at a time. That is, whenever the mouse pointer moves - * onto a new active area, any previously highlighted area will become - * un-highlighted, regardless of any delay in effect. Hovering over a - * new area will always supercede any delay and cause the new area (and - * only the new area) to be highlighted at that time. So, for dense - * imagemaps where most areas adjoin one another, this option may not - * have much effect within the boundaries of the imagemap. Rather, it - * is intended to help keep the higlights active for imagemaps that are - * sparse, or have very small areas. + * If the optional "preserveState" parameter is true, the selection overlay + * and any active tooltips will be preserved. Tooltips can still be + * dismissed by a user click, but once unbound, the selection states can no + * longer be controlled either by the user or programatically. To remove + * them, the actual DOM elements must be removed. + * + * Notes: When a mapster is first bound, several things happen. A div + * element is created which wraps the image. A copy is made of the original + * image, and the original image is set be transparent. This allows + * creating visible elements for the selections & highlights without + * interfering with the image map. Additionally, canvas elements are + * created (for HTML5 browsers), or a VML elements are created for Internet + * Explorer, to render the effects. Profile information about each bound + * image map is stored in memory, and finally, event handlers are bound to + * the image map. + * + * The "unbind" method cleans up these resources: it removes the wrapper, + * restores the image to its original visibility state, and releases + * internal resources. When using 'preserveState', the internal resources + * are cleaned up and event handling is disabled, but HTML elements are not + * removed. Each element created by ImageMapster is assigned a class of + * "mapster_el", which can be used to target them for later removal, though + * it is not easy to complete this process manually because of the wrapper + * and styles applied during configuration, which will be left intact when + * using "preserveState." */ - mouseoutDelay?: number; + mapster(method: ImageMapster.Unbind, preserveState?: boolean): JQuery; /** - * sort the values before calling onGetList + * snapshot: take a "snapshot" of the current selection state, and reset + * ImageMapster * - * If a non-false value or "asc" is passed, the list will be sorted in - * ascending order by the area value from mapValue. If "desc" is - * passed, the list will be sorted in descending order. + * This option is similar to unbind with preserveState. After a snapshot, + * any active selections will still appear as they did at the time of the + * snapshot, but they are no longer part of the ImageMapster. This is + * useful for configuring an initial state, or creating complex + * representations that may not be easily accomplished with area + * configuration options. + * + * For example, you could bind in image with a specific set of options; + * programatically select some areas; and take a snapshot; then set new + * options that cause a different rendering mode. This way you could have + * certain areas appear differently from the selection highlight, but be + * "highlighted again" using the new rendering options. Any effects in + * place at the time of the snapshot essentially become part of the image + * and are not affected by future operations. */ - sortList?: boolean | "asc" | "desc"; + mapster(method: ImageMapster.Snapshot): JQuery; /** - * time (in milliseconds) to wait for images to load before giving up + * rebind: rebind ImageMapster with new options * - * When first bound, ImageMapster has to wait for the source image,and - * any altImage images to load before it can finish binding. This is - * necessary because otherwise it's not alwasy possible to know the - * native size of the images. After this period of time, ImageMapster - * will give up. If you have particularly large pages or images, you - * may want to increase this to account for long load times. + * This method is similar to set_options, in that its purpose is to change + * options for an existing bound map. However, unlike set_options rebind + * will immediately apply all the new options to the existing map. This + * means that rendering options will change areas that are already selected + * to be rendered with the new options. If you pass area-specific options, + * these will also be applied, e.g. you could cause new areas to be + * selected by passing selected: true in an area specific options. + * + * set_options, in contrast only changes the options, and does not apply + * them to any existing data. When using set_options the new options only + * apply to future actions. */ - configTimeout?: number; + mapster(method: ImageMapster.Rebind, options: ImageMapster.Options): JQuery; /** - * Automatically scale imagemaps to match the size of a - * dynamically-scaled image. + * resize: change the size of the image and map * - * When you render an image, you can optionally define a size through - * CSS or using the "height" and "width" attributes. If omitted, the - * image will be displayed in its native size. If included, browsers - * will automatically resize the image to display in the dimensions you - * have provided. + * This will resize the image map to the dimensions specified. Note that + * either width or height should be passed, and the other will be + * calculated in the same aspect ratio as the original image. If you pass + * both, only the width will be used to calculate the new dimensions: the + * proportions must remain the same as the original image. (Though I intend + * to allow scaling without constraining proportions, it will be difficult + * to make work for certain shapes -- e.g. circles, which would have to + * become ovals). * - * Starting with 1.1.3, ImageMapster will automatically recalculate all - * area data to match the effective size of the image. This means that - * you can set the size of your image to anything you want and - * ImageMapster will work with no changes at all needed to the "area" - * data. + * This method will recalculate and re-render the entire imagemap, so it + * will work exactly the same under the new sizing scheme. When the image + * is unbound, the imagemap will be restored to its original condition. * - * If this behavior is not desired for some reason, this can be - * disabled by setting this option to false. + * When using HTML5 canvases, any existing selections, etc. will be + * preserved during the animation. VML data cannot be resized dynamically, + * however, so in IE<9 the selections will be erased, then redrawn when the + * animation is complete. */ - scaleMap?: boolean; + mapster(method: ImageMapster.Resize, width: number, height: number, duration?: number): JQuery; /** - * Treat areas containing the onhref attribute (or missing the href - * attribute) as masks. This is true by default. + * keys: get the primary mapKey (or comma-separated list of keys) for an + * area, set of areas, or key group. Version 1.2.4.050 * - * Set this to "false" to disable automatic masking of these areas. You - * can control them explicitly by creating independent groups for areas - * you wish to mask and assigning the isMask area-specific option when - * using this option. + * This method allows you to obtain the primary mapKey (or keys) associated + * with another key, or one or more areas. If the all parameter is true, + * the method returns all keys or groups that include the area. * - * There are some things to be aware of when using nohref and masking: + * When using area groups, it is possible for more than one key to be + * associated with a map area. It's also possible for an area to be + * highlighted from code as part of a group, but be inaccessible to the + * end-user. This is because area groups are separate physical entities + * from the areas defined by their primary key. They can have different + * options, and are highlighted independently. Note: the way area groups + * work is not well documented here yet. I am working on a more + * comprehensive tutorial for the site. In the meantime please see this + * example which describes area groups in detail, and shows how they work + * through an active demonstration. * - * * You must put the area that include the nohref attribute before - * other areas that overlap it, or it will be ignored. + * There are reasons you may want to be able to access the primary keys + * that make up an area group directly. Perhaps you want to select a group + * of areas using the options from a group - but not as a separate group. + * Perhaps you want to be able to compare the area clicked against a group + * you have defined to take some action if the area is a member of a + * certain group. This method provides access to that information. * - * * You should also explicitly omit the href tag when using nohref. - * - * * Due to limitations in rendering with VML (e.g. Internet Explorer - * 6-8), it is not possible to create a true mask, which would allow - * the underlying image to show through the masked area. Instead, the - * "masked" areas are rendered on top of the highlighted area in a - * different color. This can be specified for each area (see the - * fillColorMask option below) to create the best possible effect. + * This method allows working with groups in a variety of ways by providing + * access to a complete list of primary keys in any group, or all keys + * which contain a given primary key. */ - noHrefIsMask?: boolean; + mapster(method: ImageMapster.Keys, key: string, all?: boolean): string | string[]; + mapster(method: ImageMapster.Keys, all: boolean): string | string[]; /** - * a jQuery object whose elements are bound to the map. + * set_options: set active options * - * boundList can be any list of objects. To be bound to the map, they - * must contain an attribute whose name is identified by the option - * listKey, and whose value matches the value in an area tag's mapKey - * attribute. If more than one element in the list has the same value, - * the action will affect all matching elements. + * When called without the "options" parameter, returns an object with all + * active options. When the parameter is included, the active options are + * updated for the imagemap, and any area options are merged with existing + * area options. Unlike "rebind", this will not rebind or reapply any + * options, but only update the state. This may affect future actions, but + * it will not change any existing state information. */ - boundList?: JQuery; + mapster(method: ImageMapster.SetOptions, options?: ImageMapster.Options): JQuery; /** - * enable tooltips + * get_options: get active options * - * When showToolTip is true, mapster will look for a property called - * toolTip in the areas option for a an area. If present, a tool tip - * dialog will be shown on mouseover for that area. It will - * automatically be closed according to the behavior specified by - * toolTipClose. This option does not apply at the item level, but - * rather enables tooltips for the entire map. At the item level, only - * the presence of tooltip data is necessary for a tooltip to appear. + * When called with no parameters, returns the options that the mapster was + * configured using. When called with a single key it returns the + * area-specific options assigned to that area. The final parameter + * effective determines whether the actual options in effect for this area, + * or the specific options assigned are returned. + * + * Areas inherit the global options assigned, but can be overridden by + * area-specific options. The "effective" options contain all options + * including those that are inherited, as well as any specifically assigned + * to the area. */ - showToolTip?: boolean; + mapster(method: ImageMapster.GetOptions, key?: string, effective?: boolean): ImageMapster.Options | ImageMapster.AreaRenderingOptions; /** - * HTML describing the popup that will be created for tooltips. + * tooltip: show/hide tooltips from code * - * A div with some simple styling is included as the default tooltip - * container. This can be replaced with anything using this option. + * See the tooltip options section below for options to control how + * tooltips appear and are dismissed. * - * When tooltips are rendered, the code attempts to determine the best - * place for it. It will try to position it in near the top-left part - * of the area, and continue to try other corners in order to render it - * within the confines of the container where the image map resides. If - * it can't be placed within the image, it will be placed in the - * lower-right corner and extend outside the image. + * This method can be used to manipulate tooltips from code. If the global + * showToolTip option is false, these methods will still work, so you have + * the ability to control tooltips bound to areas completely using your own + * logic, if desired. These methods can also be used to have better control + * over events needed to close the tooltip, e.g. you could have no tooltip + * closing event, but add a "close" button to your contianer that will + * cause the tooltip to close when clicked. */ - toolTipContainer?: string | JQuery; - - /** - * specify the behavior that causes a toolTip to close. - * - * This option should be passed an array of strings that define the - * events that cause active tooltips to close. The array can include - * one or more of the following stings: - * - * 'area-mouseout' - tooltips close when the mouse pointer leaves the - * area that activated it. This is the default. - * - * 'area-click' - tooltips close when another area (or the same one) is - * clicked - * - * 'tooltip-click' - tooltips close when the tooltip itself is clicked - * anywhere - * - * 'image-mouseout' - tooltips close when the mouse pointer leaves the - * image itself. - * - * Under any circumstances, active tooltip will disappear when a new - * one is created. You don't have to define an automatic closing - * behavior; setting this option to an empty array will result in - * tooltips never closing, leaving it to you to close them manually - * though the tooltip method. - */ - toolTipClose?: ToolTipCloseEvent[]; - - /** - * callback when a hotspot area is clicked. Return false to cancel - * default select action, or true to navigate to the 'href' - */ - - /** - * a callback when an area is clicked.:silent doautocmd FocusLost % - * - * This event occurs when the usual click event happens, but includes - * data from the mapster about the area: - * - * This can be used to perform additional actions on a click without - * binding another event and having to obtain information manually. - */ - onClick?: (data: OnClickData) => void; - - /** - * callback when mouse enters a bound area. - * - * This function is called when the mouse enters a bound area. - */ - onMouseover?: (data: OnMouseData) => void; - - /** - * callback when mouse leavesd a bound area. - * - * Callback when the mouse leaves a bound area. The data structure - * passed to the callback is the same as onMouseover. - */ - onMouseout?: (data: OnMouseData) => void; - - /** - * a callback on mapster initialization that provides summary data - * about the image map, and expects a jQuery list to be returned. - * - * This callback allows you to dynamically provide a boundList based on - * summary data from the imagemap itself, rather than providing the - * list up front. The event passes an array of AreaData objects - * - * The client should return a jQuery object containing all the elements - * that make up the bound list, the same as if it was assigned - * manually. - */ - onGetList?: (data: OnGetListData) => JQuery; - - /** - * a callback when the mapster has finished initial configuration - * - * This event is fired when the mapster configuration completes. When - * control execution continues after a first-time bind operation, the - * mapster is not guaranteed to be configured, because images are - * loaded asynchronously by web browsers. If a mapster is bound to an - * image that is not yet loaded, it will attempt to rebind every 200 - * milliseconds. This event will be fired when it is eventually - * successful, or the length of time specified by configTimeout is - * exceeded (default of ten seconds). - * - * The altImage option will also increase the time needed to configure, - * because the alternate image is loaded by the client at configure - * time to ensure it is available immediately when needed. - */ - onConfigured?: (success: boolean) => void; - - /** - * callback when area state is changed (either highlight or select). - * - * onStateChange can be used to get more specific information than the - * mouseover or click events. - */ - onStateChange?: (data: OnStateChangeData) => void; - - /** - * callback when a toolTip is created - * - * This can be used to control tooltip closing behavior directly, if - * desired. - */ - onShowToolTip?: (data: OnShowToolTipData) => void; + mapster(method: ImageMapster.Tooltip, key?: string): JQuery; } } - -interface JQuery { - - /** - * - * All images in the jQuery object will be bound. The specific example - * above will attempt to bind to all images present on the page. Each image - * must be bound to an image map identified with the usemap attribute. If - * there is no usemap attribute, or it does not refer to a valid map, then - * the image will be ignored. Therefore you can use this syntax to activate - * all imagemaps on a page. Because pages often contain many images, - * though, it will be faster to select just the image you are targeting - * using a more specific selector. - * - * Images are often not completely loaded when script execution begins. - * ImageMapster will ensure that all images are loaded before it permits - * interaction from the client. If an alternate image is specified, this - * will also be preloaded. - * - * Because images are loaded asynchronously, code execution will often - * return to your script before the ImageMapster is available. If you apply - * other methods to it (such as selecting or deselecting areas), these - * commands will be queued until the image has been loaded, and then - * executed automatically. So you don't need to worry about using callbacks - * for initial configuration. You can assign a function to a callback when - * configuration is complete if needed to perform other setup activities on - * the page. - */ - mapster(options?: ImageMapster.Options): JQuery; - - /** - * select: Cause an area to become selected. This is similar to a user - * click, but will not cause a click event to be fired. - * - * Programatically select elements from the image map. The programmatic - * selection/deselection methods will not honor the staticState property. - */ - mapster(method: ImageMapster.Select): void; - - /** - * deselect: Cause an area to become deselected - * - * The opposite of select, this causes an area to become deselected. If it - * was not previously selected, nothing changes. - */ - mapster(method: ImageMapster.Deselect): void; - - /** - * set: select or deselect an area - * - * Select or deselect elements from jQuery objects wrapping "area" tags on - * the map based on truthiness of selected. If the area represents a bound - * area on the imagemap, it will be selected or deselected. The method can - * be called from an AREA, or from a bound image, passing a specific key as - * a 2nd parameter - * - * If the selected parameter is omitted (or anything other than "true" or - * "false") then the state of each area will be toggled. - * - * You can include an object containing rendering options as the last - * parameter. When present, these will supercede the default and - * area-specific rendering options. - */ - mapster(method: ImageMapster.Set, selected: boolean, options: ImageMapster.RenderingOptions): JQuery; - mapster(method: ImageMapster.Set, options: ImageMapster.RenderingOptions): JQuery; - - /** - * get: get keys for all selected areas - * - * When no "key" parameter is included, returns a comma-separated list of - * keys representing the areas currently selected. If specified, returns - * true or false indicating whether the area specified is selected. - */ - mapster(method: ImageMapster.Get, key?: string): string | boolean; - - /** - * highlight: highlight, clear, or return highlight state - * - * This method is used to control or obtain the current highlight state. - * Setting the highlight does not mimic a mouseover, rather, it only sets - * the highlight. Events and tooltips will not be activated. Even using - * these methods, it is not possible to highlight more than one area at a - * time. If another area is highlighted programatically, any existing - * highlight will be removed. - * - * Once set this way, the highlight will be removed when any user-event - * that would normally cause a highlight to be removed occurs (e.g. moving - * the mouse into any area), or it is removed programatically. - */ - mapster(method: ImageMapster.Highlight, flag?: string | boolean): void; - - /** - * unbind: unbind ImageMapster from an image - * - * Removes the ImageMapster binding from an image and restores it to its - * original state. All visible elements (selections, tooltips) will be - * removed. - * - * If the optional "preserveState" parameter is true, the selection overlay - * and any active tooltips will be preserved. Tooltips can still be - * dismissed by a user click, but once unbound, the selection states can no - * longer be controlled either by the user or programatically. To remove - * them, the actual DOM elements must be removed. - * - * Notes: When a mapster is first bound, several things happen. A div - * element is created which wraps the image. A copy is made of the original - * image, and the original image is set be transparent. This allows - * creating visible elements for the selections & highlights without - * interfering with the image map. Additionally, canvas elements are - * created (for HTML5 browsers), or a VML elements are created for Internet - * Explorer, to render the effects. Profile information about each bound - * image map is stored in memory, and finally, event handlers are bound to - * the image map. - * - * The "unbind" method cleans up these resources: it removes the wrapper, - * restores the image to its original visibility state, and releases - * internal resources. When using 'preserveState', the internal resources - * are cleaned up and event handling is disabled, but HTML elements are not - * removed. Each element created by ImageMapster is assigned a class of - * "mapster_el", which can be used to target them for later removal, though - * it is not easy to complete this process manually because of the wrapper - * and styles applied during configuration, which will be left intact when - * using "preserveState." - */ - mapster(method: ImageMapster.Unbind, preserveState?: boolean): JQuery; - - /** - * snapshot: take a "snapshot" of the current selection state, and reset - * ImageMapster - * - * This option is similar to unbind with preserveState. After a snapshot, - * any active selections will still appear as they did at the time of the - * snapshot, but they are no longer part of the ImageMapster. This is - * useful for configuring an initial state, or creating complex - * representations that may not be easily accomplished with area - * configuration options. - * - * For example, you could bind in image with a specific set of options; - * programatically select some areas; and take a snapshot; then set new - * options that cause a different rendering mode. This way you could have - * certain areas appear differently from the selection highlight, but be - * "highlighted again" using the new rendering options. Any effects in - * place at the time of the snapshot essentially become part of the image - * and are not affected by future operations. - */ - mapster(method: ImageMapster.Snapshot): JQuery; - - /** - * rebind: rebind ImageMapster with new options - * - * This method is similar to set_options, in that its purpose is to change - * options for an existing bound map. However, unlike set_options rebind - * will immediately apply all the new options to the existing map. This - * means that rendering options will change areas that are already selected - * to be rendered with the new options. If you pass area-specific options, - * these will also be applied, e.g. you could cause new areas to be - * selected by passing selected: true in an area specific options. - * - * set_options, in contrast only changes the options, and does not apply - * them to any existing data. When using set_options the new options only - * apply to future actions. - */ - mapster(method: ImageMapster.Rebind, options: ImageMapster.Options): JQuery; - - /** - * resize: change the size of the image and map - * - * This will resize the image map to the dimensions specified. Note that - * either width or height should be passed, and the other will be - * calculated in the same aspect ratio as the original image. If you pass - * both, only the width will be used to calculate the new dimensions: the - * proportions must remain the same as the original image. (Though I intend - * to allow scaling without constraining proportions, it will be difficult - * to make work for certain shapes -- e.g. circles, which would have to - * become ovals). - * - * This method will recalculate and re-render the entire imagemap, so it - * will work exactly the same under the new sizing scheme. When the image - * is unbound, the imagemap will be restored to its original condition. - * - * When using HTML5 canvases, any existing selections, etc. will be - * preserved during the animation. VML data cannot be resized dynamically, - * however, so in IE<9 the selections will be erased, then redrawn when the - * animation is complete. - */ - mapster(method: ImageMapster.Resize, width: number, height: number, duration?: number): JQuery; - - /** - * keys: get the primary mapKey (or comma-separated list of keys) for an - * area, set of areas, or key group. Version 1.2.4.050 - * - * This method allows you to obtain the primary mapKey (or keys) associated - * with another key, or one or more areas. If the all parameter is true, - * the method returns all keys or groups that include the area. - * - * When using area groups, it is possible for more than one key to be - * associated with a map area. It's also possible for an area to be - * highlighted from code as part of a group, but be inaccessible to the - * end-user. This is because area groups are separate physical entities - * from the areas defined by their primary key. They can have different - * options, and are highlighted independently. Note: the way area groups - * work is not well documented here yet. I am working on a more - * comprehensive tutorial for the site. In the meantime please see this - * example which describes area groups in detail, and shows how they work - * through an active demonstration. - * - * There are reasons you may want to be able to access the primary keys - * that make up an area group directly. Perhaps you want to select a group - * of areas using the options from a group - but not as a separate group. - * Perhaps you want to be able to compare the area clicked against a group - * you have defined to take some action if the area is a member of a - * certain group. This method provides access to that information. - * - * This method allows working with groups in a variety of ways by providing - * access to a complete list of primary keys in any group, or all keys - * which contain a given primary key. - */ - mapster(method: ImageMapster.Keys, key: string, all?: boolean): string | string[]; - mapster(method: ImageMapster.Keys, all: boolean): string | string[]; - - /** - * set_options: set active options - * - * When called without the "options" parameter, returns an object with all - * active options. When the parameter is included, the active options are - * updated for the imagemap, and any area options are merged with existing - * area options. Unlike "rebind", this will not rebind or reapply any - * options, but only update the state. This may affect future actions, but - * it will not change any existing state information. - */ - mapster(method: ImageMapster.SetOptions, options?: ImageMapster.Options): JQuery; - - /** - * get_options: get active options - * - * When called with no parameters, returns the options that the mapster was - * configured using. When called with a single key it returns the - * area-specific options assigned to that area. The final parameter - * effective determines whether the actual options in effect for this area, - * or the specific options assigned are returned. - * - * Areas inherit the global options assigned, but can be overridden by - * area-specific options. The "effective" options contain all options - * including those that are inherited, as well as any specifically assigned - * to the area. - */ - mapster(method: ImageMapster.GetOptions, key?: string, effective?: boolean): ImageMapster.Options | ImageMapster.AreaRenderingOptions; - - /** - * tooltip: show/hide tooltips from code - * - * See the tooltip options section below for options to control how - * tooltips appear and are dismissed. - * - * This method can be used to manipulate tooltips from code. If the global - * showToolTip option is false, these methods will still work, so you have - * the ability to control tooltips bound to areas completely using your own - * logic, if desired. These methods can also be used to have better control - * over events needed to close the tooltip, e.g. you could have no tooltip - * closing event, but add a "close" button to your contianer that will - * cause the tooltip to close when clicked. - */ - mapster(method: ImageMapster.Tooltip, key?: string): JQuery; -} diff --git a/types/jake/index.d.ts b/types/jake/index.d.ts index 98fc72d148..29385edcdc 100644 --- a/types/jake/index.d.ts +++ b/types/jake/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/mde/jake // Definitions by: Kon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// diff --git a/types/jquery-easy-loading/index.d.ts b/types/jquery-easy-loading/index.d.ts index 72ab6cd65d..9498e6ac9a 100644 --- a/types/jquery-easy-loading/index.d.ts +++ b/types/jquery-easy-loading/index.d.ts @@ -2,6 +2,9 @@ // Project: http://carlosbonetti.github.io/jquery-loading/ // Definitions by: delphinus // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// declare namespace JQueryEasyLoading { diff --git a/types/jquery-easy-loading/jquery-easy-loading-tests.ts b/types/jquery-easy-loading/jquery-easy-loading-tests.ts index ece98fd6d0..b8c6ac219c 100644 --- a/types/jquery-easy-loading/jquery-easy-loading-tests.ts +++ b/types/jquery-easy-loading/jquery-easy-loading-tests.ts @@ -35,7 +35,6 @@ function test_commands() { .loading("toggle"); } -import * as jQuery from "jquery"; import * as factory from "jquery-easy-loading"; function test_factory() { diff --git a/types/jquery-easy-loading/tsconfig.json b/types/jquery-easy-loading/tsconfig.json index efe892fc96..9e16b77cbf 100644 --- a/types/jquery-easy-loading/tsconfig.json +++ b/types/jquery-easy-loading/tsconfig.json @@ -12,11 +12,6 @@ "typeRoots": [ "../" ], - "paths": { - "jquery": [ - "jquery/v2" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/jquery-mockjax/index.d.ts b/types/jquery-mockjax/index.d.ts index f5dc5c8db1..2e8441131f 100644 --- a/types/jquery-mockjax/index.d.ts +++ b/types/jquery-mockjax/index.d.ts @@ -2,6 +2,9 @@ // Project: https://github.com/jakerella/jquery-mockjax // Definitions by: Laszlo Jakab , Vladimir Đokić // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// interface MockJaxSettingsHeaders { [key: string]: string; diff --git a/types/jquery-mockjax/jquery-mockjax-tests.ts b/types/jquery-mockjax/jquery-mockjax-tests.ts index a0df96dad6..3090a1c3cc 100644 --- a/types/jquery-mockjax/jquery-mockjax-tests.ts +++ b/types/jquery-mockjax/jquery-mockjax-tests.ts @@ -1,7 +1,5 @@ /// -import $ = require('jquery'); - class Tests { private _noErrorCallbackExpected: (jqXHR: JQueryXHR, textStatus: string, errorThrown: string) => any; private _defaultMockjaxSettings: MockJaxSettings; diff --git a/types/jquery-mockjax/tsconfig.json b/types/jquery-mockjax/tsconfig.json index 5fcedf714e..660cf14287 100644 --- a/types/jquery-mockjax/tsconfig.json +++ b/types/jquery-mockjax/tsconfig.json @@ -12,11 +12,6 @@ "typeRoots": [ "../" ], - "paths": { - "jquery": [ - "jquery/v2" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/jquery.bbq/index.d.ts b/types/jquery.bbq/index.d.ts index 1860d63343..7040200d11 100644 --- a/types/jquery.bbq/index.d.ts +++ b/types/jquery.bbq/index.d.ts @@ -3,156 +3,160 @@ // Definitions by: Adam R. Smith // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace JQueryBbq { +import $ = require('jquery'); + +declare global { + namespace JQueryBbq { + + interface JQuery { + /** + * Adds a 'state' into the browser history at the current position, setting + * location.hash and triggering any bound callbacks + * (provided the new state is different than the previous state). + * + * @name params A serialized params string or a hash string beginning with # to merge into location.hash. + * @name merge_mode Merge behavior defaults to 0 if merge_mode is not specified (unless a hash string beginning with # is specified, in which case merge behavior defaults to 2) + */ + pushState(params?: string, merge_mode?: number): void; + + pushState(params?: any, merge_mode?: number): void; + + /** + * Retrieves the current 'state' from the browser history, parsing + * location.hash for a specific key or returning an object containing the + * entire state, optionally coercing numbers, booleans, null and undefined + * values. + * + * @name key An optional state key for which to return a value. + * @name coerce If true, coerces any numbers or true, false, null, and undefined to their actual value. Defaults to false + */ + getState(key?: string, coerce?: boolean): any; + + getState(coerce?: boolean): any; + + /** + * Remove one or more keys from the current browser history 'state', creating + * a new state, setting location.hash and triggering any bound + * callbacks (provided the new state is different than + * the previous state). + * + * @name key One or more key values to remove from the current state. + */ + removeState(...key: any[]): void; + } + + interface ParamFragment { + (url?: string): string; + + (url: string, params: any, merge_mode?: number): string; + + /** + * Specify characters that will be left unescaped when fragments are created + * or merged using , or when the fragment is modified + * using . This option only applies to serialized data + * object fragments, and not set-as-string fragments. Does not affect the + * query string. Defaults to ",/" (comma, forward slash). + * + * @name chars The characters to not escape in the fragment. If unspecified, defaults to empty string (escape all characters). + */ + noEscape: (chars?: string) => void; + + /** + * TODO: DESCRIBE + * + * @name state TODO: DESCRIBE + */ + ajaxCrawlable(state?: boolean): boolean; + } + + interface JQueryDeparam { + /** + * Deserialize a params string into an object, optionally coercing numbers, + * booleans, null and undefined values; this method is the counterpart to the + * internal jQuery.param method. + * + * @name params A params string to be parsed. + * @name coerce If true, coerces any numbers or true, false, null, and undefined to their actual value. Defaults to false if omitted. + */ + (params: string, coerce?: boolean): any; + + + /** + * Parse the query string from a URL or the current window.location.href, + * deserializing it into an object, optionally coercing numbers, booleans, + * null and undefined values. + * + * @name url An optional params string or URL containing query string params to be parsed. If url is omitted, the current window.location.href is used. + * @name coerce If true, coerces any numbers or true, false, null, and undefined to their actual value. Defaults to false if omitted. + */ + querystring(url?: string, coerce?: boolean): any; + + /** + * Parse the fragment (hash) from a URL or the current window.location.href, + * deserializing it into an object, optionally coercing numbers, booleans, + * null and undefined values. + * + * @name url An optional params string or URL containing fragment (hash) params to be parsed. If url is omitted, the current window.location.href is used. + * @name coerce If true, coerces any numbers or true, false, null, and undefined to their actual value. Defaults to false if omitted. + */ + fragment(url?: string, coerce?: boolean): any; + } + + interface EventObject extends JQueryEventObject { + fragment: string; + + getState(key?: string, coerce?: boolean); + } + } + + interface JQueryParam { + /** + * Parse the query string from a URL or the current window.location.href, + * deserializing it into an object, optionally coercing numbers, booleans, + * null and undefined values. + * + * @name url An optional params string or URL containing query string params to be parsed. If url is omitted, the current window.location.href is used. + * @name coerce (Boolean) If true, coerces any numbers or true, false, null, and undefined to their actual value. Defaults to false if omitted. + * @name merge_mode An object representing the deserialized params string. + */ + querystring(url?: string, coerce?: boolean, merge_mode?: number): string; + + querystring(url?: string, coerce?: any, merge_mode?: number): string; + + fragment: JQueryBbq.ParamFragment; + + /** + * Returns a params string equivalent to that returned by the internal + * jQuery.param method, but sorted, which makes it suitable for use as a + * cache key. + * + * @name obj An object to be serialized. + * @name traditional Params deep/shallow serialization mode. See the documentation at http://api.jquery.com/jQuery.param/ for more detail. + */ + sorted(obj: any, traditional?: boolean): string; + } + + interface JQueryStatic { + bbq: JQueryBbq.JQuery; + + deparam: JQueryBbq.JQueryDeparam; + + /** + * Get the internal "Default URL attribute per tag" list, or augment the list + * with additional tag-attribute pairs, in case the defaults are insufficient. + * + * @name tag_attr An object containing a list of tag names and their associated default attribute names in the format { tag: 'attr', ... } to be merged into the internal tag-attribute list. + */ + elemUrlAttr(tag_attr?: any): any; + } interface JQuery { - /** - * Adds a 'state' into the browser history at the current position, setting - * location.hash and triggering any bound callbacks - * (provided the new state is different than the previous state). - * - * @name params A serialized params string or a hash string beginning with # to merge into location.hash. - * @name merge_mode Merge behavior defaults to 0 if merge_mode is not specified (unless a hash string beginning with # is specified, in which case merge behavior defaults to 2) - */ - pushState(params?: string, merge_mode?: number): void; + querystring(attr?: any, params?: any, merge_mode?: number): JQuery; - pushState(params?: any, merge_mode?: number): void; + fragment(attr?: any, params?: any, merge_mode?: number): JQuery; - /** - * Retrieves the current 'state' from the browser history, parsing - * location.hash for a specific key or returning an object containing the - * entire state, optionally coercing numbers, booleans, null and undefined - * values. - * - * @name key An optional state key for which to return a value. - * @name coerce If true, coerces any numbers or true, false, null, and undefined to their actual value. Defaults to false - */ - getState(key?: string, coerce?: boolean): any; + hashchange(eventData?: any, handler?: (eventObject: JQueryBbq.EventObject) => any): JQuery; - getState(coerce?: boolean): any; - - /** - * Remove one or more keys from the current browser history 'state', creating - * a new state, setting location.hash and triggering any bound - * callbacks (provided the new state is different than - * the previous state). - * - * @name key One or more key values to remove from the current state. - */ - removeState(...key: any[]): void; - } - - interface ParamFragment { - (url?: string): string; - - (url: string, params: any, merge_mode?: number): string; - - /** - * Specify characters that will be left unescaped when fragments are created - * or merged using , or when the fragment is modified - * using . This option only applies to serialized data - * object fragments, and not set-as-string fragments. Does not affect the - * query string. Defaults to ",/" (comma, forward slash). - * - * @name chars The characters to not escape in the fragment. If unspecified, defaults to empty string (escape all characters). - */ - noEscape: (chars?: string) => void; - - /** - * TODO: DESCRIBE - * - * @name state TODO: DESCRIBE - */ - ajaxCrawlable(state?: boolean): boolean; - } - - interface JQueryDeparam { - /** - * Deserialize a params string into an object, optionally coercing numbers, - * booleans, null and undefined values; this method is the counterpart to the - * internal jQuery.param method. - * - * @name params A params string to be parsed. - * @name coerce If true, coerces any numbers or true, false, null, and undefined to their actual value. Defaults to false if omitted. - */ - (params: string, coerce?: boolean): any; - - - /** - * Parse the query string from a URL or the current window.location.href, - * deserializing it into an object, optionally coercing numbers, booleans, - * null and undefined values. - * - * @name url An optional params string or URL containing query string params to be parsed. If url is omitted, the current window.location.href is used. - * @name coerce If true, coerces any numbers or true, false, null, and undefined to their actual value. Defaults to false if omitted. - */ - querystring(url?: string, coerce?: boolean): any; - - /** - * Parse the fragment (hash) from a URL or the current window.location.href, - * deserializing it into an object, optionally coercing numbers, booleans, - * null and undefined values. - * - * @name url An optional params string or URL containing fragment (hash) params to be parsed. If url is omitted, the current window.location.href is used. - * @name coerce If true, coerces any numbers or true, false, null, and undefined to their actual value. Defaults to false if omitted. - */ - fragment(url?: string, coerce?: boolean): any; - } - - interface EventObject extends JQueryEventObject { - fragment: string; - - getState(key?: string, coerce?: boolean); + hashchange(handler: (eventObject: JQueryBbq.EventObject) => any): JQuery; } } - -interface JQueryParam { - /** - * Parse the query string from a URL or the current window.location.href, - * deserializing it into an object, optionally coercing numbers, booleans, - * null and undefined values. - * - * @name url An optional params string or URL containing query string params to be parsed. If url is omitted, the current window.location.href is used. - * @name coerce (Boolean) If true, coerces any numbers or true, false, null, and undefined to their actual value. Defaults to false if omitted. - * @name merge_mode An object representing the deserialized params string. - */ - querystring(url?: string, coerce?: boolean, merge_mode?: number): string; - - querystring(url?: string, coerce?: any, merge_mode?: number): string; - - fragment: JQueryBbq.ParamFragment; - - /** - * Returns a params string equivalent to that returned by the internal - * jQuery.param method, but sorted, which makes it suitable for use as a - * cache key. - * - * @name obj An object to be serialized. - * @name traditional Params deep/shallow serialization mode. See the documentation at http://api.jquery.com/jQuery.param/ for more detail. - */ - sorted(obj: any, traditional?: boolean): string; -} - -interface JQueryStatic { - bbq: JQueryBbq.JQuery; - - deparam: JQueryBbq.JQueryDeparam; - - /** - * Get the internal "Default URL attribute per tag" list, or augment the list - * with additional tag-attribute pairs, in case the defaults are insufficient. - * - * @name tag_attr An object containing a list of tag names and their associated default attribute names in the format { tag: 'attr', ... } to be merged into the internal tag-attribute list. - */ - elemUrlAttr(tag_attr?: any): any; -} - -interface JQuery { - querystring(attr?: any, params?: any, merge_mode?: number): JQuery; - - fragment(attr?: any, params?: any, merge_mode?: number): JQuery; - - hashchange(eventData?: any, handler?: (eventObject: JQueryBbq.EventObject) => any): JQuery; - - hashchange(handler: (eventObject: JQueryBbq.EventObject) => any): JQuery; -} diff --git a/types/jquery.clientsidelogging/index.d.ts b/types/jquery.clientsidelogging/index.d.ts index f0548b89b2..896e921e23 100644 --- a/types/jquery.clientsidelogging/index.d.ts +++ b/types/jquery.clientsidelogging/index.d.ts @@ -2,6 +2,9 @@ // Project: https://github.com/remybach/jQuery.clientSideLogging // Definitions by: Diullei Gomes // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// interface ClientSideLoggingClientInfoObject { location?: boolean; // The url to the page on which the error occurred. @@ -23,6 +26,7 @@ interface ClientSideLoggingObject { interface JQueryStatic { info: (what?: any) => any; + error(what?: any): any; log: (what?: any) => any; clientSideLogging: (options: ClientSideLoggingObject) => any; } diff --git a/types/jquery.clientsidelogging/jquery.clientsidelogging-tests.ts b/types/jquery.clientsidelogging/jquery.clientsidelogging-tests.ts index f23b9acb25..24cba342f7 100644 --- a/types/jquery.clientsidelogging/jquery.clientsidelogging-tests.ts +++ b/types/jquery.clientsidelogging/jquery.clientsidelogging-tests.ts @@ -1,5 +1,3 @@ -import $ = require('jquery'); - $.clientSideLogging({ log_level: 3, client_info: { diff --git a/types/jquery.clientsidelogging/tsconfig.json b/types/jquery.clientsidelogging/tsconfig.json index db54f5cd84..5a94a133b5 100644 --- a/types/jquery.clientsidelogging/tsconfig.json +++ b/types/jquery.clientsidelogging/tsconfig.json @@ -12,11 +12,6 @@ "typeRoots": [ "../" ], - "paths": { - "jquery": [ - "jquery/v2" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/jquery.fancytree/index.d.ts b/types/jquery.fancytree/index.d.ts index e2c79b0341..f4e6ac7be8 100644 --- a/types/jquery.fancytree/index.d.ts +++ b/types/jquery.fancytree/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for jquery.fancytree 2.7.0 // Project: https://github.com/mar10/fancytree // Definitions by: Peter Palotas +// Mahdi Abedi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -721,6 +722,8 @@ declare namespace Fancytree { restore?(event: JQueryEventObject, data: EventData): void; /** `data.node` was selected */ select?(event: JQueryEventObject, data: EventData): void; + /** Enable RTL version, default is false */ + rtl?: boolean; } interface FancytreeOptions extends FancytreeEvents { diff --git a/types/jquery.joyride/index.d.ts b/types/jquery.joyride/index.d.ts index 05e5b5e2d9..d67262f4af 100644 --- a/types/jquery.joyride/index.d.ts +++ b/types/jquery.joyride/index.d.ts @@ -3,269 +3,272 @@ // Definitions by: Vincent Bortone // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/** -* HTML segments for tip layout -*/ -interface JoyrideTemplate { - /** - * Link template - * @member {string} - */ - link?: string; +import $ = require('jquery'); +declare global { /** - * Timer template - * @member {string} - */ - timer?: string; + * HTML segments for tip layout + */ + interface JoyrideTemplate { + /** + * Link template + * @member {string} + */ + link?: string; - /** - * Tip template - * @member {string} - */ - tip?: string; + /** + * Timer template + * @member {string} + */ + timer?: string; - /** - * Wrapper template - * @member {string} - */ - wrapper?: string; + /** + * Tip template + * @member {string} + */ + tip?: string; - /** - * Button template - * @member {string} - */ - button?: string; + /** + * Wrapper template + * @member {string} + */ + wrapper?: string; - /** - * Modal template - * @member {string} - */ - modal?: string; + /** + * Button template + * @member {string} + */ + button?: string; - /** - * Exposed Cover template - * @member {string} - */ - exposeCover?: string; -} - -interface JoyrideOptions { - /** - * Version - * @member {string} - */ - version?: string; - - /** - * 'top' or 'bottom' in relation to parent - * @member {string} - */ - tipLocation?: string; - - /** - * override on a per tooltip bases - * @member {any} - */ - nubPosition?: any; - - /** - * whether to scroll to tips - * @member {boolean} - */ - scroll?: boolean; - - /** - * Page scrolling speed in ms - * @member {number} - */ - scrollSpeed?: number; - - /** - * 0 = off, all other numbers = time(ms) - * @member {number} - */ - timer?: number; - - /** - * true or false - false tour starts when restart called - * @member {boolean} - */ - autoStart?: boolean; - - /** - * true/false to start timer on first click - * @member {boolean} - */ - startTimerOnClick?: boolean; - - /** - * the index of the tooltip you want to start on (index of the li) - * @member {number} - */ - startOffset?: number; - - /** - * true/false for next button visibility - * @member {boolean} - */ - nextButton?: boolean; - - /** - * 'pop' or 'fade' in each tip - * @member {string} - */ - tipAnimation?: string; - - /** - * array of indexes where to pause the tour after - * @member {any[]} - */ - pauseAfter?: any[]; - - /** - * if 'fade'- speed in ms of transition - * @member {number} - */ - tipAnimationFadeSpeed?: number; - - /** - * true/false for whether cookies are used - * @member {boolean} - */ - cookieMonster?: boolean; - - /** - * choose your own cookie name - * member {string} - */ - cookieName?: string; - - /** - * Will this cookie be attached to a domain, ie. '.notableapp.com' - * @member {any} - */ - cookieDomain?: any; - - /** - * Set to '/' if you want the cookie for the whole website - * @member {any} - */ - cookiePath?: any; - - /** - * true or false to control whether localstorage is used - * @member {boolean} - */ - localStorage?: boolean; - - /** - * Keyname in localstorage - @member {string} - */ - localStorageKey?: string; - - /** - * Where the tip be attached if not inline - * @member {HTMLElement} - */ - tipContainer?: HTMLElement; - - /** - * Whether to cover page with modal during the tour - * @member {boolean} - */ - modal?: boolean; - - /** - * Whether to expose the elements at each step in the tour (requires modal:true) - * @member {boolean} - */ - expose?: boolean; - - /** - * A method to call after an element has been exposed - * @method - * @param {number} index Tip Index - * @param {JQuery} nextTip Tip object - * @param {JQuery} el Element - */ - postExposeCallback?: (index: number, nextTip: JQuery, el?: JQuery) => void; - - /** - * A method to call before the tour starts (passed index, tip, and cloned exposed element) - * @method - * @param {number} index Current Tip Index - * @param {JQuery} currentTip Current Tip object - * @param {JQuery} el Element - */ - preRideCallback?: (index: number, currentTip: JQuery, el?: JQuery) => void; - - /** - * a method to call once the tour closes - * @method - * @param {number} index Current Tip Index - * @param {JQuery} currentTip Current Tip object - * @param {boolean} isAborted Is Aborted? - */ - postRideCallback?: (index: number, currentTip: JQuery, isAborted?: boolean) => void; - - /** - * A method to call after each step - * @method - * @param {number} index Current Tip Index - * @param {JQuery} currentTip Current Tip object - * @param {boolean} isAborted Is Aborted? - */ - postStepCallback?: (index: number, currentTip: JQuery, isAborted?: boolean) => void; - - /** - * A method to call before each step - * @method - * @param {number} index Tip Index - * @param {JQuery} nextTip Tip object - * @param {JQuery} el Element - */ - preStepCallback?: (index: number, nextTip: JQuery, el?: JQuery) => void; - - /** - * HTML segments for tip layout - * @member {JoyrideTemplate} - */ - template?: JoyrideTemplate; -} - -interface Joyride -{ - /** - * Default function, no options - * @method - * @return {JQuery} JQuery instance - */ - (): JQuery; - - /** - * Function with options - * @method - * @param {JoyrideOptions} options An object with all the joyride options you want to overwrite. - * @return {JQuery} JQuery instance - */ - (options: JoyrideOptions): JQuery; - - /** - * Function with method name and params - * @method - * @param {string} methodName Name of method to call. - * @param {any[]} params parameters for method - * @return {JQuery} JQuery instance - */ - (methodName: string, ...params: any[]): JQuery; -} - -interface JQuery { - /** - * joyride function - * @return {Joyride} Joyride instance. - */ - joyride: Joyride; + /** + * Modal template + * @member {string} + */ + modal?: string; + + /** + * Exposed Cover template + * @member {string} + */ + exposeCover?: string; + } + + interface JoyrideOptions { + /** + * Version + * @member {string} + */ + version?: string; + + /** + * 'top' or 'bottom' in relation to parent + * @member {string} + */ + tipLocation?: string; + + /** + * override on a per tooltip bases + * @member {any} + */ + nubPosition?: any; + + /** + * whether to scroll to tips + * @member {boolean} + */ + scroll?: boolean; + + /** + * Page scrolling speed in ms + * @member {number} + */ + scrollSpeed?: number; + + /** + * 0 = off, all other numbers = time(ms) + * @member {number} + */ + timer?: number; + + /** + * true or false - false tour starts when restart called + * @member {boolean} + */ + autoStart?: boolean; + + /** + * true/false to start timer on first click + * @member {boolean} + */ + startTimerOnClick?: boolean; + + /** + * the index of the tooltip you want to start on (index of the li) + * @member {number} + */ + startOffset?: number; + + /** + * true/false for next button visibility + * @member {boolean} + */ + nextButton?: boolean; + + /** + * 'pop' or 'fade' in each tip + * @member {string} + */ + tipAnimation?: string; + + /** + * array of indexes where to pause the tour after + * @member {any[]} + */ + pauseAfter?: any[]; + + /** + * if 'fade'- speed in ms of transition + * @member {number} + */ + tipAnimationFadeSpeed?: number; + + /** + * true/false for whether cookies are used + * @member {boolean} + */ + cookieMonster?: boolean; + + /** + * choose your own cookie name + * member {string} + */ + cookieName?: string; + + /** + * Will this cookie be attached to a domain, ie. '.notableapp.com' + * @member {any} + */ + cookieDomain?: any; + + /** + * Set to '/' if you want the cookie for the whole website + * @member {any} + */ + cookiePath?: any; + + /** + * true or false to control whether localstorage is used + * @member {boolean} + */ + localStorage?: boolean; + + /** + * Keyname in localstorage + @member {string} + */ + localStorageKey?: string; + + /** + * Where the tip be attached if not inline + * @member {HTMLElement} + */ + tipContainer?: HTMLElement; + + /** + * Whether to cover page with modal during the tour + * @member {boolean} + */ + modal?: boolean; + + /** + * Whether to expose the elements at each step in the tour (requires modal:true) + * @member {boolean} + */ + expose?: boolean; + + /** + * A method to call after an element has been exposed + * @method + * @param {number} index Tip Index + * @param {JQuery} nextTip Tip object + * @param {JQuery} el Element + */ + postExposeCallback?: (index: number, nextTip: JQuery, el?: JQuery) => void; + + /** + * A method to call before the tour starts (passed index, tip, and cloned exposed element) + * @method + * @param {number} index Current Tip Index + * @param {JQuery} currentTip Current Tip object + * @param {JQuery} el Element + */ + preRideCallback?: (index: number, currentTip: JQuery, el?: JQuery) => void; + + /** + * a method to call once the tour closes + * @method + * @param {number} index Current Tip Index + * @param {JQuery} currentTip Current Tip object + * @param {boolean} isAborted Is Aborted? + */ + postRideCallback?: (index: number, currentTip: JQuery, isAborted?: boolean) => void; + + /** + * A method to call after each step + * @method + * @param {number} index Current Tip Index + * @param {JQuery} currentTip Current Tip object + * @param {boolean} isAborted Is Aborted? + */ + postStepCallback?: (index: number, currentTip: JQuery, isAborted?: boolean) => void; + + /** + * A method to call before each step + * @method + * @param {number} index Tip Index + * @param {JQuery} nextTip Tip object + * @param {JQuery} el Element + */ + preStepCallback?: (index: number, nextTip: JQuery, el?: JQuery) => void; + + /** + * HTML segments for tip layout + * @member {JoyrideTemplate} + */ + template?: JoyrideTemplate; + } + + interface Joyride { + /** + * Default function, no options + * @method + * @return {JQuery} JQuery instance + */ + (): JQuery; + + /** + * Function with options + * @method + * @param {JoyrideOptions} options An object with all the joyride options you want to overwrite. + * @return {JQuery} JQuery instance + */ + (options: JoyrideOptions): JQuery; + + /** + * Function with method name and params + * @method + * @param {string} methodName Name of method to call. + * @param {any[]} params parameters for method + * @return {JQuery} JQuery instance + */ + (methodName: string, ...params: any[]): JQuery; + } + + interface JQuery { + /** + * joyride function + * @return {Joyride} Joyride instance. + */ + joyride: Joyride; + } } diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index db7af3d2ad..ac047d0167 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -2329,7 +2329,7 @@ interface JQuery { * @see {@link https://api.jquery.com/val/} * @since 1.0 */ - val(): string | number | string[] | undefined; + val(): string | number | string[] | null | undefined; /** * Set the CSS width of each element in the set of matched elements. * diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 7a05a5630a..438f36c79b 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -3025,7 +3025,7 @@ function JQuery() { return 'myVal'; }); - // $ExpectType string | number | string[] | undefined + // $ExpectType string | number | string[] | null | undefined $('p').val(); } } diff --git a/types/jquery/v1/index.d.ts b/types/jquery/v1/index.d.ts index a3c2d42979..ee66781019 100644 --- a/types/jquery/v1/index.d.ts +++ b/types/jquery/v1/index.d.ts @@ -702,7 +702,9 @@ interface JQueryCoordinates { /** * The interface used to specify the properties parameter in css() */ -type cssPropertySetter = (index: number, value?: string) => string | number; +interface cssPropertySetter { + (index: number, value?: string): string | number; +} interface JQueryCssProperties { [propertyName: string]: string | number | cssPropertySetter; } diff --git a/types/jquery/v2/index.d.ts b/types/jquery/v2/index.d.ts index b01e4ceda7..9d30f12c38 100644 --- a/types/jquery/v2/index.d.ts +++ b/types/jquery/v2/index.d.ts @@ -702,7 +702,9 @@ interface JQueryCoordinates { /** * The interface used to specify the properties parameter in css() */ -type cssPropertySetter = (index: number, value?: string) => string | number; +interface cssPropertySetter { + (index: number, value?: string): string | number; +} interface JQueryCssProperties { [propertyName: string]: string | number | cssPropertySetter; } diff --git a/types/jsdeferred/index.d.ts b/types/jsdeferred/index.d.ts index 4002ffaee8..9cae18ee60 100644 --- a/types/jsdeferred/index.d.ts +++ b/types/jsdeferred/index.d.ts @@ -3,79 +3,101 @@ // Definitions by: Daisuke Mino // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface Loop { - begin?: number; - end?: number; - step?: number; +import $ = require('jquery'); + +declare global { + interface Loop { + begin?: number; + end?: number; + step?: number; + } + + interface ConnectOption { + target: any; + args?: any[]; + ok?: number; + ng?: number; + } + + interface RetryOption { + wait: number; + } + + interface DeferredizedFunction { (...arg: any[]): Deferred; } + interface DeferredizedFunctionWithNumber { (n: number): Deferred; } + interface FunctionWithNumber { (i: number, o?: any): any; } + interface ErrorCallback { (d: Deferred, ...args: any[]): any; } + + class Deferred { + + static methods: string[]; + + static isDeferred(obj: any): boolean; + + static next(fun: Function): Deferred; + + static chain(...args: any[]): Deferred; + + static wait(n: number): Deferred; + + static call(fun?: Function, ...args: any[]): Deferred; + + static parallel(dl: any): Deferred; + + static earlier(dl: any): Deferred; + + static loop(n: number, fun: FunctionWithNumber): Deferred; + static loop(n: Loop, fun: FunctionWithNumber): Deferred; + + static repeat(n: number, fun: FunctionWithNumber): Deferred; + + static register(name: string, fun: DeferredizedFunction): void; + + static connect(funo: any, options: string): DeferredizedFunction; + static connect(funo: Function, options?: ConnectOption): DeferredizedFunction; + + static retry(retryCount: number, funcDeferred: DeferredizedFunctionWithNumber, options?: RetryOption): Deferred; + + static define(obj?: any, list?: string[]): any; + + constructor(); + + next(fun: Function): Deferred; + + wait(n: number): Deferred; + + error(fun: ErrorCallback): Deferred; + + call(val?: any): Deferred; + + fail(err: any): Deferred; + + cancel(): Deferred; + + parallel(dl: any): Deferred; + + loop(n: number, fun: FunctionWithNumber): Deferred; + loop(n: Loop, fun: FunctionWithNumber): Deferred; + } + + interface JQueryXHR { + next(fun: Function): Deferred; + } + + function chain(...args: any[]): Deferred; + + function wait(n: number): Deferred; + + function call(fun?: Function, ...args: any[]): Deferred; + + function parallel(dl: any): Deferred; + + function earlier(dl: any): Deferred; + + function loop(n: number, fun: FunctionWithNumber): Deferred; + function loop(n: Loop, fun: FunctionWithNumber): Deferred; + + function repeat(n: number, fun: FunctionWithNumber): Deferred; + + function next(fun: Function): Deferred; } - -interface ConnectOption { - target: any; - args?: any[]; - ok?: number; - ng?: number; -} - -interface RetryOption { - wait: number; -} - -interface DeferredizedFunction { (...arg: any[]): Deferred; } -interface DeferredizedFunctionWithNumber { (n: number): Deferred; } -interface FunctionWithNumber { (i: number, o?: any): any; } -interface ErrorCallback { (d: Deferred, ...args: any[]): any; } - -declare class Deferred { - - static methods: string[]; - static isDeferred(obj: any): boolean; - static next(fun: Function): Deferred; - static chain(...args: any[]): Deferred; - static wait(n: number): Deferred; - static call(fun?: Function, ...args: any[]): Deferred; - static parallel(dl: any): Deferred; - static earlier(dl: any): Deferred; - - static loop(n: number, fun: FunctionWithNumber): Deferred; - static loop(n: Loop, fun: FunctionWithNumber): Deferred; - - static repeat(n: number, fun: FunctionWithNumber): Deferred; - static register(name: string, fun: DeferredizedFunction): void; - - static connect(funo: any, options: string): DeferredizedFunction; - static connect(funo: Function, options?: ConnectOption): DeferredizedFunction; - - static retry(retryCount: number, funcDeferred: DeferredizedFunctionWithNumber, options?: RetryOption): Deferred; - static define(obj?: any, list?: string[]): any; - - constructor(); - - next(fun: Function): Deferred; - wait(n: number): Deferred; - error(fun: ErrorCallback): Deferred; - call(val?: any): Deferred; - fail(err: any): Deferred; - cancel(): Deferred; - parallel(dl: any): Deferred; - - loop(n: number, fun: FunctionWithNumber): Deferred; - loop(n: Loop, fun: FunctionWithNumber): Deferred; -} - -interface JQueryXHR { - next(fun: Function): Deferred; -} - -declare function chain(...args: any[]): Deferred; -declare function wait(n: number): Deferred; -declare function call(fun?: Function, ...args: any[]): Deferred; -declare function parallel(dl: any): Deferred; -declare function earlier(dl: any): Deferred; - -declare function loop(n: number, fun: FunctionWithNumber): Deferred; -declare function loop(n: Loop, fun: FunctionWithNumber): Deferred; - -declare function repeat(n: number, fun: FunctionWithNumber): Deferred; - -declare function next(fun: Function): Deferred; - diff --git a/types/kendo-ui/index.d.ts b/types/kendo-ui/index.d.ts index 8c58c182be..733845e514 100644 --- a/types/kendo-ui/index.d.ts +++ b/types/kendo-ui/index.d.ts @@ -16,8 +16,8 @@ declare namespace kendo { names: string[]; namesAbbr: string[]; namesShort: string[]; - firstDay: number; }; + firstDay: number; months: { names: string[]; namesAbbr: string[]; diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index 2e301af850..a7c08661d2 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -177,9 +177,8 @@ declare namespace Knex { interface Join { (raw: Raw): QueryBuilder; - (builder: QueryBuilder, clause: (this: JoinClause) => void): QueryBuilder; - (tableName: string, columns: { [key: string]: string | number | Raw }): QueryBuilder; - (tableName: string, callback: Function): QueryBuilder; + (tableName: TableName, clause: (this: JoinClause) => void): QueryBuilder; + (tableName: TableName, columns: { [key: string]: string | number | Raw }): QueryBuilder; (tableName: TableName, raw: Raw): QueryBuilder; (tableName: TableName, column1: string, column2: string): QueryBuilder; (tableName: TableName, column1: string, raw: Raw): QueryBuilder; diff --git a/types/knex/knex-tests.ts b/types/knex/knex-tests.ts index 1f12a1044a..610f51cc1f 100644 --- a/types/knex/knex-tests.ts +++ b/types/knex/knex-tests.ts @@ -213,6 +213,14 @@ knex('users') .join(knex('contacts').select('user_id', 'phone').as('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(knex('accounts').select('id', 'owner_id').as('accounts'), function() { + this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id') +}); + knex.select('*').from('users').join('accounts', function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id') }); diff --git a/types/libpq/index.d.ts b/types/libpq/index.d.ts index 49c00db818..d336d95c9f 100644 --- a/types/libpq/index.d.ts +++ b/types/libpq/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/brianc/node-libpq#readme // Definitions by: Vlad Rindevich // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 /// diff --git a/types/lodash/divide/index.d.ts b/types/lodash/divide/index.d.ts new file mode 100644 index 0000000000..2df6f40e3a --- /dev/null +++ b/types/lodash/divide/index.d.ts @@ -0,0 +1,2 @@ +import { divide } from "../index"; +export = divide; diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index bb0b7b7f9d..ae7f70fdb0 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -187,7 +187,7 @@ Misc: - [ ] _.extendWith as an alias of _.assignInWith - [ ] Added clear method to _.memoize.Cache - [ ] Added support for ES6 maps, sets, & symbols to _.clone, _.isEqual, & _.toArray -- [ ] Enabled _.flow & _.flowRight to accept an array of functions +- [x] Enabled _.flow & _.flowRight to accept an array of functions - [ ] Ensured “Collection” methods treat functions as objects - [ ] Ensured _.assign, _.defaults, & _.merge coerce object values to objects - [ ] Ensured _.bindKey bound functions call object[key] when called with the new operator @@ -10799,6 +10799,7 @@ declare namespace _ { flow(f1: (a1: A1, a2: A2, a3: A3, a4: A4) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7): (a1: A1, a2: A2, a3: A3, a4: A4) => R7; // generic function flow(...funcs: Function[]): TResult; + flow(funcs: Function[]): TResult; } interface LoDashImplicitObjectWrapper { @@ -10806,6 +10807,10 @@ declare namespace _ { * @see _.flow */ flow(...funcs: Function[]): LoDashImplicitObjectWrapper; + /** + * @see _.flow + */ + flow(funcs: Function[]): LoDashImplicitObjectWrapper; } interface LoDashExplicitObjectWrapper { @@ -10813,6 +10818,10 @@ declare namespace _ { * @see _.flow */ flow(...funcs: Function[]): LoDashExplicitObjectWrapper; + /** + * @see _.flow + */ + flow(funcs: Function[]): LoDashExplicitObjectWrapper; } //_.flowRight @@ -10825,6 +10834,10 @@ declare namespace _ { * @return Returns the new function. */ flowRight(...funcs: Function[]): TResult; + /** + * @see _.flowRight + */ + flowRight(funcs: Function[]): TResult; } interface LoDashImplicitObjectWrapper { @@ -10832,6 +10845,10 @@ declare namespace _ { * @see _.flowRight */ flowRight(...funcs: Function[]): LoDashImplicitObjectWrapper; + /** + * @see _.flowRight + */ + flowRight(funcs: Function[]): LoDashImplicitObjectWrapper; } interface LoDashExplicitObjectWrapper { @@ -10839,6 +10856,10 @@ declare namespace _ { * @see _.flowRight */ flowRight(...funcs: Function[]): LoDashExplicitObjectWrapper; + /** + * @see _.flowRight + */ + flowRight(funcs: Function[]): LoDashExplicitObjectWrapper; } //_.memoize @@ -13519,6 +13540,35 @@ declare namespace _ { ceil(precision?: number): LoDashExplicitWrapper; } + //_.divide + interface LoDashStatic { + /** + * Divide two numbers. + * + * @param dividend The first number in a division. + * @param divisor The second number in a division. + * @returns Returns the quotient. + */ + divide( + dividend: number, + divisor: number + ): number; + } + + interface LoDashImplicitWrapper { + /** + * @see _.divide + */ + divide(divisor: number): number; + } + + interface LoDashExplicitWrapper { + /** + * @see _.divide + */ + divide(divisor: number): LoDashExplicitWrapper; + } + //_.floor interface LoDashStatic { /** @@ -13864,6 +13914,34 @@ declare namespace _ { ): T | undefined; } + //_.multiply + interface LoDashStatic { + /** + * Multiply two numbers. + * @param multiplier The first number in a multiplication. + * @param multiplicand The second number in a multiplication. + * @returns Returns the product. + */ + multiply( + multiplier: number, + multiplicand: number + ): number; + } + + interface LoDashImplicitWrapper { + /** + * @see _.multiply + */ + multiply(multiplicand: number): number; + } + + interface LoDashExplicitWrapper { + /** + * @see _.multiply + */ + multiply(multiplicand: number): LoDashExplicitWrapper; + } + //_.round interface LoDashStatic { /** diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index d69529e0dd..1f7eabd3cb 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -6090,6 +6090,7 @@ namespace TestFlow { result = _.flow(Fn2, Fn1, Fn1, Fn1, Fn1, Fn1); result = _.flow(Fn2, Fn1, Fn1, Fn1, Fn1, Fn1, Fn1); result = _.flow(Fn2, Fn1, Fn3, Fn4); + result = _.flow<(m: number, n: number) => number>([Fn2, Fn1, Fn3, Fn4]); } { @@ -6098,6 +6099,7 @@ namespace TestFlow { result = _.flow<(m: number, n: number) => number>(Fn1, Fn2); result = _.flow<(m: number, n: number) => number>(Fn1, Fn1, Fn2); result = _.flow<(m: number, n: number) => number>(Fn1, Fn1, Fn1, Fn2); + result = _.flow<(m: number, n: number) => number>([Fn1, Fn1, Fn1, Fn2]); } { @@ -6106,6 +6108,7 @@ namespace TestFlow { result = _(Fn1).flow<(m: number, n: number) => number>(Fn2); result = _(Fn1).flow<(m: number, n: number) => number>(Fn1, Fn2); result = _(Fn1).flow<(m: number, n: number) => number>(Fn1, Fn1, Fn2); + result = _(Fn1).flow<(m: number, n: number) => number>([Fn1, Fn1, Fn2]); } { @@ -6114,6 +6117,7 @@ namespace TestFlow { result = _(Fn1).chain().flow<(m: number, n: number) => number>(Fn2); result = _(Fn1).chain().flow<(m: number, n: number) => number>(Fn1, Fn2); result = _(Fn1).chain().flow<(m: number, n: number) => number>(Fn1, Fn1, Fn2); + result = _(Fn1).chain().flow<(m: number, n: number) => number>([Fn1, Fn1, Fn2]); } } @@ -6128,6 +6132,7 @@ namespace TestFlowRight { result = _.flowRight<(m: number, n: number) => number>(Fn1, Fn2); result = _.flowRight<(m: number, n: number) => number>(Fn1, Fn1, Fn2); result = _.flowRight<(m: number, n: number) => number>(Fn1, Fn1, Fn1, Fn2); + result = _.flowRight<(m: number, n: number) => number>([Fn1, Fn1, Fn1, Fn2]); } { @@ -6136,6 +6141,7 @@ namespace TestFlowRight { result = _(Fn1).flowRight<(m: number, n: number) => number>(Fn2); result = _(Fn1).flowRight<(m: number, n: number) => number>(Fn1, Fn2); result = _(Fn1).flowRight<(m: number, n: number) => number>(Fn1, Fn1, Fn2); + result = _(Fn1).flowRight<(m: number, n: number) => number>([Fn1, Fn1, Fn2]); } { @@ -6144,6 +6150,7 @@ namespace TestFlowRight { result = _(Fn1).chain().flowRight<(m: number, n: number) => number>(Fn2); result = _(Fn1).chain().flowRight<(m: number, n: number) => number>(Fn1, Fn2); result = _(Fn1).chain().flowRight<(m: number, n: number) => number>(Fn1, Fn1, Fn2); + result = _(Fn1).chain().flowRight<(m: number, n: number) => number>([Fn1, Fn1, Fn2]); } } @@ -8058,6 +8065,23 @@ namespace TestCeil { } } +// _.divide +namespace TestDivide { + { + let result: number; + + result = _.divide(6, 4); + + result = _(6).divide(4); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(6).chain().floor(4); + } +} + // _.floor namespace TestFloor { { @@ -8204,6 +8228,23 @@ namespace TestMinBy { result = _(dictionary).minBy<{a: number}, number>({a: 42}); } +// _.multiply +namespace TestMultiply { + { + let result: number; + + result = _.multiply(6, 4); + + result = _(6).multiply(4); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(6).chain().multiply(4); + } +} + // _.round namespace TestRound { { diff --git a/types/lodash/tsconfig.json b/types/lodash/tsconfig.json index 88cd24b85a..55cecd6166 100644 --- a/types/lodash/tsconfig.json +++ b/types/lodash/tsconfig.json @@ -19,6 +19,7 @@ "capitalize/index.d.ts", "castArray/index.d.ts", "ceil/index.d.ts", + "divide/index.d.ts", "chain/index.d.ts", "chunk/index.d.ts", "clamp/index.d.ts", diff --git a/types/main-bower-files/index.d.ts b/types/main-bower-files/index.d.ts index 0a00b19b8b..f3cc5e7228 100644 --- a/types/main-bower-files/index.d.ts +++ b/types/main-bower-files/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/ck86/main-bower-files // Definitions by: Keita Kagurazaka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index 9438bfafac..680362fe82 100644 --- a/types/mapbox-gl/index.d.ts +++ b/types/mapbox-gl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mapbox GL JS v0.38.0 +// Type definitions for Mapbox GL JS v0.39.0 // Project: https://github.com/mapbox/mapbox-gl-js // Definitions by: Dominik Bruderer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -173,7 +173,7 @@ declare namespace mapboxgl { keyboard: KeyboardHandler; - doublClickZoom: DoubleClickZoomHandler; + doubleClickZoom: DoubleClickZoomHandler; touchZoomRotate: TouchZoomRotateHandler; } @@ -254,6 +254,9 @@ declare namespace mapboxgl { /** Initial zoom level */ zoom?: number; + + /** Maximum tile cache size for each layer. */ + maxTileCacheSize?: number; } export interface PaddingOptions { diff --git a/types/mapbox__shelf-pack/index.d.ts b/types/mapbox__shelf-pack/index.d.ts new file mode 100644 index 0000000000..3ef3ec3507 --- /dev/null +++ b/types/mapbox__shelf-pack/index.d.ts @@ -0,0 +1,59 @@ +// Type definitions for @mapbox/shelf-pack 3.0 +// Project: https://github.com/mapbox/shelf-pack +// Definitions by: Gyusun Yeom +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// tslint:disable-next-line no-single-declare-module +declare module "@mapbox/shelf-pack" { + export = ShelfPack; + + class ShelfPack { + constructor(width?: number, height?: number, options?: ShelfPack.CreateOption); + + pack(bins: Array, options?: ShelfPack.PackOption): ShelfPack.Bin[]; + packOne(w: number, h: number, id?: ShelfPack.ID): ShelfPack.Bin; + getBin(id: ShelfPack.ID): ShelfPack.Bin; + ref(bin: ShelfPack.Bin): number; + unref(bin: ShelfPack.Bin): number; + clear(): void; + resize(w: number, h: number): boolean; + + w: number; + h: number; + } + + namespace ShelfPack { + class Bin { + constructor(id: ID, x: number, y: number, w: number, h: number, maxw?: number, maxh?: number); + + id: ID; + x: number; + y: number; + w: number; + h: number; + } + + type ID = number | string; + interface Request { + id?: ID; + } + interface RequestShort extends Request { + w: number; + h: number; + } + interface RequestLong extends Request { + width: number; + height: number; + } + + interface PackOption { + /// If true , the supplied bin objects will be updated inplace with x and y properties + inPlace?: boolean; + } + + interface CreateOption { + /// If true , the sprite will automatically grow + autoResize?: boolean; + } + } +} diff --git a/types/mapbox__shelf-pack/mapbox__shelf-pack-tests.ts b/types/mapbox__shelf-pack/mapbox__shelf-pack-tests.ts new file mode 100644 index 0000000000..3baff984cb --- /dev/null +++ b/types/mapbox__shelf-pack/mapbox__shelf-pack-tests.ts @@ -0,0 +1,30 @@ +import * as ShelfPack from '@mapbox/shelf-pack'; + +let sprite = new ShelfPack(64, 64); + +for (let i = 0; i < 5; i++) { + const bin = sprite.packOne(32, 32); +} + +sprite.clear(); + +sprite.resize(128, 128); + +sprite = new ShelfPack(64, 64); + +[100, 101, 102].forEach(id => { + const bin = sprite.packOne(16, 16, id); +}); + +const bin102 = sprite.packOne(16, 16, 102); + +const bin101 = sprite.getBin(101); +sprite.ref(bin101); + +const bin100 = sprite.getBin(100); +sprite.unref(bin100); + +const bin103 = sprite.packOne(16, 15, 103); +sprite.unref(bin103); + +const bin104 = sprite.packOne(16, 16, 104); diff --git a/types/mapbox__shelf-pack/tsconfig.json b/types/mapbox__shelf-pack/tsconfig.json new file mode 100644 index 0000000000..540d660492 --- /dev/null +++ b/types/mapbox__shelf-pack/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mapbox__shelf-pack-tests.ts" + ] +} diff --git a/types/mapbox__shelf-pack/tslint.json b/types/mapbox__shelf-pack/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mapbox__shelf-pack/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/massive/index.d.ts b/types/massive/index.d.ts index 67be093bb0..ccf6469d91 100644 --- a/types/massive/index.d.ts +++ b/types/massive/index.d.ts @@ -50,9 +50,9 @@ declare namespace massive { count(criteria: object): Promise; where(query: string, params: any[] | object): Promise; search(criteria: SearchCriteria, queryOptions?: QueryOptions): Promise; - save(data: object): Promise; - insert(data: object): Promise; - update(dataOrCriteria: object, changesMap?: object): Promise; + save(data: object | object[]): Promise | Promise; + insert(data: object | object[]): Promise | Promise; + update(dataOrCriteria: object | object[], changesMap?: object): Promise | Promise; destroy(criteria: object): Promise; } diff --git a/types/material-ui/index.d.ts b/types/material-ui/index.d.ts index a7b13f2bb4..16c6b5dce7 100644 --- a/types/material-ui/index.d.ts +++ b/types/material-ui/index.d.ts @@ -942,6 +942,8 @@ declare namespace __MaterialUI { utils?: propTypes.utils; } export class DatePicker extends React.Component { + focus(): void; + openDialog(): void; } interface DatePickerDialogProps { diff --git a/types/mongoose-simple-random/index.d.ts b/types/mongoose-simple-random/index.d.ts new file mode 100644 index 0000000000..cf41c64241 --- /dev/null +++ b/types/mongoose-simple-random/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for mongoose-simple-random 0.4 +// Project: https://github.com/larryprice/mongoose-simple-random +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +// tslint:disable-next-line no-single-declare-module +declare module "mongoose" { + interface Model extends NodeJS.EventEmitter, ModelProperties { + findRandom(conditions: Object, projection?: Object | null, options?: Object | null, callback?: (err: any, res: T[]) => void) + : void; + } +} diff --git a/types/mongoose-simple-random/mongoose-simple-random-tests.ts b/types/mongoose-simple-random/mongoose-simple-random-tests.ts new file mode 100644 index 0000000000..2aa9e18296 --- /dev/null +++ b/types/mongoose-simple-random/mongoose-simple-random-tests.ts @@ -0,0 +1,15 @@ +import * as mongoose from 'mongoose'; + +// test compatibility with other libraries - from @types/mongoose +import * as _ from 'lodash'; +import * as fs from "fs"; + +mongoose.Model.findRandom({ + username: { $ne: "DummyUser" }, + rating: { + $gt: 1, + $lt: 11, + }, +}, {}, { limit: 1 }, (error, data) => { + if (error) { console.error("Error!"); } else { console.log("Success!"); } +}); diff --git a/types/mongoose-simple-random/tsconfig.json b/types/mongoose-simple-random/tsconfig.json new file mode 100644 index 0000000000..28627f97dd --- /dev/null +++ b/types/mongoose-simple-random/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mongoose-simple-random-tests.ts" + ] +} diff --git a/types/mongoose-simple-random/tslint.json b/types/mongoose-simple-random/tslint.json new file mode 100644 index 0000000000..8438350251 --- /dev/null +++ b/types/mongoose-simple-random/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // This package uses the Function type, and it will take effort to fix. + "ban-types": false + } +} \ No newline at end of file diff --git a/types/mongoose/v3/index.d.ts b/types/mongoose/v3/index.d.ts index 80cca9da2f..c914af0813 100644 --- a/types/mongoose/v3/index.d.ts +++ b/types/mongoose/v3/index.d.ts @@ -68,6 +68,7 @@ declare module "mongoose" { pass?: string; /** Options for authentication */ auth?: any; + useMongoClient?: boolean; } export interface ConnectionOptions extends ConnectOpenOptionsBase { @@ -656,4 +657,4 @@ declare module "mongoose" { error(err: any): Promise; } -} \ No newline at end of file +} diff --git a/types/mysql/index.d.ts b/types/mysql/index.d.ts index 9212d59ef6..d98ef82216 100644 --- a/types/mysql/index.d.ts +++ b/types/mysql/index.d.ts @@ -58,6 +58,8 @@ interface IConnection { end(callback: (err: IError, ...args: any[]) => void): void; end(options: any, callback: (err: IError, ...args: any[]) => void): void; + ping(callback: (err: IError) => void): void; + destroy(): void; pause(): void; diff --git a/types/mysql/mysql-tests.ts b/types/mysql/mysql-tests.ts index a6d9afc07e..d2c44e21ee 100644 --- a/types/mysql/mysql-tests.ts +++ b/types/mysql/mysql-tests.ts @@ -148,6 +148,11 @@ connection.connect(function (err) { console.log('connected as id ' + connection.threadId); }); +connection.ping(function (err) { + if (err) throw err; + console.log('Ping was successful'); +}) + /// Pools var poolConfig = { diff --git a/types/node-hid/index.d.ts b/types/node-hid/index.d.ts index 34afff06b1..92ffd4a60a 100644 --- a/types/node-hid/index.d.ts +++ b/types/node-hid/index.d.ts @@ -1,17 +1,20 @@ // Type definitions for node-hid 0.5 // Project: https://github.com/node-hid/node-hid#readme // Definitions by: Mohamed Hegazy +// Robert Kiss // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface Device { vendorId: number; productId: number; - path: string; - serialNumber: string; - manufacturer: string; - product: string; + path?: string; + serialNumber?: string; + manufacturer?: string; + product?: string; release: number; interface: number; + usagePage?: number; + usage?: number; } export class HID { diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 131dbc96a1..bcb4db0bef 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -6,6 +6,8 @@ // Roberto Desideri // Christian Vaagland Tellnes // Wilco Bakker +// Nicolas Voigt +// Chigozirim C. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -307,7 +309,7 @@ declare namespace NodeJS { export interface ReadableStream extends EventEmitter { readable: boolean; read(size?: number): string | Buffer; - setEncoding(encoding: string | null): this; + setEncoding(encoding: string): this; pause(): this; resume(): this; isPaused(): boolean; @@ -400,6 +402,10 @@ declare namespace NodeJS { isTTY?: true; } + export interface ProcessEnv { + [key: string]: string | undefined + } + export interface Process extends EventEmitter { stdout: Socket; stderr: Socket; @@ -413,7 +419,7 @@ declare namespace NodeJS { chdir(directory: string): void; cwd(): string; emitWarning(warning: string | Error, name?: string, ctor?: Function): void; - env: any; + env: ProcessEnv; exit(code?: number): never; exitCode: number; getgid(): number; @@ -2439,6 +2445,8 @@ declare module "dgram" { send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error, bytes: number) => void): void; send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; bind(port?: number, address?: string, callback?: () => void): void; + bind(port?: number, callback?: () => void): void; + bind(callback?: () => void): void; bind(options: BindOptions, callback?: Function): void; close(callback?: () => void): void; address(): AddressInfo; @@ -2499,6 +2507,7 @@ declare module "dgram" { declare module "fs" { import * as stream from "stream"; import * as events from "events"; + import * as url from "url"; interface Stats { isFile(): boolean; @@ -2827,13 +2836,17 @@ declare module "fs" { */ export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, encoding: string, callback: (err: NodeJS.ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFileSync(filename: string, data: any, encoding: string): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function appendFile(filename: string, data: any, encoding: string, callback: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFileSync(filename: string, data: any, encoding: string): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; @@ -2977,7 +2990,7 @@ declare module "fs" { export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ export function accessSync(path: string | Buffer, mode?: number): void; - export function createReadStream(path: string | Buffer, options?: { + export function createReadStream(path: string | Buffer | url.URL, options?: string | { flags?: string; encoding?: string; fd?: number; @@ -2986,9 +2999,9 @@ declare module "fs" { start?: number; end?: number; }): ReadStream; - export function createWriteStream(path: string | Buffer, options?: { + export function createWriteStream(path: string | Buffer | url.URL, options?: string | { flags?: string; - encoding?: string; + defaultEncoding?: string; fd?: number; mode?: number; autoClose?: boolean; @@ -3634,8 +3647,10 @@ declare module "crypto" { export interface Verify extends NodeJS.WritableStream { update(data: string | Buffer): Verify; update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Verify; - verify(object: string, signature: Buffer): boolean; - verify(object: string, signature: string, signature_format: HexBase64Latin1Encoding): boolean; + verify(object: string | Object, signature: Buffer | DataView): boolean; + verify(object: string | Object, signature: string, signature_format: HexBase64Latin1Encoding): boolean; + // https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format + // The signature field accepts a TypedArray type, but it is only available starting ES2017 } export function createDiffieHellman(prime_length: number, generator?: number): DiffieHellman; export function createDiffieHellman(prime: Buffer): DiffieHellman; @@ -3823,6 +3838,8 @@ declare module "stream" { end(): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; + cork(): void; + uncork(): void; /** * Event emitter @@ -3908,6 +3925,8 @@ declare module "stream" { end(): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; + cork(): void; + uncork(): void; } export interface TransformOptions extends DuplexOptions { @@ -3934,8 +3953,18 @@ declare module "util" { export function puts(...param: any[]): void; export function print(...param: any[]): void; export function log(string: string): void; - export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string; - export function inspect(object: any, options: InspectOptions): string; + export var inspect: { + (object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string; + (object: any, options: InspectOptions): string; + colors: { + [color: string]: [number, number] + } + styles: { + [style: string]: string + } + defaultOptions: InspectOptions; + custom: symbol; + } export function isArray(object: any): object is any[]; export function isRegExp(object: any): object is RegExp; export function isDate(object: any): object is Date; @@ -3954,7 +3983,10 @@ declare module "util" { export function isSymbol(object: any): object is symbol; export function isUndefined(object: any): object is undefined; export function deprecate(fn: Function, message: string): Function; - export function promisify(fn: Function): Function; + export var promisify: { + (fn: Function): Function; + custom: symbol + } } declare module "assert" { diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index aeefc2bbdc..a31f3e8899 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -169,6 +169,18 @@ namespace fs_tests { encoding: "ascii" }, assert.ifError); + + fs.writeFile("testfile", "content", "utf8", assert.ifError); + + fs.writeFileSync("testfile", "content", "utf8"); + fs.writeFileSync("testfile", "content", { encoding: "utf8" }); + } + + { + fs.appendFile("testfile", "foobar", "utf8", assert.ifError); + fs.appendFile("testfile", "foobar", { encoding: "utf8" }, assert.ifError); + fs.appendFileSync("testfile", "foobar", "utf8"); + fs.appendFileSync("testfile", "foobar", { encoding: "utf8" }); } { @@ -544,6 +556,11 @@ namespace util_tests { maxArrayLength: null, breakLength: Infinity }) + assert(typeof util.inspect.custom === 'symbol') + // util.promisify + var readPromised = util.promisify(fs.readFile) + var sampleRead: Promise = readPromised(__filename).then((data: string): void => {}).catch((error: Error): void => {}) + assert(typeof util.promisify.custom === 'symbol') } } @@ -1045,6 +1062,10 @@ namespace dgram_tests { }); ds.bind(); ds.bind(41234); + ds.bind(4123, 'localhost'); + ds.bind(4123, 'localhost', () => {}); + ds.bind(4123, () => {}); + ds.bind(() => {}); var ai: dgram.AddressInfo = ds.address(); ds.send(new Buffer("hello"), 0, 5, 5000, "127.0.0.1", (error: Error, bytes: number): void => { }); diff --git a/types/node/v0/node-tests.ts b/types/node/v0/node-tests.ts index 30dfd2bd72..57019bfe86 100644 --- a/types/node/v0/node-tests.ts +++ b/types/node/v0/node-tests.ts @@ -47,6 +47,11 @@ fs.writeFile("Harry Potter", }, assert.ifError); +fs.writeFileSync("testfile", "content", { encoding: "utf8" }); + +fs.appendFile("testfile", "foobar", { encoding: "utf8" }, assert.ifError); +fs.appendFileSync("testfile", "foobar", { encoding: "utf8" }); + var content: string, buffer: Buffer; diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 3c5a7745e9..a79f49e35d 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -1773,13 +1773,17 @@ declare module "fs" { */ export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, encoding: string, callback: (err: NodeJS.ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFileSync(filename: string, data: any, encoding: string): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function appendFile(filename: string, data: any, encoding: string, callback: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFileSync(filename: string, data: any, encoding: string): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; diff --git a/types/node/v4/node-tests.ts b/types/node/v4/node-tests.ts index b56bb224e1..a3e1cca18a 100644 --- a/types/node/v4/node-tests.ts +++ b/types/node/v4/node-tests.ts @@ -151,6 +151,18 @@ namespace fs_tests { encoding: "ascii" }, assert.ifError); + + fs.writeFile("testfile", "content", "utf8", assert.ifError); + + fs.writeFileSync("testfile", "content", "utf8"); + fs.writeFileSync("testfile", "content", { encoding: "utf8" }); + } + + { + fs.appendFile("testfile", "foobar", "utf8", assert.ifError); + fs.appendFile("testfile", "foobar", { encoding: "utf8" }, assert.ifError); + fs.appendFileSync("testfile", "foobar", "utf8"); + fs.appendFileSync("testfile", "foobar", { encoding: "utf8" }); } { diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index d0c3a44311..b71a70e537 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -2562,13 +2562,17 @@ declare module "fs" { */ export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, encoding: string, callback: (err: NodeJS.ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFileSync(filename: string, data: any, encoding: string): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function appendFile(filename: string, data: any, encoding: string, callback: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFileSync(filename: string, data: any, encoding: string): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; diff --git a/types/node/v6/node-tests.ts b/types/node/v6/node-tests.ts index f7474844e8..191f1128c2 100644 --- a/types/node/v6/node-tests.ts +++ b/types/node/v6/node-tests.ts @@ -168,6 +168,18 @@ namespace fs_tests { encoding: "ascii" }, assert.ifError); + + fs.writeFile("testfile", "content", "utf8", assert.ifError); + + fs.writeFileSync("testfile", "content", "utf8"); + fs.writeFileSync("testfile", "content", { encoding: "utf8" }); + } + + { + fs.appendFile("testfile", "foobar", "utf8", assert.ifError); + fs.appendFile("testfile", "foobar", { encoding: "utf8" }, assert.ifError); + fs.appendFileSync("testfile", "foobar", "utf8"); + fs.appendFileSync("testfile", "foobar", { encoding: "utf8" }); } { diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index 31e068cec8..f075587a95 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -2691,13 +2691,17 @@ declare module "fs" { */ export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, encoding: string, callback: (err: NodeJS.ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFileSync(filename: string, data: any, encoding: string): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function appendFile(filename: string, data: any, encoding: string, callback: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFileSync(filename: string, data: any, encoding: string): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; diff --git a/types/node/v7/node-tests.ts b/types/node/v7/node-tests.ts index de401eb0fc..4a2f53ab67 100644 --- a/types/node/v7/node-tests.ts +++ b/types/node/v7/node-tests.ts @@ -169,6 +169,18 @@ namespace fs_tests { encoding: "ascii" }, assert.ifError); + + fs.writeFile("testfile", "content", "utf8", assert.ifError); + + fs.writeFileSync("testfile", "content", "utf8"); + fs.writeFileSync("testfile", "content", { encoding: "utf8" }); + } + + { + fs.appendFile("testfile", "foobar", "utf8", assert.ifError); + fs.appendFile("testfile", "foobar", { encoding: "utf8" }, assert.ifError); + fs.appendFileSync("testfile", "foobar", "utf8"); + fs.appendFileSync("testfile", "foobar", { encoding: "utf8" }); } { diff --git a/types/passport-beam/index.d.ts b/types/passport-beam/index.d.ts index 7d34ef4173..852ac6f698 100644 --- a/types/passport-beam/index.d.ts +++ b/types/passport-beam/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/alfw/passport-beam // Definitions by: AtlasDev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// /// @@ -31,4 +32,4 @@ export namespace Strategy { _raw: any; _json: any; } -} \ No newline at end of file +} diff --git a/types/passport-facebook-token/index.d.ts b/types/passport-facebook-token/index.d.ts index 173992a701..49bfc62d11 100644 --- a/types/passport-facebook-token/index.d.ts +++ b/types/passport-facebook-token/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/drudge/passport-facebook-token // Definitions by: Ray Martone // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// diff --git a/types/passport-facebook/index.d.ts b/types/passport-facebook/index.d.ts index cd35cbe0c8..01db85012d 100644 --- a/types/passport-facebook/index.d.ts +++ b/types/passport-facebook/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jaredhanson/passport-facebook // Definitions by: James Roland Cabresos , Lucas Acosta // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// diff --git a/types/passport-github/index.d.ts b/types/passport-github/index.d.ts index 38704a0a88..0b0880bb05 100644 --- a/types/passport-github/index.d.ts +++ b/types/passport-github/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jaredhanson/passport-github // Definitions by: Yasunori Ohoka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 import passport = require('passport'); import express = require('express'); diff --git a/types/passport-github/passport-github-tests.ts b/types/passport-github/passport-github-tests.ts index 72697a7dd2..10c24a366d 100644 --- a/types/passport-github/passport-github-tests.ts +++ b/types/passport-github/passport-github-tests.ts @@ -11,11 +11,27 @@ const User = { } }; +const callbackURL = process.env.PASSPORT_GITHUB_CALLBACK_URL; +const clientID = process.env.PASSPORT_GITHUB_CONSUMER_KEY; +const clientSecret = process.env.PASSPORT_GITHUB_CONSUMER_SECRET; + +if (typeof callbackURL === "undefined") { + throw new Error("callbackURL is undefined"); +} + +if (typeof clientID === "undefined") { + throw new Error("clientID is undefined"); +} + +if (typeof clientSecret === "undefined") { + throw new Error("clientSecret is undefined"); +} + passport.use(new github.Strategy( { - clientID: process.env.PASSPORT_GITHUB_CONSUMER_KEY, - clientSecret: process.env.PASSPORT_GITHUB_CONSUMER_SECRET, - callbackURL: process.env.PASSPORT_GITHUB_CALLBACK_URL + callbackURL, + clientID, + clientSecret }, (accessToken: string, refreshToken: string, profile: github.Profile, done: (error: any, user?: any) => void) => { User.findOrCreate(profile.id, profile.provider, (err, user) => { diff --git a/types/passport-google-oauth/index.d.ts b/types/passport-google-oauth/index.d.ts index 50930a45ad..cefd05fe20 100644 --- a/types/passport-google-oauth/index.d.ts +++ b/types/passport-google-oauth/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jaredhanson/passport-facebook // Definitions by: James Roland Cabresos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// diff --git a/types/passport-twitter/index.d.ts b/types/passport-twitter/index.d.ts index f819ef721d..41cee10286 100644 --- a/types/passport-twitter/index.d.ts +++ b/types/passport-twitter/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jaredhanson/passport-twitter // Definitions by: James Roland Cabresos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// diff --git a/types/pg-types/package.json b/types/pg-types/package.json index 4c6d24a445..d33ff913ce 100644 --- a/types/pg-types/package.json +++ b/types/pg-types/package.json @@ -2,4 +2,4 @@ "dependencies": { "moment": ">=2.14.0" } -} \ No newline at end of file +} diff --git a/types/pty.js/index.d.ts b/types/pty.js/index.d.ts index 49acad6260..c54022279b 100644 --- a/types/pty.js/index.d.ts +++ b/types/pty.js/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/chjj/pty.js // Definitions by: Vadim Macagon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// diff --git a/types/react-bootstrap-table/index.d.ts b/types/react-bootstrap-table/index.d.ts index 06e965c04b..1b80e670fa 100644 --- a/types/react-bootstrap-table/index.d.ts +++ b/types/react-bootstrap-table/index.d.ts @@ -157,7 +157,7 @@ export interface SelectRow { Give an array data to perform which rows you want to be selected when table loading. The content of array should be the rowkey which you want to be selected. */ - selected?: string[]; + selected?: string[] | number[]; /** if true, the radio/checkbox column will be hide. You can enable this attribute if you enable clickToSelect and you don't want to show the selection column. diff --git a/types/react-bootstrap/index.d.ts b/types/react-bootstrap/index.d.ts index 3030e7d6a5..a696c4ac6d 100644 --- a/types/react-bootstrap/index.d.ts +++ b/types/react-bootstrap/index.d.ts @@ -847,6 +847,7 @@ declare namespace ReactBootstrap { // interface BadgeProps extends React.HTMLProps { + bsClass?: string; pullRight?: boolean; } type Badge = React.ClassicComponent; @@ -908,6 +909,7 @@ declare namespace ReactBootstrap { responsive?: boolean; striped?: boolean; fill?: boolean; + bsClass?: string; } type Table = React.ClassicComponent; var Table: React.ClassicComponentClass; diff --git a/types/react-burger-menu/index.d.ts b/types/react-burger-menu/index.d.ts new file mode 100644 index 0000000000..6d3a508c97 --- /dev/null +++ b/types/react-burger-menu/index.d.ts @@ -0,0 +1,57 @@ +// Type definitions for react-burger-menu 2.1 +// Project: https://github.com/negomi/react-burger-menu +// Definitions by: Rajab Shakirov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from "react"; + +// TODO (Rajab) actually I don't want export Props, but +// `npm run lint react-burger-menu` error doesn't allow me to do it; +export interface Props { + burgerBarClassName?: string; + burgerButtonClassName?: string; + crossButtonClassName?: string; + crossClassName?: string; + customBurgerIcon?: Element | false; + customCrossIcon?: Element | false; + id?: string; + isOpen?: boolean; + itemListClassName?: string; + menuClassName?: string; + morphShapeClassName?: string; + noOverlay?: boolean; + onStateChange?(): void; + // TODO (Rajab) This can be improved, though I do not know how. From PropTypes: + // styles && styles.outerContainer ? PropTypes.string.isRequired : PropTypes.string + outerContainerId?: string; + overlayClassName?: string; + // TODO (Rajab) This can be improved, though I do not know how. From PropTypes: + // styles && styles.pageWrap ? PropTypes.string.isRequired : PropTypes.string, + pageWrapId?: string; + right?: boolean; + styles?: { + bmBurgerButton: CSSStyleDeclaration; + bmBurgerBars: CSSStyleDeclaration; + bmCrossButton: CSSStyleDeclaration; + bmCross: CSSStyleDeclaration; + bmMenu: CSSStyleDeclaration; + bmMorphShape: CSSStyleDeclaration; + bmItemList: CSSStyleDeclaration; + bmOverlay: CSSStyleDeclaration; + }; + width?: number | string; +} + +// TODO (Rajab) actually I don't want export ReactBurgerMenu, but +// `npm run lint react-burger-menu` error doesn't allow me to do it; +export class ReactBurgerMenu extends React.Component { } + +export class slide extends ReactBurgerMenu { } +export class stack extends ReactBurgerMenu { } +export class elastic extends ReactBurgerMenu { } +export class bubble extends ReactBurgerMenu { } +export class push extends ReactBurgerMenu { } +export class pushRotate extends ReactBurgerMenu { } +export class scaleDown extends ReactBurgerMenu { } +export class scaleRotate extends ReactBurgerMenu { } +export class fallDown extends ReactBurgerMenu { } diff --git a/types/react-burger-menu/react-burger-menu-tests.tsx b/types/react-burger-menu/react-burger-menu-tests.tsx new file mode 100644 index 0000000000..4a9190000b --- /dev/null +++ b/types/react-burger-menu/react-burger-menu-tests.tsx @@ -0,0 +1,21 @@ +import * as React from 'react'; +import { slide as Menu } from 'react-burger-menu'; + +class Example extends React.Component<{}, {}> { + showSettings(event: { + preventDefault(): void; + }) { + event.preventDefault(); + } + + render() { + return ( + + Home + About + Contact + Settings + + ); + } +} diff --git a/types/react-burger-menu/tsconfig.json b/types/react-burger-menu/tsconfig.json new file mode 100644 index 0000000000..19dc806fbe --- /dev/null +++ b/types/react-burger-menu/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-burger-menu-tests.tsx" + ] +} diff --git a/types/react-burger-menu/tslint.json b/types/react-burger-menu/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-burger-menu/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-datepicker/index.d.ts b/types/react-datepicker/index.d.ts index f31f0316e1..aeb44be606 100644 --- a/types/react-datepicker/index.d.ts +++ b/types/react-datepicker/index.d.ts @@ -9,7 +9,7 @@ import * as React from "react"; import * as moment from "moment"; -interface ReactDatePickerProps { +export interface ReactDatePickerProps { autoComplete?: string; autoFocus?: boolean; calendarClassName?: string; diff --git a/types/react-dropzone/index.d.ts b/types/react-dropzone/index.d.ts index 0c944b99cd..c47b64d9bc 100644 --- a/types/react-dropzone/index.d.ts +++ b/types/react-dropzone/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-dropzone // Project: https://github.com/okonet/react-dropzone -// Definitions by: Mathieu Larouche Dube , Ivo Jesus , Luís Rodrigues +// Definitions by: Mathieu Larouche Dube , Ivo Jesus , Luís Rodrigues , Ben Bayard // Definitions: https://github.com/Vooban/DefinitelyTyped // TypeScript Version: 2.3 @@ -9,35 +9,38 @@ declare module "react-dropzone" { interface DropzoneProps { // Drop behavior - onDrop?: Function, - onDropAccepted?: Function, - onDropRejected?: Function, + onDrop?: (accepted: File[], rejected: File[]) => any; + onDropAccepted?: (accepted: File[]) => any; + onDropRejected?: (rejected: File[]) => any; // Drag behavior - onDragStart?: Function, - onDragEnter?: Function, - onDragLeave?: Function, + onDragStart?: Function; + onDragEnter?: Function; + onDragLeave?: Function; - style?: Object, // CSS styles to apply - activeStyle?: Object, // CSS styles to apply when drop will be accepted - rejectStyle?: Object, // CSS styles to apply when drop will be rejected - className?: string, // Optional className - activeClassName?: string, // className for accepted state - rejectClassName?: string, // className for rejected state + style?: React.CSSProperties; // CSS styles to apply + activeStyle?: React.CSSProperties; // CSS styles to apply when drop will be accepted + rejectStyle?: React.CSSProperties; // CSS styles to apply when drop will be rejected + className?: string; // Optional className + activeClassName?: string; // className for accepted state + rejectClassName?: string; // className for rejected state - disablePreview?: boolean, // Enable/disable preview generation - disableClick?: boolean, // Disallow clicking on the dropzone container to open file dialog + disablePreview?: boolean; // Enable/disable preview generation + disableClick?: boolean; // Disallow clicking on the dropzone container to open file dialog - inputProps?: Object, // Pass additional attributes to the tag - multiple?: boolean, // Allow dropping multiple files - accept?: string, // Allow specific types of files. See https://github.com/okonet/attr-accept for more information - name?: string, // name attribute for the input tag - maxSize?: number, - minSize?: number + inputProps?: React.ChangeTargetHTMLProps; // Pass additional attributes to the tag + multiple?: boolean; // Allow dropping multiple files + accept?: string; // Allow specific types of files. See https://github.com/okonet/attr-accept for more information + name?: string; // name attribute for the input tag + maxSize?: number; + minSize?: number; onFileDialogCancel?: () => void; } - let Dropzone: React.ClassicComponentClass; + class Dropzone extends React.Component { + open(): void; + } + export = Dropzone; } diff --git a/types/react-dropzone/react-dropzone-tests.tsx b/types/react-dropzone/react-dropzone-tests.tsx index aaa499a3e3..95c3886454 100644 --- a/types/react-dropzone/react-dropzone-tests.tsx +++ b/types/react-dropzone/react-dropzone-tests.tsx @@ -1,36 +1,45 @@ import * as React from 'react'; -import * as Dropzone from 'react-dropzone'; +import Dropzone = require('react-dropzone'); class Test extends React.Component { constructor(props: any) { super(props); } + dz: Dropzone; + + open() { + this.dz.open(); + } + render() { - return (
- { e.preventDefault(); } } - onDropAccepted={(e: any) => { e.preventDefault(); } } - onDropRejected={(e: any) => { e.preventDefault(); } } - onDragStart={(e: any) => { e.preventDefault(); } } - onDragEnter={(e: any) => { e.preventDefault(); } } - onDragLeave={(e: any) => { e.preventDefault(); } } - style={{ borderStyle: "dashed" }} - activeStyle={{ borderStyle: "dotted" }} - rejectStyle={{ borderStyle: "dotted" }} - className="regular" - activeClassName="active" - rejectClassName="reject" - minSize={2000} - maxSize={Infinity} - disablePreview={true} - disableClick={true} - multiple={false} - accept="*.png" - name="dropzone" - inputProps={{ id: "dropzone" }} + return ( +
+ { this.dz = node } } + onDrop={(e: any) => { e.preventDefault(); } } + onDropAccepted={(e: any) => { e.preventDefault(); } } + onDropRejected={(e: any) => { e.preventDefault(); } } + onDragStart={(e: any) => { e.preventDefault(); } } + onDragEnter={(e: any) => { e.preventDefault(); } } + onDragLeave={(e: any) => { e.preventDefault(); } } + style={{ borderStyle: "dashed" }} + activeStyle={{ borderStyle: "dotted" }} + rejectStyle={{ borderStyle: "dotted" }} + className="regular" + activeClassName="active" + rejectClassName="reject" + minSize={2000} + maxSize={Infinity} + disablePreview={true} + disableClick={true} + multiple={false} + accept="*.png" + name="dropzone" + inputProps={{ id: "dropzone" }} /> -
); +
+ ); } } diff --git a/types/react-lazyload/index.d.ts b/types/react-lazyload/index.d.ts index 2766d998b0..7ec2ae156c 100644 --- a/types/react-lazyload/index.d.ts +++ b/types/react-lazyload/index.d.ts @@ -24,3 +24,5 @@ export default class LazyLoad extends Component { } export function lazyload(option: {}): LazyLoad; + +export function forceCheck(): void; diff --git a/types/react-lazyload/react-lazyload-tests.tsx b/types/react-lazyload/react-lazyload-tests.tsx index 37b928a99c..ce9641dee4 100644 --- a/types/react-lazyload/react-lazyload-tests.tsx +++ b/types/react-lazyload/react-lazyload-tests.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import LazyLoad from "react-lazyload"; +import LazyLoad, { forceCheck } from "react-lazyload"; interface State { arr: string[]; @@ -14,6 +14,11 @@ class Normal extends React.Component<{}, State> { } this.state = { arr }; } + + componentDidMount() { + forceCheck(); + } + render() { return (
diff --git a/types/react-native-vector-icons/Entypo.d.ts b/types/react-native-vector-icons/Entypo.d.ts new file mode 100644 index 0000000000..b4e8bbc633 --- /dev/null +++ b/types/react-native-vector-icons/Entypo.d.ts @@ -0,0 +1,2 @@ +import { Icon } from './Icon'; +export default Icon; diff --git a/types/react-native-vector-icons/EvilIcons.d.ts b/types/react-native-vector-icons/EvilIcons.d.ts new file mode 100644 index 0000000000..b4e8bbc633 --- /dev/null +++ b/types/react-native-vector-icons/EvilIcons.d.ts @@ -0,0 +1,2 @@ +import { Icon } from './Icon'; +export default Icon; diff --git a/types/react-native-vector-icons/FontAwesome.d.ts b/types/react-native-vector-icons/FontAwesome.d.ts new file mode 100644 index 0000000000..b4e8bbc633 --- /dev/null +++ b/types/react-native-vector-icons/FontAwesome.d.ts @@ -0,0 +1,2 @@ +import { Icon } from './Icon'; +export default Icon; diff --git a/types/react-native-vector-icons/Foundation.d.ts b/types/react-native-vector-icons/Foundation.d.ts new file mode 100644 index 0000000000..b4e8bbc633 --- /dev/null +++ b/types/react-native-vector-icons/Foundation.d.ts @@ -0,0 +1,2 @@ +import { Icon } from './Icon'; +export default Icon; diff --git a/types/react-native-vector-icons/Icon.d.ts b/types/react-native-vector-icons/Icon.d.ts new file mode 100644 index 0000000000..3ae4916eea --- /dev/null +++ b/types/react-native-vector-icons/Icon.d.ts @@ -0,0 +1,197 @@ +import * as React from 'react'; +import { + TextStyle, + ViewStyle, + TextProperties, + TouchableHighlightProperties, + TouchableNativeFeedbackProperties, + TabBarIOSProperties, + ToolbarAndroidProperties +} from 'react-native'; + +export interface IconProps extends TextProperties { + /** + * Size of the icon, can also be passed as fontSize in the style object. + * + * @default 12 + * @type {string} + * @memberof IconProps + */ + size?: number; + + /** + * Name of the icon to show + * + * See Icon Explorer app + * {@link https://github.com/oblador/react-native-vector-icons/tree/master/Examples/IconExplorer} + * @type {string} + * @memberof IconProps + */ + name: string; + + /** + * Color of the icon + * + * @type {string} + * @memberof IconProps + */ + color?: string; +} + +export interface IconButtonProps extends IconProps, TouchableHighlightProperties, TouchableNativeFeedbackProperties { + /** + * Text and icon color + * Use iconStyle or nest a Text component if you need different colors. + * + * @default 'white' + * @type {string} + * @memberof IconButtonProps + */ + color?: string; + + /** + * Border radius of the button + * Set to 0 to disable. + * + * @default 5 + * @type {number} + * @memberof IconButtonProps + */ + borderRadius?: number; + + /** + * Styles applied to the icon only + * Good for setting margins or a different color. + * + * @default {marginRight: 10} + * @type {ViewStyle} + * @memberof IconButtonProps + */ + iconStyle?: ViewStyle; + + /** + * Style prop inherited from TextProperties and TouchableWithoutFeedbackProperties + * Only exist here so we can have ViewStyle or TextStyle + * + * @type {(ViewStyle | TextStyle)} + * @memberof IconButtonProps + */ + style?: ViewStyle | TextStyle; + + /** + * Background color of the button + * + * @default '#007AFF' + * @type {string} + * @memberof IconButtonProps + */ + backgroundColor?: string; +} + +export type ImageSource = any; + +export interface TabBarIOSProps extends TabBarIOSProperties { + /** + * Name of the default icon (similar to TabBarIOS.Item icon) + * + * @type {string} + * @memberof TabBarIOSProps + */ + iconName: string; + + /** + * Name of the selected icon (similar to TabBarIOS.Item selectedIcon). + * + * @default iconName + * @type {string} + * @memberof TabBarIOSProps + */ + selectedIconName: string; + + /** + * Size of the icon. + * + * @default 30 + * @type {number} + * @memberof TabBarIOSProps + */ + iconSize: number; + + /** + * Color of the icon + * + * @type {string} + * @memberof TabBarIOSProps + */ + iconColor: string; + + /** + * Color of the selected icon. + * + * @default iconColor + * @type {string} + * @memberof TabBarIOSProps + */ + selectedIconColor: string; +} + +export interface ToolbarAndroidProps extends ToolbarAndroidProperties { + /** + * Name of the navigation logo icon + * (similar to ToolbarAndroid logo) + * + * @type {string} + * @memberof ToolbarAndroidProps + */ + logoName: string; + + /** + * Name of the navigation icon + * (similar to ToolbarAndroid navIcon) + * + * @type {string} + * @memberof ToolbarAndroidProps + */ + navIconName: string; + + /** + * Name of the overflow icon + * (similar to ToolbarAndroid overflowIcon) + * + * @type {string} + * @memberof ToolbarAndroidProps + */ + overflowIconName: string; + + /** + * Size of the icons + * + * @default 24 + * @type {number} + * @memberof ToolbarAndroidProps + */ + iconSize: number; + + /** + * Color of the icons + * + * @default 'black' + * @type {string} + * @memberof ToolbarAndroidProps + */ + iconColor: string; +} + +export class Icon extends React.Component { + static getImageSource( + name: string, + color: string, + size?: number + ): Promise; +} + +export namespace Icon { + class ToolbarAndroid extends React.Component {} + class TabBarIOS extends React.Component {} + class Button extends React.Component {} +} diff --git a/types/react-native-vector-icons/Ionicons.d.ts b/types/react-native-vector-icons/Ionicons.d.ts new file mode 100644 index 0000000000..b4e8bbc633 --- /dev/null +++ b/types/react-native-vector-icons/Ionicons.d.ts @@ -0,0 +1,2 @@ +import { Icon } from './Icon'; +export default Icon; diff --git a/types/react-native-vector-icons/MaterialCommunityIcons.d.ts b/types/react-native-vector-icons/MaterialCommunityIcons.d.ts new file mode 100644 index 0000000000..b4e8bbc633 --- /dev/null +++ b/types/react-native-vector-icons/MaterialCommunityIcons.d.ts @@ -0,0 +1,2 @@ +import { Icon } from './Icon'; +export default Icon; diff --git a/types/react-native-vector-icons/MaterialIcons.d.ts b/types/react-native-vector-icons/MaterialIcons.d.ts new file mode 100644 index 0000000000..b4e8bbc633 --- /dev/null +++ b/types/react-native-vector-icons/MaterialIcons.d.ts @@ -0,0 +1,2 @@ +import { Icon } from './Icon'; +export default Icon; diff --git a/types/react-native-vector-icons/Octicons.d.ts b/types/react-native-vector-icons/Octicons.d.ts new file mode 100644 index 0000000000..b4e8bbc633 --- /dev/null +++ b/types/react-native-vector-icons/Octicons.d.ts @@ -0,0 +1,2 @@ +import { Icon } from './Icon'; +export default Icon; diff --git a/types/react-native-vector-icons/SimpleLineIcons.d.ts b/types/react-native-vector-icons/SimpleLineIcons.d.ts new file mode 100644 index 0000000000..b4e8bbc633 --- /dev/null +++ b/types/react-native-vector-icons/SimpleLineIcons.d.ts @@ -0,0 +1,2 @@ +import { Icon } from './Icon'; +export default Icon; diff --git a/types/react-native-vector-icons/Zocial.d.ts b/types/react-native-vector-icons/Zocial.d.ts new file mode 100644 index 0000000000..b4e8bbc633 --- /dev/null +++ b/types/react-native-vector-icons/Zocial.d.ts @@ -0,0 +1,2 @@ +import { Icon } from './Icon'; +export default Icon; diff --git a/types/react-native-vector-icons/index.d.ts b/types/react-native-vector-icons/index.d.ts new file mode 100644 index 0000000000..d46847b1ae --- /dev/null +++ b/types/react-native-vector-icons/index.d.ts @@ -0,0 +1,61 @@ +// Type definitions for react-native-vector-icons 4.2 +// Project: https://github.com/oblador/react-native-vector-icons +// Definitions by: Kyle Roach +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from 'react'; +import { Icon } from './Icon'; +import { TextProperties } from 'react-native'; + +/** + * Returns your own custom font based on the glyphMap where the key is the icon name + * and the value is either a UTF-8 character or it's character code. fontFamily is the name + * of the font NOT the filename. Open the font in Font Book.app or similar to learn the name. + * Optionally pass the third fontFile argument for android support, it should be a path + * to the font file in you asset folder. + * + * @param glyphMap + * @param fontFamily + * @param fontFile + */ +export function createIconSet( + glyphMap: {}, + fontFamily: string, + fontFile?: string +): Icon; + +/** + * Convenience method to create a custom font based on a fontello config file. + * Don't forget to import the font as described above and drop the config.json + * somewhere convenient in your project. + * + * Example usage + * import { createIconSetFromFontello } from 'react-native-vector-icons'; + * import fontelloConfig from './config.json'; + * const Icon = createIconSetFromFontello(fontelloConfig); + * + * @see http://fontello.com + * @export + * @param {{}} config + * @returns {Icon} + */ +export function createIconSetFromFontello(config: {}): Icon; + +/** + * Convenience method to create a custom font from IcoMoon + * Make sure you're using the Download option in IcoMoon, and use the .json file that's + * included in the .zip you've downloaded. You'll also need to import the .ttf font + * file into your project + * + * Example usage + * import { createIconSetFromIcoMoon } from 'react-native-vector-icons'; + * import icoMoonConfig from './config.json'; + * const Icon = createIconSetFromIcoMoon(icoMoonConfig); + * + * @see https://icomoon.io/app + * @export + * @param {{}} config + * @returns {Icon} + */ +export function createIconSetFromIcoMoon(config: {}): Icon; diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx new file mode 100644 index 0000000000..270c8fbdc4 --- /dev/null +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -0,0 +1,30 @@ +import * as React from 'react'; +import { View, Text } from 'react-native'; +import MaterialIcon from 'react-native-vector-icons/MaterialIcons'; +import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; + +class Example extends React.Component<{}, {}> { + handleButton() { + console.log('You pressed me'); + } + + render() { + return ( + + {/* Normal Icon */} + + + {/* Icon button */} + this.handleButton()} + > + + Login with Facebook + + + + ); + } +} diff --git a/types/react-native-vector-icons/tsconfig.json b/types/react-native-vector-icons/tsconfig.json new file mode 100644 index 0000000000..746ae7e0ff --- /dev/null +++ b/types/react-native-vector-icons/tsconfig.json @@ -0,0 +1,35 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "Icon.d.ts", + "Entypo.d.ts", + "EvilIcons.d.ts", + "FontAwesome.d.ts", + "Foundation.d.ts", + "Ionicons.d.ts", + "MaterialCommunityIcons.d.ts", + "MaterialIcons.d.ts", + "Octicons.d.ts", + "SimpleLineIcons.d.ts", + "Zocial.d.ts", + "react-native-vector-icons-tests.tsx" + ] +} diff --git a/types/react-native-vector-icons/tslint.json b/types/react-native-vector-icons/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-vector-icons/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 06e777a270..5f9e6e3856 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -1,6 +1,10 @@ // Type definitions for react-native 0.44 // Project: https://github.com/facebook/react-native -// Definitions by: Eloy Durán , Fedor Nezhivoi , HuHuanming , Jeremi Stadler , Kyle Roach +// Definitions by: Eloy Durán +// Fedor Nezhivoi +// HuHuanming +// Jeremi Stadler +// Kyle Roach // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 829c897a6e..1d07494104 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -3,35 +3,46 @@ // Definitions by: Huhuanming // mhcgrq // fangpenlin +// abrahambotros +// petejkim // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as React from 'react' +/** + * BEGIN FLOW TYPEDEFINITION.JS PORT + * Reference: https://github.com/react-community/react-navigation/tree/52a2846e77119148320bcea83b8982a8bc6acce3 + * + * NOTE: Please update the commit/link above when updating to a new Flow + * TypeDefinition.js reference, so we can conveniently just look at diffs on + * TypeDefinition.js between this latest reference point and the one you are + * using when making new updates. + */ + +import * as React from 'react'; import { Animated, + TextStyle, ViewStyle, - TextStyle -} from 'react-native' +} from 'react-native'; -export type HeaderMode = 'float' | 'screen' | 'none' +// @todo when we split types into common, native and web, +// we can properly change Animated.Value to its real value +type AnimatedValue = any; -export function addNavigationHelpers(params: any): any - -type SubViewProps = NavigationSceneRendererProps & { - onNavigateBack?: () => void, -} - -type SubViewRenderer = (subViewProps: SubViewProps) => React.ReactElement | undefined +export type HeaderMode = 'float' | 'screen' | 'none'; export type HeaderProps = NavigationSceneRendererProps & { mode: HeaderMode, - onNavigateBack?: () => void, - renderLeftComponent: SubViewRenderer, - renderRightComponent: SubViewRenderer, - renderTitleComponent: SubViewRenderer, - tintColor?: string, - router: NavigationRouter, -} + router: NavigationRouter< + NavigationState, + NavigationAction, + NavigationStackScreenOptions + >, + getScreenDetails: (navigationScene: NavigationScene) => NavigationScreenDetails< + NavigationStackScreenOptions + >, + style: Style, +}; /** * NavigationState is a tree of routes for a single navigator, where each child @@ -46,15 +57,17 @@ export type HeaderProps = NavigationSceneRendererProps & { * The state for the root navigator of our app represents the whole navigation * state for the whole app. */ -export interface NavigationState { +export type NavigationState = { /** * Index refers to the active child route in the routes array. */ index: number, - routes: any[], -} + routes: Array, +}; -export interface NavigationRoute

{ +export type NavigationRoute = NavigationLeafRoute | NavigationStateRoute; + +export type NavigationLeafRoute = { /** * React's key used by some navigators. No need to specify these manually, * they will be defined by the router. @@ -73,174 +86,110 @@ export interface NavigationRoute

{ * Params passed to this route when navigating to it, * e.g. `{ car_id: 123 }` in a route that displays a car. */ - params: P, -} + params?: Params, +}; -export interface NavigationRouter { +export type NavigationStateRoute = NavigationLeafRoute & { + index: number, + routes: Array>, +}; + +export type NavigationScreenOptionsGetter = ( + navigation: NavigationScreenProp, Action>, + screenProps?: { [key: string]: any } +) => Options; + +export type NavigationRouter = { /** * The reducer that outputs the new navigation state for a given action, with * an optional previous state. When the action is considered handled but the * state is unchanged, the output state is null. */ - getStateForAction: ( - action: NavigationAction, - lastState?: NavigationState, - ) => NavigationState | undefined, + getStateForAction: (action: Action, lastState: (State | null)) => (State | null), /** * Maps a URI-like string to an action. This can be mapped to a state * using `getStateForAction`. */ - getActionForPathAndParams: (path: string, params?: NavigationParams) => NavigationAction | undefined, + getActionForPathAndParams: ( + path: string, + params?: NavigationParams + ) => (Action | null), - getPathAndParamsForState: (state: NavigationState) => { path: string, params?: NavigationParams }, + getPathAndParamsForState: ( + state: State + ) => { + path: string, + params?: NavigationParams, + }, getComponentForRouteName: (routeName: string) => NavigationComponent, - getComponentForState: (state: NavigationState) => NavigationComponent, + getComponentForState: (state: State) => NavigationComponent, /** - * Gets the screen config for a given navigation screen prop. + * Gets the screen navigation options for a given screen. * - * For example, we could get the config for a 'Foo' screen when the + * For example, we could get the config for the 'Foo' screen when the * `navigation.state` is: * * {routeName: 'Foo', key: '123'} */ - getScreenConfig: ( - navigation: NavigationScreenProp, - optionName: string, - ) => any, // todo, fix this any type to become a key of NavigationScreenConfig -} + getScreenOptions: NavigationScreenOptionsGetter, +}; -type NavigationFunc = (navigation: NavigationScreenProp, config: E) => E +export type NavigationScreenOption = + T + | (( + navigation: NavigationScreenProp, NavigationAction>, + config: T + ) => T); -export type NavigationScreenOption = T | NavigationFunc +export type Style = ViewStyle; -export interface HeaderConfig { - /** - * Title string used by the navigation bar, or a custom component - */ - title?: string | React.ReactElement; +export type NavigationScreenDetails = { + options: T, + state: NavigationRoute, + navigation: NavigationScreenProp, NavigationAction>, +}; - /** - * Whether the navigation bar is visible. - */ - visible?: boolean; - - /** - * Renders a custom right component - */ - right?: React.ReactElement, - - /** - * Renders a custom left component - */ - left?: React.ReactElement - - /** - * Style passed into navigation bar container - */ - style?: ViewStyle, - - /** - * Style passed into navigation bar title - */ - titleStyle?: TextStyle, - - // // Style of title text - // titleTextStyle?: $NavigationThunk, - // // Tint color of navigation bar contents - // tintColor?: $NavigationThunk, - // // Navigation bar height - // height?: $NavigationThunk, - // // Navigation bar translucentcy - // translucent?: $NavigationThunk, - // // Renders a custom left component - // renderLeft?: React.Element<*> | - // (navigation: NavigationProp<*>, canGoBack: boolean) => React.Element<*>, - // // Renders a custom navigation bar background - // renderBackground?: $NavigationThunk>, -} - -export interface TabBarConfig { - /** - * Icon used by the tab bar. - */ - icon?: (options: { tintColor: string, focused: boolean }) => React.ReactElement | undefined; - /** - * Label text used by the tab bar. - */ - label?: string | React.ReactElement; -} - -export interface DrawerConfig { - /** - * Icon used by the drawer. - */ - icon?: (options: { tintColor: string, focused: boolean }) => React.ReactElement | undefined; - /** - * Label text used by the drawer. - */ - label?: string; -} - -export interface CardStackConfig { - /** - * Whether you can use gestures to dismiss this screen. - * Defaults to true on iOS, false on Android. - */ - gesturesEnabled?: boolean; -} - -export interface NavigationScreenOptions { - /** - * Title is rendered by certain navigators, e.g. the tab navigator, - * or on web as the title of the browser tab. - */ - title?: NavigationScreenOption; - /** - * Options passed to the navigation bar for this screen. - */ - header?: NavigationScreenOption; - /** - * Options passed to the tab bar for this screen. - */ - tabBar?: NavigationScreenOption; - /** - * Options passed to the drawer for this screen. - */ - drawer?: NavigationScreenOption; - /** - * Options passed to the card stack for this screen. - */ - cardStack?: NavigationScreenOption; -} - -export interface NavigationScreenConfig { +export type NavigationScreenOptions = { title?: string, - header?: HeaderConfig, - tabBar?: TabBarConfig, - drawer?: DrawerConfig; -} +}; -export type NavigationComponent = NavigationScreenComponent | NavigationNavigator +export type NavigationScreenConfigProps = { + navigation: NavigationScreenProp, NavigationAction>, + screenProps: { [key: string]: any } +}; -export type NavigationScreenComponent = React.ComponentClass & { - navigationOptions?: NavigationScreenOptions, -} +export type NavigationScreenConfig = + Options + | (NavigationScreenConfigProps & + ((navigationOptionsContainer: { + navigationOptions: NavigationScreenProp< + NavigationRoute, + NavigationAction + >, + }) => Options)); -export type NavigationNavigator = React.ComponentClass & { - router?: NavigationRouter, - navigationOptions?: NavigationScreenOptions, -} +export type NavigationComponent = + NavigationScreenComponent + | NavigationNavigator; + +export type NavigationScreenComponent = React.ComponentClass & { + navigationOptions?: NavigationScreenConfig, +}; + +export type NavigationNavigator = React.ComponentClass & { + router?: NavigationRouter, + navigationOptions?: NavigationScreenConfig, +}; export interface NavigationParams { [key: string]: any, } -export interface NavigationNavigateAction { - type?: 'Navigation/NAVIGATE', +export interface NavigationNavigateActionPayload { routeName: string, params?: NavigationParams, @@ -248,14 +197,19 @@ export interface NavigationNavigateAction { action?: NavigationNavigateAction, } -export interface NavigationBackAction { - type?: 'Navigation/BACK', - key?: string, +export interface NavigationNavigateAction extends NavigationNavigateActionPayload { + type: 'Navigation/NAVIGATE', } -export interface NavigationSetParamsAction { - type?: 'Navigation/SET_PARAMS', +export interface NavigationBackActionPayload { + key?: string | null, +} +export interface NavigationBackAction extends NavigationBackActionPayload { + type: 'Navigation/BACK', +} + +export interface NavigationSetParamsActionPayload { // The key of the route where the params should be set key: string, @@ -263,46 +217,65 @@ export interface NavigationSetParamsAction { params?: NavigationParams, } -export interface NavigationInitAction { - type?: 'Navigation/INIT', +export interface NavigationSetParamsAction extends NavigationSetParamsActionPayload { + type: 'Navigation/SET_PARAMS', +} + +export interface NavigationInitActionPayload { params?: NavigationParams, } -export interface NavigationResetAction { - type?: 'Navigation/RESET', - index: number, - key?: string | null, - actions: NavigationNavigateAction[], +export interface NavigationInitAction extends NavigationInitActionPayload { + type: 'Navigation/INIT', } -export interface NavigationUriAction { - type?: 'Navigation/URI', +export interface NavigationResetActionPayload { + index: number, + key?: string | null, + actions: Array, +} + +export interface NavigationResetAction extends NavigationResetActionPayload { + type: 'Navigation/RESET', +} + +export interface NavigationUriActionPayload { uri: string, } -export interface NavigationContainerOptions { - // This is used to extract the path from the URI passed to the app for a deep link - URIPrefix?: string, -} - -export interface NavigationContainerConfig { - containerOptions?: NavigationContainerOptions, +export interface NavigationUriAction extends NavigationUriActionPayload { + type: 'Navigation/URI', } export interface NavigationStackViewConfig { mode?: 'card' | 'modal', headerMode?: HeaderMode, - headerComponent?: React.ComponentClass, - cardStyle?: ViewStyle, + cardStyle?: Style, + transitionConfig?: () => TransitionConfig, onTransitionStart?: () => void, onTransitionEnd?: () => void, } +export type NavigationStackScreenOptions = NavigationScreenOptions & { + header?: (React.ReactElement | ((headerProps: HeaderProps) => React.ReactElement)) | null, + headerTitle?: string | React.ReactElement, + headerTitleStyle?: Style, + headerTintColor?: string, + headerLeft?: React.ReactElement, + headerBackTitle?: string, + headerTruncatedBackTitle?: string, + headerBackTitleStyle?: Style, + headerPressColorAndroid?: string, + headerRight?: React.ReactElement, + headerStyle?: Style, + gesturesEnabled?: boolean, +}; + export interface NavigationStackRouterConfig { initialRouteName?: string, initialRouteParams?: NavigationParams, paths?: NavigationPathsConfig, - navigationOptions?: NavigationScreenOptions, + navigationOptions?: NavigationScreenConfig, } export type NavigationStackAction = @@ -310,238 +283,279 @@ export type NavigationStackAction = | NavigationNavigateAction | NavigationBackAction | NavigationSetParamsAction - | NavigationResetAction + | NavigationResetAction; export type NavigationTabAction = NavigationInitAction | NavigationNavigateAction - | NavigationBackAction + | NavigationBackAction; export type NavigationAction = NavigationInitAction | NavigationStackAction - | NavigationTabAction - -export namespace NavigationActions { - function init(options?: NavigationInitAction): NavigationInitAction; - function navigate(options: NavigationNavigateAction): NavigationNavigateAction; - function reset(options: NavigationResetAction): NavigationResetAction; - function back(options?: NavigationBackAction): NavigationBackAction; - function setParams(options: NavigationSetParamsAction): NavigationSetParamsAction; -} + | NavigationTabAction; export type NavigationRouteConfig = T & { - navigationOptions?: NavigationScreenOptions, + navigationOptions?: NavigationScreenConfig, path?: string, -} +}; -export interface NavigationPathsConfig { +export type NavigationScreenRouteConfig = + { + screen: NavigationComponent, + } + | { + getScreen: () => NavigationComponent, + }; + +export type NavigationPathsConfig = { [routeName: string]: string, -} +}; export interface NavigationTabRouterConfig { initialRouteName?: string, paths?: NavigationPathsConfig, - navigationOptions?: NavigationScreenOptions, - order?: string[], // todo: type these as the real route names rather than 'string' + navigationOptions?: NavigationScreenConfig, + order?: Array, // todo: type these as the real route names rather than 'string' // Does the back button cause the router to switch to the initial tab backBehavior?: 'none' | 'initialRoute', // defaults `initialRoute` } -export interface NavigationRouteConfigMap { +export type NavigationTabScreenOptions = NavigationScreenOptions & { + tabBarIcon?: + React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)), + tabBarLabel?: + string + | React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)), + tabBarVisible?: boolean, +}; + +export type NavigationDrawerScreenOptions = NavigationScreenOptions & { + drawerIcon?: + React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)), + drawerLabel?: + React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)), +}; + +export type NavigationRouteConfigMap = { [routeName: string]: NavigationRouteConfig, -} +}; -export type NavigationDispatch = (action: A) => boolean +export type NavigationDispatch = (action: A) => boolean; -export interface NavigationProp { +export type NavigationProp = { state: S, dispatch: NavigationDispatch, -} +}; -export type NavigationScreenProp = NavigationProp & { - goBack: (routeKey?: string | null) => boolean, - navigate: (routeName: string, params?: NavigationParams, action?: NavigationAction) => boolean, +export type NavigationScreenProp = { + state: S, + dispatch: NavigationDispatch, + goBack: (routeKey?: (string | null)) => boolean, + navigate: ( + routeName: string, + params?: NavigationParams, + action?: NavigationAction + ) => boolean, setParams: (newParams: NavigationParams) => boolean, -} +}; -export interface NavigationNavigatorProps

{ - navigation: NavigationProp, NavigationAction>, -} +export type NavigationNavigatorProps = { + navigation?: NavigationProp, + screenProps?: { [key: string]: any } + navigationOptions?: any, +}; /** * Gestures, Animations, and Interpolators */ -export type NavigationAnimatedValue = Animated.Value +export type NavigationGestureDirection = 'horizontal' | 'vertical'; -export type NavigationGestureDirection = 'horizontal' | 'vertical' - -export interface NavigationLayout { - height: NavigationAnimatedValue, +export type NavigationLayout = { + height: AnimatedValue, initHeight: number, initWidth: number, isMeasured: boolean, - width: NavigationAnimatedValue, -} + width: AnimatedValue, +}; -export interface NavigationScene { +export type NavigationScene = { index: number, isActive: boolean, isStale: boolean, key: string, - route: any, -} + route: NavigationRoute, +}; -export interface NavigationTransitionProps { - // The layout of the transitioner of the scenes. +export type NavigationTransitionProps = { + // The layout of the screen container layout: NavigationLayout, - // The navigation state of the transitioner. - navigationState: NavigationState, + // The destination navigation state of the transition + navigation: NavigationScreenProp, // The progressive index of the transitioner's navigation state. - position: NavigationAnimatedValue, + position: AnimatedValue, // The value that represents the progress of the transition when navigation // state changes from one to another. Its numberic value will range from 0 // to 1. // progress.__getAnimatedValue() < 1 : transtion is happening. // progress.__getAnimatedValue() == 1 : transtion completes. - progress: NavigationAnimatedValue, + progress: AnimatedValue, // All the scenes of the transitioner. - scenes: NavigationScene[], + scenes: Array, // The active scene, corresponding to the route at - // `navigationState.routes[navigationState.index]`. When rendering + // `navigation.state.routes[navigation.state.index]`. When rendering // NavigationSceneRendererPropsIndex, the scene does not refer to the active // scene, but instead the scene that is being rendered. The index always // is the index of the scene scene: NavigationScene, index: number, - navigation: NavigationScreenProp, - // The gesture distance for `horizontal` and `vertical` transitions - gestureResponseDistance?: number, -} + screenProps?: { [key: string]: any } +}; // The scene renderer props are nearly identical to the props used for rendering // a transition. The exception is that the passed scene is not the active scene // but is instead the scene that the renderer should render content for. -export type NavigationSceneRendererProps = NavigationTransitionProps +export type NavigationSceneRendererProps = NavigationTransitionProps; -export interface NavigationPanHandlers { - onMoveShouldSetResponder: () => void, - onMoveShouldSetResponderCapture: () => void, - onResponderEnd: () => void, - onResponderGrant: () => void, - onResponderMove: () => void, - onResponderReject: () => void, - onResponderRelease: () => void, - onResponderStart: () => void, - onResponderTerminate: () => void, - onResponderTerminationRequest: () => void, - onStartShouldSetResponder: () => void, - onStartShouldSetResponderCapture: () => void, -} - -export interface NavigationTransitionSpec { +export type NavigationTransitionSpec = { duration?: number, // An easing function from `Easing`. - easing?: () => any, + easing?: (t: number) => number, // A timing function such as `Animated.timing`. - timing?: (value: NavigationAnimatedValue, config: any) => any, -} + timing?: (value: AnimatedValue, config: any) => any, +}; + +/** + * Describes a visual transition from one screen to another. + */ +export type TransitionConfig = { + // The basics properties of the animation, such as duration and easing + transitionSpec?: NavigationTransitionSpec, + // How to animate position and opacity of the screen + // based on the value generated by the transitionSpec + screenInterpolator?: (props: NavigationSceneRendererProps) => any, +}; export type NavigationAnimationSetter = ( - position: NavigationAnimatedValue, + position: AnimatedValue, newState: NavigationState, - lastState: NavigationState, -) => void + lastState: NavigationState +) => void; -export type NavigationSceneRenderer = ( - props: NavigationSceneRendererProps, -) => React.ReactElement +export type NavigationSceneRenderer = () => (React.ReactElement | null); export type NavigationStyleInterpolator = ( - props: NavigationSceneRendererProps, -) => ViewStyle + props: NavigationSceneRendererProps +) => Style; -export interface LayoutEvent { +export type LayoutEvent = { nativeEvent: { layout: { - x: number; - y: number; - width: number; - height: number; + x: number, + y: number, + width: number, + height: number, }, - } -} + }, +}; +/** + * END FLOW TYPEDEFINITION.JS PORT + */ + + +/** + * BEGIN MANUAL DEFINITIONS OUTSIDE OF TYPEDEFINITION.JS + */ + +// From addNavigatorHelpers.js +export function addNavigationHelpers(navigation: NavigationProp): NavigationScreenProp; + +// From createNavigationContainer.js interface NavigationContainerProps { - screenProps?: any - navigation?: NavigationProp + uriPrefix?: string | RegExp, onNavigationStateChange?: ( - preNavigationState: NavigationState, + prevNavigationState: NavigationState, nextNavigationState: NavigationState, + action: NavigationAction, ) => void, - style?: ViewStyle -} - -interface NavigationContainerState { - nav?: NavigationState + style?: ViewStyle, } export interface NavigationContainer extends React.ComponentClass< - NavigationContainerProps + NavigationContainerProps & NavigationNavigatorProps > { - router: NavigationRouter + router: NavigationRouter + screenProps: { [key: string]: any }, + navigationOptions: any, + state: { nav: NavigationState | null }, } -export type StackNavigatorConfig = - NavigationContainerConfig - & NavigationStackViewConfig - & NavigationStackRouterConfig; +export interface StackNavigatorConfig extends NavigationStackViewConfig, NavigationStackRouterConfig { + containerOptions?: any, +} // Return createNavigationContainer -export function StackNavigator( +export function StackNavigator( routeConfigMap: NavigationRouteConfigMap, stackConfig?: StackNavigatorConfig, -): NavigationContainer +): NavigationContainer; /** * Drawer Navigator */ -export interface DrawNavigatorConfig { - drawerWidth?: number, - drawerPosition?: 'left'|'right', - contentComponent?: React.ReactElement, +export interface DrawerViewConfig { + drawerWidth: number, + drawerPosition: 'left' | 'right', + contentComponent: React.ComponentClass, + contentOptions?: any, + style?: ViewStyle, +} +export interface DrawerNavigatorConfig extends NavigationTabRouterConfig, DrawerViewConfig { + containerConfig?: any, contentOptions?: { activeTintColor?: string, activeBackgroundColor?: string, inactiveTintColor?: string, inactiveBackgroundColor?: string, style?: ViewStyle, - labelStyle?: TextStyle + labelStyle?: TextStyle, } } -export function DrawerNavigator( +export function DrawerNavigator( routeConfigMap: NavigationRouteConfigMap, - drawConfig?: DrawNavigatorConfig, + drawerConfig?: DrawerNavigatorConfig, ): NavigationContainer; /** * Tab Navigator */ -export interface TabNavigatorConfig { - tabBarComponent?: React.ReactElement, - tabBarPosition?: 'top'|'bottom', - swipeEnabled?: boolean, - animationEnabled?: boolean, - lazy?: boolean, + +// From views/TabView/TabView.js +export interface TabViewConfig { + tabBarComponent?: React.ComponentClass, + tabBarPosition?: 'top' | 'bottom', tabBarOptions?: { activeTintColor?: string, activeBackgroundColor?: string, @@ -559,104 +573,81 @@ export interface TabNavigatorConfig { scrollEnabled?: boolean, tabStyle?: ViewStyle, indicatorStyle?: ViewStyle - } - initialRouteName?: string, - order?: string[], - paths?: any // TODO: better def - backBehavior?: 'initialRoute'|'none' + }, + swipeEnabled?: boolean, + animationEnabled?: boolean, + lazy?: boolean, } -export function TabNavigator( +// From navigators/TabNavigator.js +export interface TabNavigatorConfig extends NavigationTabRouterConfig, TabViewConfig { } + +// From navigators/TabNavigator.js +export function TabNavigator( routeConfigMap: NavigationRouteConfigMap, drawConfig?: TabNavigatorConfig, ): NavigationContainer; + +export const TabBarTop: React.ComponentClass; +export const TabBarBottom: React.ComponentClass; + /** - * Screen Options + * NavigationActions */ -export interface StackNavigatorScreenOptions { - title?: string; - headerVisible?: boolean; - headerTitle?: string|React.ReactElement; - headerBackTitle?: string; - headerTruncatedBackTitle?: string; - headerRight?: React.ReactElement; - headerLeft?: React.ReactElement; - headerStyle?: ViewStyle; - headerTitleStyle?: ViewStyle; - headerTintColor?: string; - headerPressColorAndroid?: string; - gesturesEnabled?: boolean; +export namespace NavigationActions { + export function init(options?: NavigationInitActionPayload): NavigationInitAction; + export function navigate(options: NavigationNavigateActionPayload): NavigationNavigateAction; + export function reset(options: NavigationResetActionPayload): NavigationResetAction; + export function back(options?: NavigationBackActionPayload): NavigationBackAction; + export function setParams(options: NavigationSetParamsActionPayload): NavigationSetParamsAction; } -export interface TabNavigatorScreenOptions { - title?: string; - tabBarVisible?: boolean; - tabBarIcon?: React.ReactElement - | ((options: { focused: boolean, tintColor: string }) => React.ReactElement); - tabBarLabel?: string - | React.ReactElement - | ((options: { focused: boolean, tintColor: string }) => React.ReactElement); -} - -export interface DrawerNavigatorScreenOptions { - title?: string; - drawerLabel?: string - |React.ReactElement - | ((options: {focused: boolean, tintColor: string}) => React.ReactElement) - ; - drawerIcon?: React.ReactElement - | ((options: {focused: boolean, tintColor: string}) => React.ReactElement) - ; -} - -export type NavigationNavigateActionCreator = (options: NavigationNavigateAction) => boolean; -export type NavigationResetActionCreator = (options: NavigationResetAction) => boolean; -export type NavigationBackActionCreator = (options?: NavigationBackAction) => boolean; -export type NavigationSetParamsActionCreator = (options: NavigationSetParamsAction) => boolean; - -export interface NavigationComponentProps { - screenProps: any - navigation: { - dispatch: any - goBack: NavigationBackActionCreator - navigate: NavigationNavigateActionCreator - setParams: NavigationSetParamsActionCreator - state: { - key: string - routeName: string, - params: T, - }, - } -} - -export const TabBarTop: React.ReactElement; -export const TabBarBottom: React.ReactElement; - +/** + * Transitioner + * @desc From react-navigation/src/views/Transitioner.js + */ interface TransitionerProps { configureTransition: ( transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps - ) => NavigationTransitionSpec - navigation: NavigationProp - onTransitionEnd?: () => void - onTransitionStart?: () => void + ) => NavigationTransitionSpec, + navigation: NavigationScreenProp, + onTransitionEnd?: () => void, + onTransitionStart?: () => void, render: ( transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps ) => any - style?: ViewStyle + style?: ViewStyle, } interface TransitionerState { - layout: NavigationLayout - position: Animated.Value - progress: Animated.Value - scenes: Array + layout: NavigationLayout, + position: Animated.Value, + progress: Animated.Value, + scenes: Array, } export class Transitioner extends React.Component< TransitionerProps, TransitionerState -> { +> { } +/** + * END MANUAL DEFINITIONS OUTSIDE OF TYPEDEFINITION.JS + */ + + +/** + * BEGIN CUSTOM CONVENIENCE INTERFACES + */ + +export interface NavigationScreenProps { + navigation: NavigationScreenProp, NavigationAction>, + screenProps?: { [key: string]: any }, + navigationOptions?: NavigationScreenConfig, } + +/** + * END CUSTOM CONVENIENCE INTERFACES + */ diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 738bd8c456..1840fd7ccf 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -1,81 +1,261 @@ import * as React from 'react'; -import { View } from 'react-native'; import { - addNavigationHelpers, - StackNavigator, - TabNavigatorScreenOptions, - TabNavigatorConfig, - TabBarTop, - TabBarBottom, - NavigationProp, + TouchableOpacity, + View, + ViewStyle, +} from 'react-native'; +import { NavigationAction, + NavigationActions, + NavigationBackAction, + NavigationInitAction, + NavigationNavigateAction, + NavigationProp, + NavigationResetAction, + NavigationRouteConfigMap, + NavigationScreenProp, + NavigationScreenProps, + NavigationSetParamsAction, + NavigationStackAction, + NavigationStackScreenOptions, + NavigationTabScreenOptions, NavigationTransitionProps, - Transitioner + StackNavigator, + StackNavigatorConfig, + TabBarTop, + TabNavigator, + TabNavigatorConfig, + Transitioner, + addNavigationHelpers, } from 'react-navigation'; -const Start = ( - +// Constants +const viewStyle: ViewStyle = { + flex: 1, + margin: 42, + padding: 0, + backgroundColor: "white", +}; + + +/** + * @class StartScreen @extends React.Component + * @desc Simple screen component class with typed component props that should + * receive the navigation prop from the AppNavigator. + */ +const ROUTE_NAME_START_SCREEN = "StartScreen"; +interface StartScreenNavigationParams { + id: number, + s: string, +} + +interface StartScreenProps extends NavigationScreenProps { } +class StartScreen extends React.Component { + render() { + // Implicit type checks. + const navigationStateParams: StartScreenNavigationParams = this.props.navigation.state.params; + const id = this.props.navigation.state.params.id; + const s = this.props.navigation.state.params.s; + + return ( + + + + ); + } + private navigateToNextScreen = (): void => { + this.props.navigation.navigate( + ROUTE_NAME_NEXT_SCREEN, + { + id: this.props.navigation.state.params.id, + name: this.props.navigation.state.params.s, + } as NextScreenNavigationParams, + ); + + } +} + +/** + * @class NextScreen @extends React.Component + */ +const ROUTE_NAME_NEXT_SCREEN = "NextScreen"; +interface NextScreenNavigationParams { + id: number, + name: string, +} +interface NextScreenProps extends NavigationScreenProps { } +class NextScreen extends React.Component { + render() { + // Implicit type checks. + const navigationStateParams: NextScreenNavigationParams = this.props.navigation.state.params; + const id = this.props.navigation.state.params.id; + const name = this.props.navigation.state.params.name; + + return ( + + ); + } +} + +const initialRouteParams: StartScreenNavigationParams = { + id: 1, + s: "Start", +}; +const routeConfigMap: NavigationRouteConfigMap = { + [ROUTE_NAME_START_SCREEN]: { + path: "start", + screen: StartScreen, + }, + [ROUTE_NAME_NEXT_SCREEN]: { + path: "next", + screen: NextScreen, + }, +}; +export const AppNavigator = StackNavigator( + routeConfigMap, + { + initialRouteName: ROUTE_NAME_START_SCREEN, + initialRouteParams, + }, ); -export const AppNavigator = StackNavigator({ - StartImage: { - path: 'startImage', - screen: Start, - }, -}, { - initialRouteName: 'StartImage', -}); - +/** + * Router. + */ const Router = (props: any) => ( - true, + state: {}, + }) + } /> ); -const tabNavigatorScreenOptions: TabNavigatorScreenOptions = { + +/** + * Tab navigator. + */ + +const tabNavigatorScreenOptions: NavigationTabScreenOptions = { title: 'title', tabBarVisible: true, tabBarIcon: , tabBarLabel: 'label', -} +}; const tabNavigatorConfig: TabNavigatorConfig = { lazy: true, tabBarComponent: TabBarTop, + tabBarOptions: tabNavigatorScreenOptions, +}; + +const BasicTabNavigator = TabNavigator( + routeConfigMap, + tabNavigatorConfig, +); + +function renderBasicTabNavigator(): JSX.Element { + return ( + { }} + style={viewStyle} + /> + ); } + +/** + * Stack navigator. + */ + +const stackNavigatorScreenOptions: NavigationStackScreenOptions = { + title: 'title', +}; + +const stackNavigatorConfig: StackNavigatorConfig = { + mode: "card", + headerMode: "screen", + navigationOptions: stackNavigatorScreenOptions, +}; + +const BasicStackNavigator = StackNavigator( + routeConfigMap, + stackNavigatorConfig, +); + +function renderBasicStackNavigator(): JSX.Element { + return ( + { }} + style={viewStyle} + /> + ); +} + + +/** + * @class CustomTransitioner @extends React.Component + * @desc Custom transitioner component. Follows react-navigation/src/views/CardStackTransitioner.js. + */ interface CustomTransitionerProps { - navigation: NavigationProp + navigation: NavigationScreenProp +} +class CustomTransitioner extends React.Component { + render() { + return ( + { }} + onTransitionEnd={() => { }} + /> + ); + } + _render = (props: NavigationTransitionProps, prevProps: NavigationTransitionProps): React.ReactElement => { + return ( + + ); + } + _configureTransition = ( + _transitionProps: NavigationTransitionProps, + _prevTransitionProps: NavigationTransitionProps + ) => { + return {} + } } -const configureTransition = ( - _transitionProps: NavigationTransitionProps, - _prevTransitionProps: NavigationTransitionProps - ) => { - return {} - } +const initAction: NavigationInitAction = NavigationActions.init({ + params: { + foo: "bar" + } +}) -const renderTransitioner = (props: NavigationTransitionProps, prevProps: NavigationTransitionProps) => { - return -} +const navigateAction: NavigationNavigateAction = NavigationActions.navigate({ + routeName: "FooScreen", + params: { + foo: "bar" + }, + action: NavigationActions.navigate({ routeName: "BarScreen" }) +}) -const CustomTransitioner = (props: CustomTransitionerProps) => { - { }} - onTransitionEnd={() => { }} - /> -} +const resetAction: NavigationResetAction = NavigationActions.reset({ + index: 0, + key: "foo", + actions: [ + NavigationActions.navigate({ routeName: "FooScreen" }) + ] +}) -const BasicStackNavigation = StackNavigator({ - StartScreen: { screen: Start } -}); +const backAction: NavigationBackAction = NavigationActions.back({ + key: "foo" +}) - +const setParamsAction: NavigationSetParamsAction = NavigationActions.setParams({ + key: "foo", + params: { + foo: "bar" + } +}) diff --git a/types/react-navigation/tsconfig.json b/types/react-navigation/tsconfig.json index e670f06667..ad15863a78 100644 --- a/types/react-navigation/tsconfig.json +++ b/types/react-navigation/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/react-router-native/index.d.ts b/types/react-router-native/index.d.ts index 214e81b0d3..f2ab1c72b1 100644 --- a/types/react-router-native/index.d.ts +++ b/types/react-router-native/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/ReactTraining/react-router-native // Definitions by: Eduard Zintz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 export { match, @@ -23,25 +23,25 @@ import * as React from 'react'; import * as H from 'history'; export interface AndroidBackButtonProps { - children: Array>; + children: React.Component[]; } -export class AndroidBackButton extends React.Component {} +export class AndroidBackButton extends React.Component {} -export class DeepLinking extends React.Component<{}, {}> {} +export class DeepLinking extends React.Component {} export interface LinkProps { - component?: React.Component; + component?: React.Component; replace?: boolean; style?: any; to: H.LocationDescriptor; } -export class Link extends React.Component {} +export class Link extends React.Component {} export interface NativeRouterProps { getUserConfirmation?: Function; keyLength?: number; } -export class NativeRouter extends React.Component {} +export class NativeRouter extends React.Component {} diff --git a/types/react-router/test/README.md b/types/react-router/test/README.md deleted file mode 100644 index 341bd29130..0000000000 --- a/types/react-router/test/README.md +++ /dev/null @@ -1 +0,0 @@ -Examples taken from https://github.com/ReactTraining/react-router/tree/22bd52c901ef0312348c2b02549c7102bd5653ae/packages/react-router-website/modules/examples diff --git a/types/react-router/test/Ambiguous.tsx b/types/react-router/test/examples-from-react-router-website/Ambiguous.tsx similarity index 100% rename from types/react-router/test/Ambiguous.tsx rename to types/react-router/test/examples-from-react-router-website/Ambiguous.tsx diff --git a/types/react-router/test/Animation.tsx b/types/react-router/test/examples-from-react-router-website/Animation.tsx similarity index 100% rename from types/react-router/test/Animation.tsx rename to types/react-router/test/examples-from-react-router-website/Animation.tsx diff --git a/types/react-router/test/Auth.tsx b/types/react-router/test/examples-from-react-router-website/Auth.tsx similarity index 100% rename from types/react-router/test/Auth.tsx rename to types/react-router/test/examples-from-react-router-website/Auth.tsx diff --git a/types/react-router/test/Basic.tsx b/types/react-router/test/examples-from-react-router-website/Basic.tsx similarity index 100% rename from types/react-router/test/Basic.tsx rename to types/react-router/test/examples-from-react-router-website/Basic.tsx diff --git a/types/react-router/test/CustomLink.tsx b/types/react-router/test/examples-from-react-router-website/CustomLink.tsx similarity index 100% rename from types/react-router/test/CustomLink.tsx rename to types/react-router/test/examples-from-react-router-website/CustomLink.tsx diff --git a/types/react-router/test/ModalGallery.tsx b/types/react-router/test/examples-from-react-router-website/ModalGallery.tsx similarity index 99% rename from types/react-router/test/ModalGallery.tsx rename to types/react-router/test/examples-from-react-router-website/ModalGallery.tsx index f4b55aca20..211e62aa49 100644 --- a/types/react-router/test/ModalGallery.tsx +++ b/types/react-router/test/examples-from-react-router-website/ModalGallery.tsx @@ -130,7 +130,7 @@ const ImageView: React.SFC> = ({ match }) => const Modal: React.SFC> = ({ match, history }) => { const image = IMAGES[parseInt(match.params.id, 10)]; if (!image) { - return null!; + return null; } const back = (e: React.MouseEvent) => { e.stopPropagation(); diff --git a/types/react-router/test/NoMatch.tsx b/types/react-router/test/examples-from-react-router-website/NoMatch.tsx similarity index 100% rename from types/react-router/test/NoMatch.tsx rename to types/react-router/test/examples-from-react-router-website/NoMatch.tsx diff --git a/types/react-router/test/Params.tsx b/types/react-router/test/examples-from-react-router-website/Params.tsx similarity index 100% rename from types/react-router/test/Params.tsx rename to types/react-router/test/examples-from-react-router-website/Params.tsx diff --git a/types/react-router/test/PreventingTransitions.tsx b/types/react-router/test/examples-from-react-router-website/PreventingTransitions.tsx similarity index 100% rename from types/react-router/test/PreventingTransitions.tsx rename to types/react-router/test/examples-from-react-router-website/PreventingTransitions.tsx diff --git a/types/react-router/test/examples-from-react-router-website/README.md b/types/react-router/test/examples-from-react-router-website/README.md new file mode 100644 index 0000000000..6648c853d0 --- /dev/null +++ b/types/react-router/test/examples-from-react-router-website/README.md @@ -0,0 +1,5 @@ +Examples taken from react-router website. + +Please keep them in sync and as close as possible to the original ones. + +See https://github.com/ReactTraining/react-router/tree/22bd52c901ef0312348c2b02549c7102bd5653ae/packages/react-router-website/modules/examples diff --git a/types/react-router/test/Recursive.tsx b/types/react-router/test/examples-from-react-router-website/Recursive.tsx similarity index 100% rename from types/react-router/test/Recursive.tsx rename to types/react-router/test/examples-from-react-router-website/Recursive.tsx diff --git a/types/react-router/test/RouteConfig.tsx b/types/react-router/test/examples-from-react-router-website/RouteConfig.tsx similarity index 100% rename from types/react-router/test/RouteConfig.tsx rename to types/react-router/test/examples-from-react-router-website/RouteConfig.tsx diff --git a/types/react-router/test/Sidebar.tsx b/types/react-router/test/examples-from-react-router-website/Sidebar.tsx similarity index 100% rename from types/react-router/test/Sidebar.tsx rename to types/react-router/test/examples-from-react-router-website/Sidebar.tsx diff --git a/types/react-router/test/StaticRouter.tsx b/types/react-router/test/examples-from-react-router-website/StaticRouter.tsx similarity index 100% rename from types/react-router/test/StaticRouter.tsx rename to types/react-router/test/examples-from-react-router-website/StaticRouter.tsx diff --git a/types/react-router/tsconfig.json b/types/react-router/tsconfig.json index 4790f0b53d..438e3c9647 100644 --- a/types/react-router/tsconfig.json +++ b/types/react-router/tsconfig.json @@ -14,22 +14,24 @@ }, "files": [ "index.d.ts", - "test/Ambiguous.tsx", - "test/Animation.tsx", - "test/Auth.tsx", - "test/Basic.tsx", + + "test/examples-from-react-router-website/Ambiguous.tsx", + "test/examples-from-react-router-website/Animation.tsx", + "test/examples-from-react-router-website/Auth.tsx", + "test/examples-from-react-router-website/Basic.tsx", + "test/examples-from-react-router-website/CustomLink.tsx", + "test/examples-from-react-router-website/ModalGallery.tsx", + "test/examples-from-react-router-website/NoMatch.tsx", + "test/examples-from-react-router-website/Params.tsx", + "test/examples-from-react-router-website/PreventingTransitions.tsx", + "test/examples-from-react-router-website/Recursive.tsx", + "test/examples-from-react-router-website/RouteConfig.tsx", + "test/examples-from-react-router-website/Sidebar.tsx", + "test/examples-from-react-router-website/StaticRouter.tsx", + "test/Children.tsx", - "test/CustomLink.tsx", - "test/ModalGallery.tsx", "test/NavigateWithContext.tsx", "test/MemoryRouter.tsx", - "test/NoMatch.tsx", - "test/Params.tsx", - "test/PreventingTransitions.tsx", - "test/Recursive.tsx", - "test/RouteConfig.tsx", - "test/Sidebar.tsx", - "test/StaticRouter.tsx", "test/Switch.tsx", "test/WithRouter.tsx" ] diff --git a/types/react-sortable-hoc/index.d.ts b/types/react-sortable-hoc/index.d.ts index f4886cd7d6..767cf1405c 100644 --- a/types/react-sortable-hoc/index.d.ts +++ b/types/react-sortable-hoc/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for nes 0.0.7 +// Type definitions for nes 0.6.3 // Project: https://github.com/clauderic/react-sortable-hoc // Definitions by: Ivo Stratev , Charles Rey // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -33,12 +33,20 @@ declare module 'react-sortable-hoc' { export type ContainerGetter = (element: React.ReactElement) => HTMLElement; + export interface Dimensions { + width: number; + height: number; + } + export interface SortableContainerProps { axis?: Axis; lockAxis?: Axis; helperClass?: string; transitionDuration?: number; pressDelay?: number; + pressThreshold?: number; + distance?: number; + shouldCancelStart?: (event: SortEvent) => boolean; onSortStart?: SortStartHandler; onSortMove?: SortMoveHandler; onSortEnd?: SortEndHandler; @@ -48,7 +56,7 @@ declare module 'react-sortable-hoc' { lockToContainerEdges?: boolean; lockOffset?: Offset | [Offset, Offset]; getContainer?: ContainerGetter; - shouldCancelStart?: (event: SortEvent) => boolean; + getHelperDimensions?: (sort: SortStart) => Dimensions; } export interface SortableElementProps { diff --git a/types/react-sortable-hoc/react-sortable-hoc-tests.tsx b/types/react-sortable-hoc/react-sortable-hoc-tests.tsx index 4700612d01..af742734bf 100644 --- a/types/react-sortable-hoc/react-sortable-hoc-tests.tsx +++ b/types/react-sortable-hoc/react-sortable-hoc-tests.tsx @@ -35,21 +35,38 @@ const SortableList = ReactSortableHOC.SortableContainer((props: SortableListProp class SortableComponent extends React.Component<{}, SortableComponentState> { private _onSortEnd: ReactSortableHOC.SortEndHandler; - private _handleSotEnd(sort: ReactSortableHOC.SortEnd, event: ReactSortableHOC.SortEvent): void { + private _handleSortEnd(sort: ReactSortableHOC.SortEnd, event: ReactSortableHOC.SortEvent): void { this.setState({items: ReactSortableHOC.arrayMove(this.state.items, sort.oldIndex, sort.newIndex)}); } + private _getHelperDimensions(sort: ReactSortableHOC.SortStart): ReactSortableHOC.Dimensions { + if (sort.node instanceof HTMLElement) { + return ({ + width: sort.node.offsetWidth, + height: sort.node.offsetHeight + }); + } + return {width: 0, height: 0}; + } + public constructor() { super(); this.state = { items: ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6'], axis: 'x' }; - this._onSortEnd = this._handleSotEnd.bind(this); + this._onSortEnd = this._handleSortEnd.bind(this); } public render(): JSX.Element { - return ; + return ; } } diff --git a/types/react-sortable-tree/index.d.ts b/types/react-sortable-tree/index.d.ts new file mode 100644 index 0000000000..a7805cd90e --- /dev/null +++ b/types/react-sortable-tree/index.d.ts @@ -0,0 +1,120 @@ +// Type definitions for react-sortable-tree 0.1 +// Project: https://fritz-c.github.io/react-sortable-tree +// Definitions by: Wouter Hardeman +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from 'react'; +import { ListProps, Index } from 'react-virtualized'; +import { ConnectDragSource, ConnectDragPreview, DragSourceMonitor } from 'react-dnd'; + +export * from './utils/tree-data-utils'; +export * from './utils/default-handlers'; + +export interface TreeItem { + title?: string; + subtitle?: string; + expanded?: boolean; + children: TreeItem[]; + [x: string]: any; +} + +export interface TreeNode { + node: TreeItem; +} + +export interface TreePath { + path: NumberArrayOrStringArray; +} + +export interface TreeIndex { + treeIndex: number; +} + +export interface FullTree { + treeData: TreeItem[]; +} + +export interface NodeData extends TreeNode, TreePath, TreeIndex {} + +export interface SearchData extends NodeData { + searchQuery: any; +} + +export interface ExtendedNodeData extends NodeData { + lowerSiblingsCounts: number[]; + isSearchMatch: boolean; + isSearchFocus: boolean; +} + +export interface OnVisibilityToggleData extends FullTree, TreeNode { + expanded: boolean; +} +export interface PreviousAnNextLocation { + prevPath: number[]; + prevParent: TreeItem; + prevTreeIndex: number; + nextPath: number[]; + nextParent: TreeItem; + nextTreeIndex: number; +} + +export type NodeRenderer = React.ComponentClass; + +export interface NodeRendererProps { + node: TreeItem; + path: NumberArrayOrStringArray; + treeIndex: number; + isSearchMatch: boolean; + isSearchFocus: boolean; + canDrag: boolean; + scaffoldBlockPxWidth: number; + toggleChildrenVisibility?(data: NodeData): void; + buttons?: any[]; + className?: string; + style?: {[index: string]: any}; + + connectDragPreview: ConnectDragPreview; + connectDragSource: ConnectDragSource; + parentNode?: {[index: string]: any}; + startDrag: any; + endDrag: any; + isDragging: boolean; + didDrop: boolean; + draggedNode?: {[index: string]: any}; + isOver: boolean; + canDrop?: boolean; +} + +type NumberArrayOrStringArray = string[] | number[]; + +export interface ReactSortableTreeProps { + treeData: TreeItem[]; + onChange(treeData: TreeItem[]): void; + style?: {[index: string]: any; }; + className?: string; + innerStyle?: {[index: string]: any; }; + maxDepth?: number; + searchMethod?(data: SearchData): boolean; + searchQuery?: string | any; + searchFocusOffset?: number; + searchFinishCallback?(matches: NodeData[]): void; + generateNodeProps?(data: ExtendedNodeData): {[index: string]: any}; + getNodeKey?(data: TreeNode & TreeIndex): string | number; + onMoveNode?(data: NodeData & FullTree): void; + onVisibilityToggle?(data: OnVisibilityToggleData): void; + canDrag?: ((data: ExtendedNodeData) => boolean) | boolean; + canDrop?(data: PreviousAnNextLocation & NodeData): boolean; + reactVirtualizedListProps?: ListProps; + rowHeight?: ((info: Index) => number) | number; + slideRegionSize?: number; + scaffoldBlockPxWidth?: number; + isVirtualized?: boolean; + nodeContentRenderer?: NodeRenderer; +} + +declare const SortableTree: React.ComponentClass; + +export const SortableTreeWithoutDndContext: React.ComponentClass; + +export default SortableTree; diff --git a/types/react-sortable-tree/react-sortable-tree-tests.tsx b/types/react-sortable-tree/react-sortable-tree-tests.tsx new file mode 100644 index 0000000000..8b89db5196 --- /dev/null +++ b/types/react-sortable-tree/react-sortable-tree-tests.tsx @@ -0,0 +1,66 @@ +import * as React from "react"; +import SortableTree, + { + SortableTreeWithoutDndContext, + defaultGetNodeKey, + NodeRenderer, + TreeItem, + defaultSearchMethod, + SearchData, + NodeData, + ExtendedNodeData, + FullTree, + OnVisibilityToggleData, + PreviousAnNextLocation + } from "react-sortable-tree"; +import { ListProps, ListRowRenderer } from "react-virtualized"; + +class Test extends React.Component { + render() { + const treeData = [ + { + title: "Title", subtitle: "Subtitle", children: [ + {title: "Child 1", subtitle: "Subtitle", children: []}, + {title: "Child 2", subtitle: "Subtitle", children: []} + ] + } + ]; + const reactVirtualizedListProps: ListProps = { + width: 100, height: 44, rowCount: 3, rowHeight: 44, rowRenderer: "test" as any as ListRowRenderer + }; + const nodeRenderer: NodeRenderer = "test" as any as NodeRenderer; + return ( +

+ {}} + style={{width: "100%"}} + className="test-class" + innerStyle={{backgroundColor: "#3A3A3A"}} + maxDepth={3} + searchMethod={defaultSearchMethod} + searchQuery={"Child 1"} + searchFocusOffset={1} + searchFinishCallback={(matches: NodeData[]) => { const firstTitle = matches[0].node.title; }} + generateNodeProps={(data: ExtendedNodeData) => ({buttons: [data.node.title]}) } + getNodeKey={defaultGetNodeKey} + onMoveNode={(data: NodeData & FullTree) => {}} + onVisibilityToggle={(data: OnVisibilityToggleData) => {}} + canDrag={true} + canDrop={(data: PreviousAnNextLocation & NodeData) => true} + reactVirtualizedListProps={reactVirtualizedListProps} + rowHeight={62} + slideRegionSize={100} + scaffoldBlockPxWidth={44} + isVirtualized={true} + nodeContentRenderer={nodeRenderer} + /> + {}} + style={{width: "100px"}} + /> +
+ ); + } +} diff --git a/types/react-sortable-tree/tsconfig.json b/types/react-sortable-tree/tsconfig.json new file mode 100644 index 0000000000..f82f976d38 --- /dev/null +++ b/types/react-sortable-tree/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "jsx": "react", + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-sortable-tree-tests.tsx" + ] +} diff --git a/types/react-sortable-tree/tslint.json b/types/react-sortable-tree/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-sortable-tree/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-sortable-tree/utils/default-handlers.d.ts b/types/react-sortable-tree/utils/default-handlers.d.ts new file mode 100644 index 0000000000..5b00de104d --- /dev/null +++ b/types/react-sortable-tree/utils/default-handlers.d.ts @@ -0,0 +1,4 @@ +import { TreeIndex, SearchData } from 'react-sortable-tree'; + +export function defaultGetNodeKey(data: TreeIndex): number; +export function defaultSearchMethod(data: SearchData): boolean; \ No newline at end of file diff --git a/types/react-sortable-tree/utils/tree-data-utils.d.ts b/types/react-sortable-tree/utils/tree-data-utils.d.ts new file mode 100644 index 0000000000..84f68840c7 --- /dev/null +++ b/types/react-sortable-tree/utils/tree-data-utils.d.ts @@ -0,0 +1,21 @@ +import { FullTree, TreePath, TreeItem, TreeIndex, SearchData, NodeData, TreeNode } from 'react-sortable-tree'; + +type GetNodeKeyFunction = (data: TreeIndex & TreeNode) => string | number; +type WalkAndMapFunctionParameters = FullTree & {getNodeKey: GetNodeKeyFunction, callback: Function, ignoreCollapsed?: boolean} +type FlattenedData = (TreeNode & TreePath & {lowerSiblingsCounts: number[]})[]; + +export function getDescendantCount(data: TreeNode & {ignoreCollapsed?: boolean}): number; +export function getVisibleNodeCount(data: FullTree): number; +export function getVisibleNodeInfoAtIndex(data: FullTree & {targetIndex: number, getNodeKey: GetNodeKeyFunction}): TreeNode & TreePath & {lowerSiblingsCounts: number[]}; +export function walk(data: WalkAndMapFunctionParameters): void; +export function map(data: WalkAndMapFunctionParameters): TreeItem[]; +export function changeNodeAtPath(data: FullTree & TreePath & {newNode: Function | any, getNodeKey: GetNodeKeyFunction, ignoreCollapsed?: boolean}): TreeItem[]; +export function removeNodeAtPath(data: FullTree & TreePath & {getNodeKey: GetNodeKeyFunction, ignoreCollapsed?: boolean}): TreeItem[]; +export function getNodeAtPath(data: FullTree & TreePath & {getNodeKey: GetNodeKeyFunction, ignoreCollapsed?: boolean}): TreeItem | null; +export function addNodeUnderParent(data: FullTree & {newNode: TreeItem, parentKey?: number | string, getNodeKey: GetNodeKeyFunction, ignoreCollapsed?: boolean, expandParent?: boolean}): FullTree & TreeIndex; +export function insertNode(data: FullTree & {depth: number, newNode: TreeItem, minimumTreeIndex: number, ignoreCollapsed?: boolean, expandParent?: boolean, getNodeKey: GetNodeKeyFunction}): FullTree & TreeIndex & TreePath & {parentNode: TreeItem}; +export function getFlatDataFromTree(data: FullTree & {getNodeKey: GetNodeKeyFunction, ignoreCollapsed?: boolean}): (TreeNode & TreePath & {lowerSiblingsCounts: number[], parentNode: TreeItem})[]; +export function getTreeFromFlatData(data: {flatData: FlattenedData, getKey?: GetNodeKeyFunction, getParentKey?: GetNodeKeyFunction, rootKey?: string | number}): TreeItem[] +export function isDescendant(older: TreeItem, younger: TreeItem): boolean; +export function getDepth(node: TreeItem, depth?: number): number; +export function find(data: FullTree & {getNodeKey: GetNodeKeyFunction, searchQuery?: string | number, searchMethod: (data: SearchData) => boolean, searchFocusOffset?: number, expandAllMatchPaths?: boolean, expandFocusMatchPaths?: boolean}): {matches: NodeData[]} & FullTree; diff --git a/types/react/README.md b/types/react/README.md index e38ba90175..594b16d48f 100644 --- a/types/react/README.md +++ b/types/react/README.md @@ -1,7 +1,7 @@ ## Known Problems & Workarounds ### **The type of `cloneElement` is incorrect.** -This is similar to the `setState` problem, in that `cloneElement(element, props)` should should accept a `props` object with a subset of the properties on `element.props`. There is an additional complication, however—React attributes, such as `key` and `ref`, should also be accepted in `props`, but should not exist on `element.props`. The "correct" way to model this, then, is with +`cloneElement(element, props)` should should accept a `props` object with a subset of the properties on `element.props`. React attributes such as `key` and `ref` should also be accepted in `props`, but should not exist on `element.props`. The "correct" way to model this, then, is with ```ts declare function cloneElement

( element: ReactElement

, diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 283fb57ba7..577959ae7b 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -136,10 +136,14 @@ declare namespace React { type: ClassType): CFactory; function createFactory

(type: ComponentClass

): Factory

; - function createElement

, T extends Element>( - type: string, + function createElement

, T extends HTMLElement>( + type: keyof ReactHTML, props?: ClassAttributes & P, - ...children: ReactNode[]): DOMElement; + ...children: ReactNode[]): ReactHTMLElement; + function createElement

, T extends SVGElement>( + type: keyof ReactSVG, + props?: ClassAttributes & P, + ...children: ReactNode[]): ReactSVGElement; function createElement

( type: SFC

, props?: Attributes & P, @@ -227,7 +231,7 @@ declare namespace React { type SFC

= StatelessComponent

; interface StatelessComponent

{ - (props: P & { children?: ReactNode }, context?: any): ReactElement; + (props: P & { children?: ReactNode }, context?: any): ReactElement | null; propTypes?: ValidationMap

; contextTypes?: ValidationMap; defaultProps?: Partial

; @@ -2526,8 +2530,7 @@ declare namespace React { // React.DOM // ---------------------------------------------------------------------- - interface ReactDOM { - // HTML + interface ReactHTML { a: HTMLFactory; abbr: HTMLFactory; address: HTMLFactory; @@ -2641,8 +2644,9 @@ declare namespace React { "var": HTMLFactory; video: HTMLFactory; wbr: HTMLFactory; + } - // SVG + interface ReactSVG { svg: SVGFactory; animate: SVGFactory; circle: SVGFactory; @@ -2666,6 +2670,8 @@ declare namespace React { use: SVGFactory; } + interface ReactDOM extends ReactHTML, ReactSVG { } + // // React.PropTypes // ---------------------------------------------------------------------- diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 80d4d574df..27acc07d34 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -138,7 +138,7 @@ interface SCProps { } function StatelessComponent(props: SCProps) { - return React.DOM.div(null, props.foo); + return props.foo ? React.DOM.div(null, props.foo) : null; }; namespace StatelessComponent { export var displayName = "StatelessComponent"; @@ -155,7 +155,8 @@ StatelessComponent2.defaultProps = { var StatelessComponent3: React.SFC = // allows usage of props.children - props => React.DOM.div(null, props.foo, props.children); + // allows null return + props => props.foo ? React.DOM.div(null, props.foo, props.children) : null; // React.createFactory var factory: React.CFactory = @@ -189,6 +190,8 @@ var classicElement: React.ClassicElement = React.createElement(ClassicComponent, props); var domElement: React.ReactHTMLElement = React.createElement("div"); +var htmlElement = React.createElement("input", { type: "text" }); +var svgElement = React.createElement("svg", { accentHeight: 12 }); // React.cloneElement var clonedElement: React.CElement = diff --git a/types/recompose/recompose-tests.tsx b/types/recompose/recompose-tests.tsx index a698de6ffa..a8bf57ee74 100644 --- a/types/recompose/recompose-tests.tsx +++ b/types/recompose/recompose-tests.tsx @@ -69,13 +69,13 @@ function testWithHandlers() { const innerComponent = ({onChange, onSubmit}: InnerProps) =>

; - const enhancer = withHandlers({ + const enhancer = withHandlers({ onChange: (props: OutterProps) => (e: any) => {}, onSubmit: (props: OutterProps) => (e: any) => {}, }); const enhanced: React.ComponentClass = enhancer(innerComponent); - const enhancer2 = withHandlers((props: OutterProps) => ({ + const enhancer2 = withHandlers((props: OutterProps) => ({ onChange: (props: OutterProps) => (e: any) => {}, onSubmit: (props: OutterProps) => (e: any) => {}, })); diff --git a/types/request/index.d.ts b/types/request/index.d.ts index fae6a2f65c..2cf7b08cf9 100644 --- a/types/request/index.d.ts +++ b/types/request/index.d.ts @@ -143,6 +143,7 @@ declare namespace request { gzip?: boolean; preambleCRLF?: boolean; postambleCRLF?: boolean; + withCredentials?: boolean; key?: Buffer; cert?: Buffer; passphrase?: string; diff --git a/types/route-parser/index.d.ts b/types/route-parser/index.d.ts index 2f5dd84e8d..f7b013447c 100644 --- a/types/route-parser/index.d.ts +++ b/types/route-parser/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for route-parser 0.0 +// Type definitions for route-parser 0.1 // Project: https://github.com/rcs/route-parser -// Definitions by: Ian Ker-Seymer +// Definitions by: Ian Ker-Seymer , Bob Buehler // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Route { @@ -23,7 +23,7 @@ declare class Route { * var route = new Route('/:one/:two') * route.match('/foo/bar/') // -> {one: 'foo', two: 'bar'} */ - match(pathname: string): { [i: string]: string } | boolean; + match(pathname: string): { [i: string]: string } | false; /** * Reverse a route specification to a path, returning false if it can't be @@ -32,7 +32,7 @@ declare class Route { * var route = new Route('/:one/:two') * route.reverse({one: 'foo', two: 'bar'}) -> '/foo/bar' */ - reverse(params: { [i: string]: any } ): string | boolean; + reverse(params: { [i: string]: any } ): string | false; } declare namespace Route {} diff --git a/types/semver/index.d.ts b/types/semver/index.d.ts index 60e7275f7a..336fa85574 100644 --- a/types/semver/index.d.ts +++ b/types/semver/index.d.ts @@ -5,6 +5,8 @@ export const SEMVER_SPEC_VERSION: "2.0.0"; +export type ReleaseType = "major" | "premajor" | "minor" | "preminor" | "patch" | "prepatch" | "prerelease"; + /** * Return the parsed version, or null if it's not valid. */ @@ -16,7 +18,7 @@ export function clean(version: string, loose?: boolean): string; /** * Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid. */ -export function inc(v: string, release: string, loose?: boolean): string; +export function inc(v: string, release: ReleaseType, loose?: boolean): string; /** * Return the major version number. */ @@ -76,7 +78,7 @@ export function rcompare(v1: string, v2: string, loose?: boolean): number; /** * Returns difference between two versions by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease), or null if the versions are the same. */ -export function diff(v1: string, v2: string, loose?: boolean): string; +export function diff(v1: string, v2: string, loose?: boolean): ReleaseType; // Ranges /** @@ -127,7 +129,7 @@ export class SemVer { compare(other: SemVer): number; compareMain(other: SemVer): number; comparePre(other: SemVer): number; - inc(release: string): SemVer; + inc(release: ReleaseType): SemVer; } export class Comparator { diff --git a/types/semver/semver-tests.ts b/types/semver/semver-tests.ts index b7a1299ad3..42088eef4d 100644 --- a/types/semver/semver-tests.ts +++ b/types/semver/semver-tests.ts @@ -4,7 +4,7 @@ let obj: {}; let bool: boolean; let num: number; let str: string; -let diff: string; +let diff: semver.ReleaseType; let x: any = null; let arr: any[]; let exp: RegExp; @@ -22,7 +22,13 @@ str = semver.clean(str); str = semver.valid(str, loose); str = semver.clean(str, loose); -str = semver.inc(str, str, loose); +str = semver.inc(str, "major", loose); +str = semver.inc(str, "premajor", loose); +str = semver.inc(str, "minor", loose); +str = semver.inc(str, "preminor", loose); +str = semver.inc(str, "patch", loose); +str = semver.inc(str, "prepatch", loose); +str = semver.inc(str, "prerelease", loose); num = semver.major(str, loose); num = semver.minor(str, loose); num = semver.patch(str, loose); @@ -66,7 +72,13 @@ strArr = ver.prerelease; num = ver.compare(ver); num = ver.compareMain(ver); num = ver.comparePre(ver); -ver = ver.inc(str); +ver = ver.inc("major"); +ver = ver.inc("premajor"); +ver = ver.inc("minor"); +ver = ver.inc("preminor"); +ver = ver.inc("patch"); +ver = ver.inc("prepatch"); +ver = ver.inc("prerelease"); const comp = new semver.Comparator(str, bool); str = comp.toString(); diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index a48df85258..75e87baae1 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -421,7 +421,7 @@ declare namespace Sinon { (value: string): SinonMatcher; (expr: RegExp): SinonMatcher; (obj: any): SinonMatcher; - (callback: (value: any) => boolean): SinonMatcher; + (callback: (value: any) => boolean, message?: string): SinonMatcher; any: SinonMatcher; defined: SinonMatcher; truthy: SinonMatcher; diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 9184ec6808..406c790a2b 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -119,6 +119,14 @@ function testPromises() { rejectsStub2 = sinon.stub().rejects("TypeError"); } +function testMatchInvoke() { + let stub = sinon.stub(); + stub(123); + stub.calledWithMatch(sinon.match(123)); + stub.calledWithMatch(sinon.match((value: any) => value === 123)); + stub.calledWithMatch(sinon.match((value: any) => value === 123, "Must be 123")); +} + function testSymbolMatch() { let stub = sinon.stub(); stub(Symbol('TestSymbol')); diff --git a/types/sizzle/index.d.ts b/types/sizzle/index.d.ts new file mode 100644 index 0000000000..bfe24791bf --- /dev/null +++ b/types/sizzle/index.d.ts @@ -0,0 +1,63 @@ +// Type definitions for sizzle 2.3 +// Project: https://sizzlejs.com +// Definitions by: Leonard Thieu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace Sizzle; + +declare const Sizzle: SizzleStatic; +export = Sizzle; + +interface SizzleStatic { + selectors: Sizzle.Selectors; + >(selector: string, context: Element | Document | DocumentFragment, results: TArrayLike): TArrayLike; + (selector: string, context?: Element | Document | DocumentFragment): Element[]; + // tslint:disable-next-line:ban-types + compile(selector: string): Function; + matchSelector(element: Element, selector: string): boolean; + matches(selector: string, elements: Element[]): Element[]; +} + +declare namespace Sizzle { + interface Selectors { + cacheLength: number; + match: { [name: string]: RegExp; }; + find: { [name: string]: Selectors.FindFunction; }; + preFilter: { [name: string]: Selectors.PreFilterFunction; }; + filter: { [name: string]: Selectors.FilterFunction; }; + attrHandle: { [name: string]: Selectors.AttrHandleFunction; }; + pseudos: { [name: string]: Selectors.PseudoFunction; }; + setFilters: { [name: string]: Selectors.SetFilterFunction; }; + createPseudo(fn: Selectors.CreatePseudoFunction): Selectors.PseudoFunction; + } + + namespace Selectors { + interface FindFunction { + (match: RegExpMatchArray, context: Element | Document, isXML: boolean): Element[] | void; + } + + interface PreFilterFunction { + (match: RegExpMatchArray): string[]; + } + + interface FilterFunction { + (element: string, ...matches: string[]): boolean; + } + + interface AttrHandleFunction { + (elem: any, casePreservedName: string, isXML: boolean): string; + } + + interface PseudoFunction { + (elem: Element): boolean; + } + + interface CreatePseudoFunction { + (...args: any[]): PseudoFunction; + } + + interface SetFilterFunction { + (elements: Element[], argument: number, not: boolean): Element[]; + } + } +} diff --git a/types/sizzle/sizzle-tests.ts b/types/sizzle/sizzle-tests.ts new file mode 100644 index 0000000000..3c6d17dc64 --- /dev/null +++ b/types/sizzle/sizzle-tests.ts @@ -0,0 +1,54 @@ +/// + +function pseudos() { + const $test = jQuery(document); + Sizzle.selectors.pseudos['fixed'] = (elem) => { + // $test[0] = elem as HTMLElement; + return $test.css('position') === 'fixed'; + }; +} + +function createPseudos_0() { + Sizzle.selectors.pseudos['not'] = + Sizzle.selectors.createPseudo((subSelector) => { + const matcher = Sizzle.compile(subSelector); + return (elem) => { + return !matcher(elem); + }; + }); +} + +function createPseudos_1() { + // An implementation of a case-insensitive contains pseudo + // made for all versions of jQuery + (($) => { + function icontains(elem: HTMLElement, text: string) { + return ( + elem.textContent || + elem.innerText || + $(elem).text() || + '' + ).toLowerCase().indexOf((text || '').toLowerCase()) > -1; + } + + // $.expr.pseudos.icontains = $.expr.createPseudo(function(text) { + // return function(elem) { + // return icontains(elem as HTMLElement, text); + // }; + // }); + })(jQuery); +} + +function setFilters_0() { + Sizzle.selectors.setFilters['first'] = (elements, argument, not) => { + // No argument for first + return not ? elements.slice(1) : [elements[0]]; + }; +} + +function setFilters_1(oldPOS: RegExp) { + Sizzle.selectors.match['POS'] = new RegExp(oldPOS.source.replace('first', 'uno'), 'gi'); + Sizzle.selectors.setFilters['uno'] = Sizzle.selectors.setFilters['first']; + delete Sizzle.selectors.setFilters['first']; + Sizzle('div:uno'); // ==> [
] +} diff --git a/types/sizzle/tsconfig.json b/types/sizzle/tsconfig.json new file mode 100644 index 0000000000..aa10d374d5 --- /dev/null +++ b/types/sizzle/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sizzle-tests.ts" + ] +} diff --git a/types/sizzle/tslint.json b/types/sizzle/tslint.json new file mode 100644 index 0000000000..a4bcc87748 --- /dev/null +++ b/types/sizzle/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "callable-types": false + } +} diff --git a/types/storybook__addon-actions/index.d.ts b/types/storybook__addon-actions/index.d.ts new file mode 100644 index 0000000000..b650cd2d55 --- /dev/null +++ b/types/storybook__addon-actions/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for @storybook/addon-actions 3.0 +// Project: https://github.com/storybooks/storybook +// Definitions by: Joscha Feth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +// TODO: Once https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17434 is merged +// Remove the `declare module` wrapper. +// tslint:disable-next-line no-single-declare-module +declare module '@storybook/addon-actions' { + type HandlerFunction = (...args: any[]) => undefined; + type DecoratorFunction = (args: any[]) => any[]; + + function decorateAction(decorators: DecoratorFunction[]): HandlerFunction; + function action(name: string): HandlerFunction; +} diff --git a/types/storybook__addon-actions/storybook__addon-actions-tests.tsx b/types/storybook__addon-actions/storybook__addon-actions-tests.tsx new file mode 100644 index 0000000000..77ba80985b --- /dev/null +++ b/types/storybook__addon-actions/storybook__addon-actions-tests.tsx @@ -0,0 +1,21 @@ +/// + +import * as React from 'react'; +import { storiesOf } from '@storybook/react'; +import { action, decorateAction } from '@storybook/addon-actions'; + +const firstArgAction = decorateAction([ + args => args.slice(0, 1) +]); + +storiesOf('Button', module) + .add('action', () => ( + + )) + .add('decorated action', () => ( + + )); diff --git a/types/storybook__addon-actions/tsconfig.json b/types/storybook__addon-actions/tsconfig.json new file mode 100644 index 0000000000..e22f8849a3 --- /dev/null +++ b/types/storybook__addon-actions/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "storybook__addon-actions-tests.tsx" + ] +} diff --git a/types/storybook__addon-actions/tslint.json b/types/storybook__addon-actions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/storybook__addon-actions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/stylus/index.d.ts b/types/stylus/index.d.ts index a2a75b2ebc..47854aaf60 100644 --- a/types/stylus/index.d.ts +++ b/types/stylus/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/LearnBoost/stylus // Definitions by: Maxime LUCE // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// diff --git a/types/superagent/index.d.ts b/types/superagent/index.d.ts index 4032a9d543..e9b0018ed7 100644 --- a/types/superagent/index.d.ts +++ b/types/superagent/index.d.ts @@ -12,6 +12,8 @@ import * as https from 'https'; type CallbackHandler = (err: any, res: request.Response) => void; +type Serializer = (obj: any) => string; + declare const request: request.SuperAgentStatic; declare namespace request { @@ -28,6 +30,7 @@ declare namespace request { (method: string, url: string): SuperAgentRequest; agent(): SuperAgent; + serialize: { [type: string]: Serializer }; } interface SuperAgent extends stream.Stream { @@ -109,6 +112,7 @@ declare namespace request { redirects(n: number): this; responseType(type: string): this; send(data?: string | object): this; + serialize(serializer: Serializer): this; set(field: string, val: string): this; set(field: object): this; timeout(ms: number | { deadline?: number, response?: number }): this; diff --git a/types/superagent/superagent-tests.ts b/types/superagent/superagent-tests.ts index a6d07c3eaa..f38dcb31ea 100644 --- a/types/superagent/superagent-tests.ts +++ b/types/superagent/superagent-tests.ts @@ -171,6 +171,22 @@ request .send({post: 'data', here: 'wahoo'}) .end(callback); +// Custom request serializer +function testParser(data: any) { + return JSON.stringify(data); +} + +request + .post('/user') + .serialize(testParser) + .type('json') + .send({ foo: 123 }) + .end(callback); + +// Default serialization map + +request.serialize['application/xml'] = (obj: any) => 'generated xml here'; + // Parsing response bodies request('/search') .end((res: request.Response) => { diff --git a/types/swagger-express-mw/index.d.ts b/types/swagger-express-mw/index.d.ts index 04c09866d6..104bd0fc39 100644 --- a/types/swagger-express-mw/index.d.ts +++ b/types/swagger-express-mw/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/apigee-127/swagger-express#readme // Definitions by: Michael Mrowetz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /* =================== USAGE =================== diff --git a/types/swagger-hapi/index.d.ts b/types/swagger-hapi/index.d.ts index 2c723cbf61..7e62dbbdbb 100644 --- a/types/swagger-hapi/index.d.ts +++ b/types/swagger-hapi/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/apigee-127/swagger-hapi#readme // Definitions by: Michael Mrowetz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /* =================== USAGE =================== diff --git a/types/swagger-node-runner/index.d.ts b/types/swagger-node-runner/index.d.ts index 033abb434b..79118bb2e5 100644 --- a/types/swagger-node-runner/index.d.ts +++ b/types/swagger-node-runner/index.d.ts @@ -2,6 +2,7 @@ // Project: https://www.npmjs.com/package/swagger-node-runner // Definitions by: Michael Mrowetz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /* =================== USAGE =================== diff --git a/types/swagger-restify-mw/index.d.ts b/types/swagger-restify-mw/index.d.ts index c9518b2ecb..efc63693f3 100644 --- a/types/swagger-restify-mw/index.d.ts +++ b/types/swagger-restify-mw/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/apigee-127/swagger-restify#readme // Definitions by: Michael Mrowetz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /* =================== USAGE =================== import * as SwaggerRestify from "swagger-restify-mw"; diff --git a/types/swagger-tools/index.d.ts b/types/swagger-tools/index.d.ts index 09d42138b6..a697e9d7e8 100644 --- a/types/swagger-tools/index.d.ts +++ b/types/swagger-tools/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/apigee-127/swagger-tools // Definitions by: Alex Brick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 import { NextHandleFunction } from 'connect'; import { IncomingMessage } from 'http'; diff --git a/types/three/three-core.d.ts b/types/three/three-core.d.ts index 02cbe672e8..7a6a6ec9ac 100644 --- a/types/three/three-core.d.ts +++ b/types/three/three-core.d.ts @@ -2318,6 +2318,9 @@ export interface MaterialParameters { lights?: boolean; shading?: Shading; vertexColors?: Colors; + clippingPlanes?: Plane[]; + clipIntersection?: boolean; + clipShadows?: boolean; } /** diff --git a/types/tinycolor2/index.d.ts b/types/tinycolor2/index.d.ts index 7ad9d849a2..921d8a4f08 100644 --- a/types/tinycolor2/index.d.ts +++ b/types/tinycolor2/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for tinycolor v1.1.1 +// Type definitions for tinycolor v1.4.1 // Project: https://github.com/bgrins/TinyColor -// Definitions by: Mordechai Zuber , Geert Jansen +// Definitions by: Mordechai Zuber , Geert Jansen , Niels van Hoorn // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var tinycolor: tinycolor; @@ -70,27 +70,34 @@ interface tinycolor { * @param firstColor - the first color to be used in the comparison. * @param secondColor - the second color to be used in the comparison. */ - readability(firstColor: tinycolorInstance, secondColor: tinycolorInstance): Readable.Readable; + readability(firstColor: ColorInput, secondColor: ColorInput): Readable.Readable; /** - * Ensure that foreground and background color combinations provide sufficient contrast. + * Ensure that foreground and background color combinations meet WCAG2 guidelines. * * @param foreColor - the fore color wanted. - * @param backCOlor - the back color wanted. + * @param backColor - the back color wanted. + * @param wcag2 - The 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA'; the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'. If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}. */ - isReadable(foreColor: tinycolorInstance, backColor: tinycolorInstance): boolean; + isReadable(foreColor: ColorInput, backColor: ColorInput, wcag2?: {level?: string, size?: string}): boolean; /** * Given a base color and a list of possible foreground or background colors for that base, - * returns the most readable color. + * returns the most readable color. Optionally returns Black or White if the most readable color is unreadable. * * @param color - the base color. * @param colorsToCompare - array of colors to pick the most readable one from. + * @param args - and object with extra arguments */ - mostReadable(color: tinycolorInstance, colorsToCompare: tinycolorInstance[]): tinycolorInstance; + mostReadable(color: ColorInput, colorsToCompare: ColorInput[], args?: {includeFallbackColors?: boolean, level?: string, size?: string}): tinycolorInstance; /**/ - mix(color1: tinycolorInstance, color2: tinycolorInstance, amount?: number): tinycolorInstance; + mix(color1: ColorInput, color2: ColorInput, amount?: number): tinycolorInstance; + + /** + * Can be called with any tinycolor input + */ + equals(color1: ColorInput, color2: ColorInput): boolean; /** * Returns a random color @@ -265,7 +272,6 @@ interface tinycolorInstance { * Default value: 10. */ darken(amount?: number): tinycolorInstance; - /** * Desaturate the color a given amount. * Providing 100 will is the same as calling greyscale. @@ -380,6 +386,8 @@ declare namespace ColorFormats { } } +type ColorInput = string | ColorFormats.RGB | ColorFormats.RGBA | ColorFormats.HSL | ColorFormats.HSLA | ColorFormats.HSV | ColorFormats.HSVA | tinycolorInstance + declare module 'tinycolor2' { export = tinycolor; -} +} \ No newline at end of file diff --git a/types/tinycolor2/tinycolor2-tests.ts b/types/tinycolor2/tinycolor2-tests.ts index b3e0d0769a..f6a6634f5f 100644 --- a/types/tinycolor2/tinycolor2-tests.ts +++ b/types/tinycolor2/tinycolor2-tests.ts @@ -28,14 +28,18 @@ tester = tinycolor({ h: 0, s: 0, v: 0, a: 0 }); //tinycolor static methods tester = tinycolor.mix(tester, tester); +tester = tinycolor.mix("#ff0000", "#00ff00"); tester = tinycolor.mix(tester, tester, 50); tester = tinycolor.random(); +var isEqual = tinycolor.equals(tester, tester); /*Tinycolor object properties*/ var readable: Readable.Readable = tinycolor.readability(tester, tester); var isReadable: boolean = tinycolor.isReadable(tester, tester); +var isReadable: boolean = tinycolor.isReadable(tester, tester, {size: "small"}); tester = tinycolor.mostReadable(tester, [tester, tester, tester]); +tester = tinycolor.mostReadable(tester, [tester, tester, tester], {size: "large", level:"AA"}); var hexNames: { [key: string]: string } = tinycolor.hexNames; var names: { [key: string]: string } = tinycolor.names; diff --git a/types/transducers-js/index.d.ts b/types/transducers-js/index.d.ts index cfed8fbbbe..96fce6f671 100644 --- a/types/transducers-js/index.d.ts +++ b/types/transducers-js/index.d.ts @@ -1,19 +1,9 @@ // Type definitions for transducers-js 0.4 // Project: https://github.com/cognitect-labs/transducers-js // Definitions by: Colin Kahn +// David Philipson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export interface IteratorResult { - done: boolean; - value?: T; -} - -export interface Iterator { - next(value?: any): IteratorResult; - return?(value?: any): IteratorResult; - throw?(e?: any): IteratorResult; -} - export interface Reduced { ['@@transducer/reduced']: boolean; ['@@transducer/value']: TResult; @@ -21,7 +11,12 @@ export interface Reduced { export type Reducer = (result: TResult, input: TInput) => TResult; -export type Transducer = (xf: Transformer) => Transformer; +// Common case: Transducer = +// Transformer => Transformer. +export type Transducer = + ( + xf: CompletingTransformer + ) => CompletingTransformer; export interface CompletingTransformer { ['@@transducer/init'](): TResult | void; @@ -44,12 +39,15 @@ export function isReduced(x: any): boolean; /** * Function composition. Take N function and return their composition. */ -export function comp(...args: T[]): T; +// Infers correct return type when all arguments have same type. +export function comp any>(...args: T[]): T; +// Falls back to (any => any) when argument types differ. +export function comp(...args: Array<(x: any) => any>): (x: any) => any; /** * Take a predicate function and return its complement. */ -export function complement(f: Function): Function; +export function complement(f: (x: T) => boolean): (x: T) => boolean; /** * Identity function. @@ -66,7 +64,7 @@ export class Map implements Transformer(f: (x: TInput) => TOutput): Transducer; +export function map(f: (x: TInput) => TOutput): Transducer; export class Filter implements Transformer { constructor(pred: (x: TInput) => boolean, xf: Transformer); @@ -78,13 +76,13 @@ export class Filter implements Transformer { /** * Filtering transducer constructor */ -export function filter(pred: (x: TInput) => boolean): Transducer; +export function filter(pred: (x: TInput) => boolean): Transducer; /** * Similar to filter except the predicate is used to * eliminate values. */ -export function remove(pred: (x: TInput) => boolean): Transducer; +export function remove(pred: (x: TInput) => boolean): Transducer; export class Keep implements Transformer { constructor(f: (x: TInput) => any, xf: Transformer); @@ -97,7 +95,7 @@ export class Keep implements Transformer { * A keeping transducer. Keep inputs as long as the provided * function does not return null or undefined. */ -export function keep(f: (x: TInput) => any): Transducer; +export function keep(f: (x: TInput) => any): Transducer; export class KeepIndexed implements Transformer { constructor(f: (i: number, x: TInput) => any, xf: Transformer); @@ -110,7 +108,7 @@ export class KeepIndexed implements Transformer(f: (i: number, x: TInput) => any): Transducer; +export function keepIndexed(f: (i: number, x: TInput) => any): Transducer; export class Take implements Transformer { constructor(n: number, xf: Transformer); @@ -123,7 +121,7 @@ export class Take implements Transformer { * A take transducer constructor. Will take n values before * returning a reduced result. */ -export function take(n: number): Transducer; +export function take(n: number): Transducer; export class TakeWhile implements Transformer { constructor(pred: (n: TInput) => boolean, xf: Transformer); @@ -136,7 +134,7 @@ export class TakeWhile implements Transformer * Like the take transducer except takes as long as the pred * return true for inputs. */ -export function takeWhile(pred: (n: TInput) => boolean): Transducer; +export function takeWhile(pred: (n: TInput) => boolean): Transducer; export class TakeNth implements Transformer { constructor(n: number, xf: Transformer); @@ -148,7 +146,7 @@ export class TakeNth implements Transformer { /** * A transducer that takes every Nth input */ -export function takeNth(n: number): Transducer; +export function takeNth(n: number): Transducer; export class Drop implements Transformer { constructor(n: number, xf: Transformer); @@ -160,7 +158,7 @@ export class Drop implements Transformer { /** * A dropping transducer constructor */ -export function drop(n: number): Transducer; +export function drop(n: number): Transducer; export class DropWhile implements Transformer { constructor(pred: (input: TInput) => boolean, xf: Transformer); @@ -173,7 +171,7 @@ export class DropWhile implements Transformer * A dropping transducer that drop inputs as long as * pred is true. */ -export function dropWhile(pred: (input: TInput) => boolean): Transducer; +export function dropWhile(pred: (input: TInput) => boolean): Transducer; export class PartitionBy implements Transformer { constructor(f: (input: TInput) => any, xf: Transformer); @@ -187,7 +185,7 @@ export class PartitionBy implements Transformer(f: (input: TInput) => any): Transducer; +export function partitionBy(f: (input: TInput) => any): Transducer; export class PartitionAll implements Transformer { constructor(n: number, xf: Transformer); @@ -200,7 +198,7 @@ export class PartitionAll implements Transformer(n: number): Transducer; +export function partitionAll(n: number): Transducer; export class Completing implements CompletingTransformer { constructor(cf: (result: TResult) => TCompleteResult, xf: Transformer); @@ -213,10 +211,12 @@ export class Completing implements CompletingT * A completing transducer constructor. Useful to provide cleanup * logic at the end of a reduction/transduction. */ -export function completing(cf: (result: TResult) => TCompleteResult): CompletingTransformer; +export function completing( + xf: Transformer | Reducer, + cf: (result: TResult) => TCompleteResult): CompletingTransformer; export class Wrap implements Transformer { - constructor(stepFn: Reducer, xf: Transformer); + constructor(stepFn: Reducer); ['@@transducer/init'](): TResult; ['@@transducer/step'](result: TResult, input: TInput): TResult; ['@@transducer/result'](result: TResult): TResult; @@ -227,44 +227,102 @@ export class Wrap implements Transformer { * accumluation and the second argument is the next input and convert * it into a transducer transformer object. */ -export function wrap(stepFn: Reducer): Transducer; +export function wrap(stepFn: Reducer): Transformer; /** * Given a transformer return a concatenating transformer */ -export function cat(xf: Transformer): Transformer ; +export function cat(xf: Transformer): Transformer>; /** * A mapping concatenating transformer */ -export function mapcat(f: (arr: TInput[]) => TOutput[]): Transducer; +export function mapcat(f: (arr: TInput) => Iterable): Transducer; /** * Given a transducer, a builder function, an initial value * and a iterable collection - returns the reduction. */ export function transduce( - xf: Transducer, - f: Transformer | Reducer, + xf: Transducer, + f: Reducer, init: TResult, - coll: TInput[] | Iterator | string | Object): TResult; + coll: Iterable): TResult; +export function transduce( + xf: Transducer, + f: CompletingTransformer, + init: TResult, + coll: Iterable): TCompleteResult; +export function transduce( + xf: Transducer, + f: CompletingTransformer, + coll: Iterable): TCompleteResult; +// Overloads for object iteration. +export function transduce( + xf: Transducer<[string, TInput], TOutput>, + f: Reducer, + init: TResult, + coll: { [key: string]: TInput }): TResult; +export function transduce( + xf: Transducer<[string, TInput], TOutput>, + f: CompletingTransformer, + init: TResult, + coll: { [key: string]: TInput }): TCompleteResult; +export function transduce( + xf: Transducer<[string, TInput], TOutput>, + f: CompletingTransformer, + coll: { [key: string]: TInput }): TCompleteResult; /** * Given a transducer, an intial value and a * collection - returns the reduction. */ -export function reduce( - xf: Transducer, +export function reduce( + xf: Transformer | Reducer, init: TResult, - coll: TInput[] | Iterator | string | Object): TResult; + coll: Iterable): TResult; +export function reduce( + xf: CompletingTransformer, + init: TResult, + coll: Iterable): TCompleteResult; +// Overloads for object iteration. +export function reduce( + xf: Transformer | Reducer, + init: TResult, + coll: { [key: string]: TInput }): TResult; +export function reduce( + xf: CompletingTransformer, + init: TResult, + coll: { [key: string]: TInput }): TCompleteResult; /** * Reduce a value into the given empty value using a transducer. */ -export function into( - empty: TResult, - xf: Transducer, - coll: TInput[] | Iterator | string | Object): TResult; +export function into( + empty: TOutput[], + xf: Transducer, + coll: Iterable): TOutput[]; +export function into( + empty: string, + xf: Transducer, + coll: Iterable): string; +export function into( + empty: { [key: string]: TOutput }, + xf: Transducer, + coll: Iterable): { [key: string]: TOutput }; +// Overloads for object iteration. +export function into( + empty: TOutput[], + xf: Transducer<[string, TInput], TOutput>, + coll: { [key: string]: TInput }): TOutput[]; +export function into( + empty: string, + xf: Transducer<[string, TInput], string>, + coll: { [key: string]: TInput }): string; +export function into( + empty: { [key: string]: TOutput }, + xf: Transducer<[string, TInput], [string, TOutput]>, + coll: { [key: string]: TInput }): { [key: string]: TOutput }; /** * Convert a transducer transformer object into a function so @@ -272,9 +330,9 @@ export function into( * Underscore, lodash */ export function toFn( - xf: Transducer, - builder: Reducer | Transformer -): Reducer; + xf: Transducer, + builder: Reducer | Transformer +): Reducer; /** * A transformer which simply returns the first input. diff --git a/types/transducers-js/transducers-js-tests.ts b/types/transducers-js/transducers-js-tests.ts index 634309a2b5..7a82b595c8 100644 --- a/types/transducers-js/transducers-js-tests.ts +++ b/types/transducers-js/transducers-js-tests.ts @@ -124,3 +124,59 @@ function mapcatExample() { const xf = t.mapcat(reverse); t.into([], xf, [[3, 2, 1], [6, 5, 4]]); // [1, 2, 3, 4, 5, 6] } + +// Original tests + +function transduceExample() { + const { completing, transduce, wrap } = t; + const stringAppendFn = (acc: string, x: number) => acc + x; + const stringAppendTransformer = wrap(stringAppendFn); + const stringAppendThenLengthTransformer = completing( + stringAppendFn, + s => s.length, + ); + const lengthsString1: string = transduce( + t.map((s: string) => s.length), + stringAppendFn, + "", + ["a", "b"], + ); + const lengthsString2: string = transduce( + t.map((s: string) => s.length), + stringAppendTransformer, + "", + ["a", "b"], + ); + const lengthsStringLength: number = transduce( + t.map((s: string) => s.length), + stringAppendThenLengthTransformer, + "", + ["a", "b"], + ); +} + +function advancedIntoExample() { + const array: number[] = into([], t.map((s: string) => s.length), [ + "a", + "b", + ]); + const string: string = into("", t.map((s: string) => s + s), ["a", "b"]); + const object1: { [key: string]: number } = into( + {}, + t.map((s: string) => [s, s.length]), + ["a", "b"], + ); + const object2: { [key: string]: boolean } = into( + {}, + t.map((kv: [string, number]) => [kv[0], true]), + { a: 1, b: 2 } + ); +} + +function compExample() { + const fn1: t.Transducer = comp(map(inc), filter(isEven)); + const fn2: t.Transducer = comp( + filter(isEven), + map((x: number) => "" + x), + ); +} diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 11dcf477a0..f72bb3ca68 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -156,7 +156,7 @@ _.where(listOfPlays, { author: "Shakespeare", year: 1611 }); var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); -_.every([true, 1, null, 'yes'], _.identity); +_.every([true, 1, null, 'yes'], x => !!_.identity(x)); _.any([null, 0, 'yes', false]); diff --git a/types/uppercamelcase/index.d.ts b/types/uppercamelcase/index.d.ts index cbdfed1925..b1e0ff34ba 100644 --- a/types/uppercamelcase/index.d.ts +++ b/types/uppercamelcase/index.d.ts @@ -5,3 +5,4 @@ declare function upperCamelCase(...args: string[]): string; export = upperCamelCase; +declare namespace upperCamelCase { } diff --git a/types/uppercamelcase/uppercamelcase-tests.ts b/types/uppercamelcase/uppercamelcase-tests.ts index 29d31d58e6..eb850ee8cd 100644 --- a/types/uppercamelcase/uppercamelcase-tests.ts +++ b/types/uppercamelcase/uppercamelcase-tests.ts @@ -1,4 +1,5 @@ import upperCamelCase = require('uppercamelcase'); +import * as upperCamelCase2 from "uppercamelcase"; upperCamelCase('foo-bar'); //=> FooBar diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index cc686b93b0..88cf8a6318 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for webpack 3.0 // Project: https://github.com/webpack/webpack // Definitions by: Qubo -// Matt Lewis // Benjamin Lim // Boris Cherny // Tommy Troy Lin @@ -504,7 +503,7 @@ declare namespace webpack { * Turns hints on/off. In addition, tells webpack to throw either an error or a warning when hints are * found. This property is set to "warning" by default. */ - hints?: 'warning' | 'error' | boolean; + hints?: 'warning' | 'error' | false; /** * An asset is any emitted file from webpack. This option controls when webpack emits a performance hint * based on individual asset size. The default value is 250000 (bytes). @@ -1216,7 +1215,7 @@ declare namespace webpack { * Target of compilation. Passed from configuration options. * Example values: "web", "node" */ - target: 'web' | 'node' | string; + target: 'web' | 'webworker' | 'async-node' | 'node' | 'electron-main' | 'electron-renderer' | 'node-webkit' | string; /** * This boolean is set to true when this is compiled by webpack. diff --git a/types/websocket/index.d.ts b/types/websocket/index.d.ts index 83d127c599..3b41a5f6da 100644 --- a/types/websocket/index.d.ts +++ b/types/websocket/index.d.ts @@ -181,7 +181,7 @@ export interface IExtension { export declare class request extends events.EventEmitter { /** A reference to the original Node HTTP request object */ - httpRequest: http.ClientRequest; + httpRequest: http.IncomingMessage; /** This will include the port number if a non-standard port is used */ host: string; /** A string containing the path that was requested by the client */ @@ -222,7 +222,7 @@ export declare class request extends events.EventEmitter { requestedProtocols: string[]; protocolFullCaseMap: { [key: string]: string }; - constructor(socket: net.Socket, httpRequest: http.ClientRequest, config: IServerConfig); + constructor(socket: net.Socket, httpRequest: http.IncomingMessage, config: IServerConfig); /** * After inspecting the `request` properties, call this function on the @@ -580,7 +580,7 @@ declare class client extends events.EventEmitter { declare class routerRequest extends events.EventEmitter { /** A reference to the original Node HTTP request object */ - httpRequest: http.ClientRequest; + httpRequest: http.IncomingMessage; /** A string containing the path that was requested by the client */ resource: string; /** Parsed resource, including the query string parameters */