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/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/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/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/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/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/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/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/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/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.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/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/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/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/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-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-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 ef2486fef5..5f9e6e3856 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -1,8 +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 5286540963..1d07494104 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -4,6 +4,7 @@ // mhcgrq // fangpenlin // abrahambotros +// petejkim // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -188,46 +189,63 @@ export interface NavigationParams { [key: string]: any, } -export type NavigationNavigateAction = { - type: 'Navigation/NAVIGATE', +export interface NavigationNavigateActionPayload { routeName: string, params?: NavigationParams, // The action to run inside the sub-router action?: NavigationNavigateAction, -}; +} -export type NavigationBackAction = { - type: 'Navigation/BACK', +export interface NavigationNavigateAction extends NavigationNavigateActionPayload { + type: 'Navigation/NAVIGATE', +} + +export interface NavigationBackActionPayload { key?: string | null, -}; +} -export type NavigationSetParamsAction = { - type: 'Navigation/SET_PARAMS', +export interface NavigationBackAction extends NavigationBackActionPayload { + type: 'Navigation/BACK', +} +export interface NavigationSetParamsActionPayload { // The key of the route where the params should be set key: string, // The new params to merge into the existing route params params?: NavigationParams, -}; +} -export type NavigationInitAction = { - type: 'Navigation/INIT', +export interface NavigationSetParamsAction extends NavigationSetParamsActionPayload { + type: 'Navigation/SET_PARAMS', +} + +export interface NavigationInitActionPayload { params?: NavigationParams, -}; +} -export type NavigationResetAction = { - type: 'Navigation/RESET', +export interface NavigationInitAction extends NavigationInitActionPayload { + type: 'Navigation/INIT', +} + +export interface NavigationResetActionPayload { index: number, key?: string | null, actions: Array, -}; +} -export type NavigationUriAction = { - type: 'Navigation/URI', +export interface NavigationResetAction extends NavigationResetActionPayload { + type: 'Navigation/RESET', +} + +export interface NavigationUriActionPayload { uri: string, -}; +} + +export interface NavigationUriAction extends NavigationUriActionPayload { + type: 'Navigation/URI', +} export interface NavigationStackViewConfig { mode?: 'card' | 'modal', @@ -575,15 +593,13 @@ export const TabBarBottom: React.ComponentClass; /** * NavigationActions - * @todo Is this necessary, or can we remove? Not referenced anywhere else here, but it seems a - * recent commit or two touches these. Can anyone provide a strong use case for keeping this in? */ 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; + 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; } /** diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 835e63d756..1840fd7ccf 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -5,22 +5,28 @@ import { ViewStyle, } from 'react-native'; import { - addNavigationHelpers, + NavigationAction, + NavigationActions, + NavigationBackAction, + NavigationInitAction, + NavigationNavigateAction, + NavigationProp, + NavigationResetAction, NavigationRouteConfigMap, NavigationScreenProp, NavigationScreenProps, + NavigationSetParamsAction, NavigationStackAction, NavigationStackScreenOptions, NavigationTabScreenOptions, + NavigationTransitionProps, StackNavigator, StackNavigatorConfig, + TabBarTop, TabNavigator, TabNavigatorConfig, - TabBarTop, Transitioner, - NavigationProp, - NavigationAction, - NavigationTransitionProps, + addNavigationHelpers, } from 'react-navigation'; // Constants @@ -42,6 +48,7 @@ interface StartScreenNavigationParams { id: number, s: string, } + interface StartScreenProps extends NavigationScreenProps { } class StartScreen extends React.Component { render() { @@ -219,3 +226,36 @@ class CustomTransitioner extends React.Component return {} } } + +const initAction: NavigationInitAction = NavigationActions.init({ + params: { + foo: "bar" + } +}) + +const navigateAction: NavigationNavigateAction = NavigationActions.navigate({ + routeName: "FooScreen", + params: { + foo: "bar" + }, + action: NavigationActions.navigate({ routeName: "BarScreen" }) +}) + +const resetAction: NavigationResetAction = NavigationActions.reset({ + index: 0, + key: "foo", + actions: [ + NavigationActions.navigate({ routeName: "FooScreen" }) + ] +}) + +const backAction: NavigationBackAction = NavigationActions.back({ + key: "foo" +}) + +const setParamsAction: NavigationSetParamsAction = NavigationActions.setParams({ + key: "foo", + params: { + foo: "bar" + } +}) 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 b0356ae4b6..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, @@ -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 77e46e49aa..27acc07d34 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -190,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/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/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/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/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 */