diff --git a/types/atob/index.d.ts b/types/atob/index.d.ts index 632880f7a6..1feb3481e8 100644 --- a/types/atob/index.d.ts +++ b/types/atob/index.d.ts @@ -2,6 +2,6 @@ // Project: https://git.coolaj86.com/coolaj86/atob.js.git // Definitions by: John Wright // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.1 export default function(str: string): string; diff --git a/types/documentdb/index.d.ts b/types/documentdb/index.d.ts index e7962ba568..118881a378 100644 --- a/types/documentdb/index.d.ts +++ b/types/documentdb/index.d.ts @@ -802,7 +802,7 @@ export class DocumentClient { * @param [options] - Represents the feed options. * @returns - An instance of queryIterator to handle reading feed. */ - queryDocuments(collectionLink: string, query: DocumentQuery, options?: FeedOptions): QueryIterator; + queryDocuments(collectionLink: string, query: DocumentQuery, options?: FeedOptions): QueryIterator; /** * Query the triggers for the collection. diff --git a/types/highland/highland-tests.ts b/types/highland/highland-tests.ts index a1c48c944b..fc63a23925 100644 --- a/types/highland/highland-tests.ts +++ b/types/highland/highland-tests.ts @@ -333,6 +333,12 @@ fooStream.toArray((arr: Foo[]) => {}); fooStream.toCallback((err: Error, x: Foo) => {}); fooStream.toCallback((err: Error) => {}); +fooStream.toNodeStream(); +fooStream.toNodeStream({objectMode: false}); +fooStream.toNodeStream({objectMode: true}); + +fooStream.toPromise(Promise); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // UTILS // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/types/highland/index.d.ts b/types/highland/index.d.ts index 473e93880a..7203e959ab 100644 --- a/types/highland/index.d.ts +++ b/types/highland/index.d.ts @@ -1,9 +1,10 @@ -// Type definitions for Highland 2.10.5 +// Type definitions for Highland 2.12.0 // Project: http://highlandjs.org/ // Definitions by: Bart van der Schoor // Hugo Wood // William Yu // Alvis HT Tang +// Jack Wearden // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -1319,6 +1320,25 @@ declare namespace Highland { */ toCallback(cb: (err?: Error, x?: R) => void): void; + /** + * Converts the stream to a node Readable Stream for use in methods + * or pipes that depend on the native stream type. + * + * The options parameter can be an object passed into the [`Readable` + * constructor](http://nodejs.org/api/stream.html#stream_class_stream_readable). + * + * @id toNodeStream + * @section Consumption + * @name Stream.toNodeStream(options) + * @param {Object} options - (optional) [`Readable` constructor](http://nodejs.org/api/stream.html#stream_class_stream_readable) options + * @api public + * + * _(fs.createReadStream('./abc')).toNodeStream() + * _(fs.createReadStream('./abc')).toNodeStream({objectMode: false}) + * _([{a: 1}]).toNodeStream({objectMode: true}) + */ + toNodeStream(options?: object): NodeJS.ReadableStream; + /** * Converts the result of a stream to Promise. * diff --git a/types/ioredis/index.d.ts b/types/ioredis/index.d.ts index 8256fea80b..7172f1e97d 100644 --- a/types/ioredis/index.d.ts +++ b/types/ioredis/index.d.ts @@ -458,6 +458,13 @@ declare namespace IORedis { } interface Pipeline { + redis: Redis; + isCluster: boolean; + options: RedisOptions; + _queue: Command[]; + _result: any[]; + _transactions: number; + _shaToScript: {}; bitcount(key: string, callback?: (err: Error, res: number) => void): Pipeline; bitcount(key: string, start: number, end: number, callback?: (err: Error, res: number) => void): Pipeline; diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index dd36f3b269..e32b9f05f0 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -342,7 +342,7 @@ declare namespace jest { } interface ExpectExtendMap { - [key: string]: (this: MatcherUtils, received: any, ...actual: any[]) => { message(): string, pass: boolean } | Promise<{ message(): string, pass: boolean }>; + [key: string]: (this: MatcherUtils, received: any, ...actual: any[]) => { message(): string | (() => string), pass: boolean } | Promise<{ message(): string, pass: boolean }>; } interface SnapshotSerializerOptions { diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index c6b00a4479..c54ebc3369 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -425,6 +425,72 @@ expect.extend({ }; } }); +expect.extend({ + async foo(this: jest.MatcherUtils, received: {}, ...actual: Array<{}>) { + return { + message: () => JSON.stringify(received), + pass: false, + }; + } +}); +expect.extend({ + foo(this: jest.MatcherUtils) { + const isNot: boolean = this.isNot; + + const expectedColor = this.utils.EXPECTED_COLOR("blue"); + const receivedColor = this.utils.EXPECTED_COLOR("red"); + + this.utils.ensureActualIsNumber({}); + this.utils.ensureActualIsNumber({}, "matcher"); + + this.utils.ensureExpectedIsNumber({}); + this.utils.ensureExpectedIsNumber({}, "matcher"); + + this.utils.ensureNoExpected({}); + this.utils.ensureNoExpected({}, "matcher"); + + this.utils.ensureNumbers({}, {}); + this.utils.ensureNumbers({}, {}, "matcher"); + + const valueType: string = this.utils.getType({}); + + this.utils.matcherHint("matcher"); + this.utils.matcherHint("matcher", "received"); + this.utils.matcherHint("matcher", "received", "expected"); + this.utils.matcherHint("matcher", "received", "expected", {}); + this.utils.matcherHint("matcher", "received", "expected", { + isDirectExpectCall: true, + }); + this.utils.matcherHint("matcher", "received", "expected", { + secondArgument: "", + }); + this.utils.matcherHint("matcher", "received", "expected", { + isDirectExpectCall: true, + secondArgument: "", + }); + + const plural: string = this.utils.pluralize("word", 3); + + const expectedPrinted: string = this.utils.printExpected({}); + + const receivedPrinted: string = this.utils.printReceived({}); + + const printedWithType: string = this.utils.printWithType( + "name", + {}, + (value: {}) => ""); + + const stringified: string = this.utils.stringify({}); + const stringifiedWithMaxDepth: string = this.utils.stringify({}, 3); + + const equals: boolean = this.equals({}, {}); + + return { + message: () => "", + pass: false, + }; + } +}); /* Basic matchers */ diff --git a/types/koa-bodyparser/index.d.ts b/types/koa-bodyparser/index.d.ts index 1664e86cac..deb1eb04e9 100644 --- a/types/koa-bodyparser/index.d.ts +++ b/types/koa-bodyparser/index.d.ts @@ -23,51 +23,54 @@ declare module "koa" { } } -declare function bodyParser(opts?: { - /** - * parser will only parse when request type hits enableTypes, default is ['json', 'form']. - */ - enableTypes?: string[]; - /** - * requested encoding. Default is utf-8 by co-body - */ - encode?: string; +declare function bodyParser(opts?: bodyParser.Options): Koa.Middleware; - /** - * limit of the urlencoded body. If the body ends up being larger than this limit - * a 413 error code is returned. Default is 56kb - */ - formLimit?: string; +declare namespace bodyParser { + interface Options { + /** + * parser will only parse when request type hits enableTypes, default is ['json', 'form']. + */ + enableTypes?: string[]; + /** + * requested encoding. Default is utf-8 by co-body + */ + encode?: string; - /** - * limit of the json body. Default is 1mb - */ - jsonLimit?: string; + /** + * limit of the urlencoded body. If the body ends up being larger than this limit + * a 413 error code is returned. Default is 56kb + */ + formLimit?: string; - /** - * when set to true, JSON parser will only accept arrays and objects. Default is true - */ - strict?: boolean; + /** + * limit of the json body. Default is 1mb + */ + jsonLimit?: string; - /** - * custom json request detect function. Default is null - */ - detectJSON?: (ctx: Koa.Context) => boolean; + /** + * when set to true, JSON parser will only accept arrays and objects. Default is true + */ + strict?: boolean; - /** - * support extend types - */ - extendTypes?: { - json?: string[]; - form?: string[]; - text?: string[]; + /** + * custom json request detect function. Default is null + */ + detectJSON?: (ctx: Koa.Context) => boolean; + + /** + * support extend types + */ + extendTypes?: { + json?: string[]; + form?: string[]; + text?: string[]; + }; + + /** + * support custom error handle + */ + onerror?: (err: Error, ctx: Koa.Context) => void; } +} - /** - * support custom error handle - */ - onerror?: (err: Error, ctx: Koa.Context) => void; -}): Koa.Middleware; - -declare namespace bodyParser { } export = bodyParser; diff --git a/types/koa-csrf/index.d.ts b/types/koa-csrf/index.d.ts index 268e261134..f8bfccd030 100644 --- a/types/koa-csrf/index.d.ts +++ b/types/koa-csrf/index.d.ts @@ -24,7 +24,7 @@ export = koaCsrf; import { Middleware } from 'koa'; declare module "koa" { - interface Request { + interface Context { csrf: string; } } diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 89f9625114..47b2ebc515 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -390,6 +390,7 @@ export interface LayerOptions { export interface InteractiveLayerOptions extends LayerOptions { interactive?: boolean; + bubblingMouseEvents?: boolean; } export class Layer extends Evented { @@ -542,12 +543,13 @@ export namespace tileLayer { function wms(baseUrl: string, options?: WMSOptions): TileLayer.WMS; } -export interface ImageOverlayOptions extends LayerOptions { +export interface ImageOverlayOptions extends InteractiveLayerOptions { opacity?: number; alt?: string; interactive?: boolean; attribution?: string; crossOrigin?: boolean; + className?: string; } export class ImageOverlay extends Layer { diff --git a/types/leaflet/leaflet-tests.ts b/types/leaflet/leaflet-tests.ts index a22ab91248..1f6671cc8c 100644 --- a/types/leaflet/leaflet-tests.ts +++ b/types/leaflet/leaflet-tests.ts @@ -251,6 +251,29 @@ tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png'); tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', tileLayerOptions); tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}&{bar}&{abc}', {foo: 'bar', bar: (data: any) => 'foo', abc: () => ''}); +// imageOverlay +let imageOverlayOptions: L.ImageOverlayOptions; +imageOverlayOptions = { + opacity: 100, + alt: 'alt', + interactive: true, + attribution: 'attribution', + crossOrigin: true, + className: 'className', + bubblingMouseEvents: false, + pane: 'pane' +}; + +const imageOverlayBounds = latLngBounds; +let imageOverlay: L.ImageOverlay; +imageOverlay = L.imageOverlay('https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png', imageOverlayBounds); +imageOverlay = L.imageOverlay('https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png', imageOverlayBounds, imageOverlayOptions); +imageOverlay = L.imageOverlay('https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png', imageOverlayBounds, { + opacity: 100, + alt: 'alt', + className: 'className', +}); + const eventHandler = () => {}; const domEvent: Event = {} as Event; L.DomEvent diff --git a/types/lodash/common/object.d.ts b/types/lodash/common/object.d.ts index 5e2d539c23..a729140e02 100644 --- a/types/lodash/common/object.d.ts +++ b/types/lodash/common/object.d.ts @@ -2951,6 +2951,22 @@ declare module "../index" { * _.omitBy(object, _.isNumber); * // => { 'b': '2' } */ + omitBy( + object: Dictionary | null | undefined, + predicate?: ValueKeyIteratee + ): Dictionary; + + /** + * @see _.omitBy + */ + omitBy( + object: NumericDictionary | null | undefined, + predicate?: ValueKeyIteratee + ): NumericDictionary; + + /** + * @see _.omitBy + */ omitBy( object: T | null | undefined, predicate: ValueKeyIteratee @@ -2958,6 +2974,22 @@ declare module "../index" { } interface LoDashImplicitWrapper { + /** + * @see _.omitBy + */ + omitBy( + this: LoDashImplicitWrapper | null | undefined>, + predicate?: ValueKeyIteratee + ): LoDashImplicitWrapper>; + + /** + * @see _.omitBy + */ + omitBy( + this: LoDashImplicitWrapper | null | undefined>, + predicate?: ValueKeyIteratee + ): LoDashImplicitWrapper>; + /** * @see _.omitBy */ @@ -2968,6 +3000,22 @@ declare module "../index" { } interface LoDashExplicitWrapper { + /** + * @see _.omitBy + */ + omitBy( + this: LoDashExplicitWrapper | null | undefined>, + predicate?: ValueKeyIteratee + ): LoDashExplicitWrapper>; + + /** + * @see _.omitBy + */ + omitBy( + this: LoDashExplicitWrapper | null | undefined>, + predicate?: ValueKeyIteratee + ): LoDashExplicitWrapper>; + /** * @see _.omitBy */ @@ -3063,6 +3111,22 @@ declare module "../index" { * _.pickBy(object, _.isNumber); * // => { 'a': 1, 'c': 3 } */ + pickBy( + object: Dictionary | null | undefined, + predicate?: ValueKeyIteratee + ): Dictionary; + + /** + * @see _.pickBy + */ + pickBy( + object: NumericDictionary | null | undefined, + predicate?: ValueKeyIteratee + ): NumericDictionary; + + /** + * @see _.pickBy + */ pickBy( object: T | null | undefined, predicate?: ValueKeyIteratee @@ -3070,6 +3134,22 @@ declare module "../index" { } interface LoDashImplicitWrapper { + /** + * @see _.pickBy + */ + pickBy( + this: LoDashImplicitWrapper | null | undefined>, + predicate?: ValueKeyIteratee + ): LoDashImplicitWrapper>; + + /** + * @see _.pickBy + */ + pickBy( + this: LoDashImplicitWrapper | null | undefined>, + predicate?: ValueKeyIteratee + ): LoDashImplicitWrapper>; + /** * @see _.pickBy */ @@ -3080,6 +3160,22 @@ declare module "../index" { } interface LoDashExplicitWrapper { + /** + * @see _.pickBy + */ + pickBy( + this: LoDashExplicitWrapper | null | undefined>, + predicate?: ValueKeyIteratee + ): LoDashExplicitWrapper>; + + /** + * @see _.pickBy + */ + pickBy( + this: LoDashExplicitWrapper | null | undefined>, + predicate?: ValueKeyIteratee + ): LoDashExplicitWrapper>; + /** * @see _.pickBy */ diff --git a/types/lodash/fp.d.ts b/types/lodash/fp.d.ts index c799bd734b..2185fbf4aa 100644 --- a/types/lodash/fp.d.ts +++ b/types/lodash/fp.d.ts @@ -2289,11 +2289,21 @@ declare namespace _ { } interface LodashOmitBy { (predicate: lodash.ValueKeyIteratee): LodashOmitBy1x1; - (predicate: lodash.__, object: T | null | undefined): LodashOmitBy1x2; + (predicate: lodash.__, object: lodash.Dictionary | null | undefined): LodashOmitBy1x2; + (predicate: lodash.ValueKeyIteratee, object: lodash.Dictionary | null | undefined): lodash.Dictionary; + (predicate: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashOmitBy2x2; + (predicate: lodash.ValueKeyIteratee, object: lodash.NumericDictionary | null | undefined): lodash.NumericDictionary; + (predicate: lodash.__, object: T | null | undefined): LodashOmitBy3x2; (predicate: lodash.ValueKeyIteratee, object: T | null | undefined): lodash.PartialObject; } - type LodashOmitBy1x1 = (object: T1 | null | undefined) => lodash.PartialObject; - type LodashOmitBy1x2 = (predicate: lodash.ValueKeyIteratee) => lodash.PartialObject; + interface LodashOmitBy1x1 { + (object: lodash.Dictionary | null | undefined): lodash.Dictionary; + (object: lodash.NumericDictionary | null | undefined): lodash.NumericDictionary; + (object: T1 | null | undefined): lodash.PartialObject; + } + type LodashOmitBy1x2 = (predicate: lodash.ValueKeyIteratee) => lodash.Dictionary; + type LodashOmitBy2x2 = (predicate: lodash.ValueKeyIteratee) => lodash.NumericDictionary; + type LodashOmitBy3x2 = (predicate: lodash.ValueKeyIteratee) => lodash.PartialObject; type LodashOnce = any>(func: T) => T; interface LodashOrderBy { (iteratees: lodash.Many<(value: T) => lodash.NotVoid>): LodashOrderBy1x1; @@ -2873,11 +2883,21 @@ declare namespace _ { type LodashPick2x2 = (props: lodash.PropertyPath) => lodash.PartialDeep; interface LodashPickBy { (predicate: lodash.ValueKeyIteratee): LodashPickBy1x1; - (predicate: lodash.__, object: T | null | undefined): LodashPickBy1x2; + (predicate: lodash.__, object: lodash.Dictionary | null | undefined): LodashPickBy1x2; + (predicate: lodash.ValueKeyIteratee, object: lodash.Dictionary | null | undefined): lodash.Dictionary; + (predicate: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashPickBy2x2; + (predicate: lodash.ValueKeyIteratee, object: lodash.NumericDictionary | null | undefined): lodash.NumericDictionary; + (predicate: lodash.__, object: T | null | undefined): LodashPickBy3x2; (predicate: lodash.ValueKeyIteratee, object: T | null | undefined): lodash.PartialObject; } - type LodashPickBy1x1 = (object: T1 | null | undefined) => lodash.PartialObject; - type LodashPickBy1x2 = (predicate: lodash.ValueKeyIteratee) => lodash.PartialObject; + interface LodashPickBy1x1 { + (object: lodash.Dictionary | null | undefined): lodash.Dictionary; + (object: lodash.NumericDictionary | null | undefined): lodash.NumericDictionary; + (object: T1 | null | undefined): lodash.PartialObject; + } + type LodashPickBy1x2 = (predicate: lodash.ValueKeyIteratee) => lodash.Dictionary; + type LodashPickBy2x2 = (predicate: lodash.ValueKeyIteratee) => lodash.NumericDictionary; + type LodashPickBy3x2 = (predicate: lodash.ValueKeyIteratee) => lodash.PartialObject; interface LodashProp { (path: TKey | [TKey]): LodashProp1x1; (path: lodash.__, object: TObject): LodashProp1x2; diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 88a5a88bfc..bc6084a005 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -5561,13 +5561,23 @@ fp.now(); // $ExpectType number // _.omitBy { const obj: AbcObject | null | undefined = anything; + const dictionary: _.Dictionary | null | undefined = anything; + const numericDictionary: _.NumericDictionary | null | undefined = anything; const predicate = (element: string | number | boolean, key: string) => true; + const predicate2 = (element: boolean, key: string) => true; _.omitBy(obj, predicate); // $ExpectType Partial + _.omitBy(dictionary, predicate2); // $ExpectType Dictionary + _.omitBy(numericDictionary, predicate2); // $ExpectType NumericDictionary _(obj).omitBy(predicate); // $ExpectType LoDashImplicitWrapper> + _(dictionary).omitBy(predicate2); // $ExpectType LoDashImplicitWrapper> + _(numericDictionary).omitBy(predicate2); // $ExpectType LoDashImplicitWrapper> _.chain(obj).omitBy(predicate); // $ExpectType LoDashExplicitWrapper> + _.chain(dictionary).omitBy(predicate2); // $ExpectType LoDashExplicitWrapper> + _.chain(numericDictionary).omitBy(predicate2); // $ExpectType LoDashExplicitWrapper> fp.omitBy(predicate, obj); // $ExpectType Partial - fp.omitBy(predicate)(obj); // $ExpectType Partial + fp.omitBy(predicate2)(dictionary); // $ExpectType Dictionary + fp.omitBy(predicate2)(numericDictionary); // $ExpectType NumericDictionary } // _.pick @@ -5584,8 +5594,10 @@ fp.now(); // $ExpectType number _.pick(obj1, readonlyArray); // $ExpectType PartialDeep // Broken in TS 2.4 // _.pick(obj2, "a", "b"); // Pick - _.pick(obj2, literalsArray); // $ExpectType Pick - _.pick(obj2, roLiteralsArray); // $ExpectType Pick + // We can't use ExpectType here because typescript keeps changing what order the types appear. + let result1: Pick; + result1 = _.pick(obj2, literalsArray); + result1 = _.pick(obj2, roLiteralsArray); _(obj1).pick("a"); // $ExpectType LoDashImplicitWrapper> _(obj1).pick(0, "a"); // $ExpectType LoDashImplicitWrapper> @@ -5593,8 +5605,9 @@ fp.now(); // $ExpectType number _(obj1).pick(readonlyArray); // $ExpectType LoDashImplicitWrapper> // Broken in TS 2.4 // _(obj2).pick("a", "b"); // LoDashImplicitWrapper> - _(obj2).pick(literalsArray); // $ExpectType LoDashImplicitWrapper> - _(obj2).pick(roLiteralsArray); // $ExpectType LoDashImplicitWrapper> + let result2: _.LoDashImplicitWrapper>; + result2 = _(obj2).pick(literalsArray); + result2 = _(obj2).pick(roLiteralsArray); _.chain(obj1).pick("a"); // $ExpectType LoDashExplicitWrapper> _.chain(obj1).pick(0, "a"); // $ExpectType LoDashExplicitWrapper> @@ -5602,24 +5615,35 @@ fp.now(); // $ExpectType number _.chain(obj1).pick(readonlyArray); // $ExpectType LoDashExplicitWrapper> // Broken in TS 2.4 // _.chain(obj2).pick("a", "b"); // LoDashExplicitWrapper> - _.chain(obj2).pick(literalsArray); // $ExpectType LoDashExplicitWrapper> - _.chain(obj2).pick(roLiteralsArray); // $ExpectType LoDashExplicitWrapper> + let result3: _.LoDashExplicitWrapper>; + result3 = _.chain(obj2).pick(literalsArray); + result3 = _.chain(obj2).pick(roLiteralsArray); fp.pick("a", obj2); // $ExpectType Pick fp.pick("a")(obj2); // $ExpectType Pick - fp.pick(literalsArray)(obj2); // $ExpectType Pick + result1 = fp.pick(literalsArray)(obj2); } // _.pickBy { const obj: AbcObject | null | undefined = anything; + const dictionary: _.Dictionary | null | undefined = anything; + const numericDictionary: _.NumericDictionary | null | undefined = anything; const predicate = (element: string | number | boolean, key: string) => true; + const predicate2 = (element: boolean, key: string) => true; _.pickBy(obj, predicate); // $ExpectType Partial + _.pickBy(dictionary, predicate2); // $ExpectType Dictionary + _.pickBy(numericDictionary, predicate2); // $ExpectType NumericDictionary _(obj).pickBy(predicate); // $ExpectType LoDashImplicitWrapper> + _(dictionary).pickBy(predicate2); // $ExpectType LoDashImplicitWrapper> + _(numericDictionary).pickBy(predicate2); // $ExpectType LoDashImplicitWrapper> _.chain(obj).pickBy(predicate); // $ExpectType LoDashExplicitWrapper> + _.chain(dictionary).pickBy(predicate2); // $ExpectType LoDashExplicitWrapper> + _.chain(numericDictionary).pickBy(predicate2); // $ExpectType LoDashExplicitWrapper> fp.pickBy(predicate, obj); // $ExpectType Partial - fp.pickBy(predicate)(obj); // $ExpectType Partial + fp.pickBy(predicate2)(dictionary); // $ExpectType Dictionary + fp.pickBy(predicate2)(numericDictionary); // $ExpectType NumericDictionary } // _.result diff --git a/types/lowdb/_lodash.d.ts b/types/lowdb/_lodash.d.ts index a7d2c424f0..862e8d39bd 100644 --- a/types/lowdb/_lodash.d.ts +++ b/types/lowdb/_lodash.d.ts @@ -1273,6 +1273,14 @@ declare module "./index" { this: LoDashExplicitSyncWrapper, ...paths: Array<_.Many<_.PropertyName>> ): LoDashExplicitSyncWrapper<_.PartialObject>; + omitBy( + this: LoDashExplicitSyncWrapper<_.Dictionary | null | undefined>, + predicate?: _.ValueKeyIteratee + ): LoDashExplicitSyncWrapper<_.Dictionary>; + omitBy( + this: LoDashExplicitSyncWrapper<_.NumericDictionary | null | undefined>, + predicate?: _.ValueKeyIteratee + ): LoDashExplicitSyncWrapper<_.NumericDictionary>; omitBy( this: LoDashExplicitSyncWrapper, predicate: _.ValueKeyIteratee @@ -1285,6 +1293,14 @@ declare module "./index" { this: LoDashExplicitSyncWrapper, ...props: _.PropertyPath[] ): LoDashExplicitSyncWrapper<_.PartialObject>; + pickBy( + this: LoDashExplicitSyncWrapper<_.Dictionary | null | undefined>, + predicate?: _.ValueKeyIteratee + ): LoDashExplicitSyncWrapper<_.Dictionary>; + pickBy( + this: LoDashExplicitSyncWrapper<_.NumericDictionary | null | undefined>, + predicate?: _.ValueKeyIteratee + ): LoDashExplicitSyncWrapper<_.NumericDictionary>; pickBy( this: LoDashExplicitSyncWrapper, predicate?: _.ValueKeyIteratee @@ -2841,6 +2857,14 @@ declare module "./index" { this: LoDashExplicitAsyncWrapper, ...paths: Array<_.Many<_.PropertyName>> ): LoDashExplicitAsyncWrapper<_.PartialObject>; + omitBy( + this: LoDashExplicitAsyncWrapper<_.Dictionary | null | undefined>, + predicate?: _.ValueKeyIteratee + ): LoDashExplicitAsyncWrapper<_.Dictionary>; + omitBy( + this: LoDashExplicitAsyncWrapper<_.NumericDictionary | null | undefined>, + predicate?: _.ValueKeyIteratee + ): LoDashExplicitAsyncWrapper<_.NumericDictionary>; omitBy( this: LoDashExplicitAsyncWrapper, predicate: _.ValueKeyIteratee @@ -2853,6 +2877,14 @@ declare module "./index" { this: LoDashExplicitAsyncWrapper, ...props: _.PropertyPath[] ): LoDashExplicitAsyncWrapper<_.PartialObject>; + pickBy( + this: LoDashExplicitAsyncWrapper<_.Dictionary | null | undefined>, + predicate?: _.ValueKeyIteratee + ): LoDashExplicitAsyncWrapper<_.Dictionary>; + pickBy( + this: LoDashExplicitAsyncWrapper<_.NumericDictionary | null | undefined>, + predicate?: _.ValueKeyIteratee + ): LoDashExplicitAsyncWrapper<_.NumericDictionary>; pickBy( this: LoDashExplicitAsyncWrapper, predicate?: _.ValueKeyIteratee diff --git a/types/materialize-css/common.d.ts b/types/materialize-css/common.d.ts index 605e9389be..a37afbbb34 100644 --- a/types/materialize-css/common.d.ts +++ b/types/materialize-css/common.d.ts @@ -43,7 +43,7 @@ declare namespace M { previousMonth: string; nextMonth: string; months: string[]; - monthsShort: string; + monthsShort: string[]; weekdays: string[]; weekdaysShort: string[]; weekdaysAbbrev: string[]; diff --git a/types/node-dijkstra/index.d.ts b/types/node-dijkstra/index.d.ts new file mode 100644 index 0000000000..20c97d7425 --- /dev/null +++ b/types/node-dijkstra/index.d.ts @@ -0,0 +1,148 @@ +// Type definitions for node-dijkstra 2.5 +// Project: https://github.com/albertorestifo/node-dijkstra +// Definitions by: Jorge López +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare class Graph { + /** + * Creates a new Graph, optionally initializing it a nodes graph representation. + * + * A graph representation is an object that has as keys the name of the point and as values + * the points reachable from that node, with the cost to get there: + * + * { + * node (Number|String): { + * neighbor (Number|String): cost (Number), + * ..., + * }, + * } + * + * In alternative to an object, you can pass a `Map` of `Map`. This will + * allow you to specify numbers as keys. + * + * @param [graph] - Initial graph definition + * @example + * + * const route = new Graph(); + * + * // Pre-populated graph + * const route = new Graph({ + * A: { B: 1 }, + * B: { A: 1, C: 2, D: 4 }, + * }); + * + * // Passing a Map + * const g = new Map() + * + * const a = new Map() + * a.set('B', 1) + * + * const b = new Map() + * b.set('A', 1) + * b.set('C', 2) + * b.set('D', 4) + * + * g.set('A', a) + * g.set('B', b) + * + * const route = new Graph(g) + */ + constructor(nodes?: any[]); + + /** + * Adds a node to the graph + * + * @param name - Name of the node + * @param neighbors - Neighboring nodes and cost to reach them + * @example + * + * const route = new Graph(); + * + * route.addNode('A', { B: 1 }); + * + * // It's possible to chain the calls + * route + * .addNode('B', { A: 1 }) + * .addNode('C', { A: 3 }); + * + * // The neighbors can be expressed in a Map + * const d = new Map() + * d.set('A', 2) + * d.set('B', 8) + * + * route.addNode('D', d) + */ + addNode(name: string, neighbors: any): Graph; + + /** + * Removes a node and all of its references from the graph + * + * @param key - Key of the node to remove from the graph + * @example + * + * const route = new Graph({ + * A: { B: 1, C: 5 }, + * B: { A: 3 }, + * C: { B: 2, A: 2 }, + * }); + * + * route.removeNode('C'); + * // The graph now is: + * // { A: { B: 1 }, B: { A: 3 } } + */ + removeNode(name: string): Graph; + + /** + * Compute the shortest path between the specified nodes + * + * @param start - Starting node + * @param goal - Node we want to reach + * @param [options] - Options + * + * @param [options.trim] - Exclude the origin and destination nodes from the result + * @param [options.reverse] - Return the path in reversed order + * @param [options.cost] - Also return the cost of the path when set to true + * + * @return Computed path between the nodes. + * + * When `option.cost` is set to true, the returned value will be an object with shape: + * - `path` *(Array)*: Computed path between the nodes + * - `cost` *(Number)*: Cost of the path + * + * @example + * + * const route = new Graph() + * + * route.addNode('A', { B: 1 }) + * route.addNode('B', { A: 1, C: 2, D: 4 }) + * route.addNode('C', { B: 2, D: 1 }) + * route.addNode('D', { C: 1, B: 4 }) + * + * route.path('A', 'D') // => ['A', 'B', 'C', 'D'] + * + * // trimmed + * route.path('A', 'D', { trim: true }) // => [B', 'C'] + * + * // reversed + * route.path('A', 'D', { reverse: true }) // => ['D', 'C', 'B', 'A'] + * + * // include the cost + * route.path('A', 'D', { cost: true }) + * // => { + * // path: [ 'A', 'B', 'C', 'D' ], + * // cost: 4 + * // } + */ + path(start: any, goal: any, options ?: PathOption): any; +} + +interface PathOption { + trim ?: boolean; + reverse ?: boolean; + cost ?: boolean; + avoid ?: any[]; +} + +export = Graph; diff --git a/types/node-dijkstra/node-dijkstra-tests.ts b/types/node-dijkstra/node-dijkstra-tests.ts new file mode 100644 index 0000000000..b6a8fbff9a --- /dev/null +++ b/types/node-dijkstra/node-dijkstra-tests.ts @@ -0,0 +1,12 @@ +import Graph = require('node-dijkstra'); + +const graph = new Graph(); +const graph2 = new Graph([{A: {B: 1}}]); + +graph + .addNode('A', {B: 1}) + .removeNode('C'); + +graph2.path('A', 'B'); +graph.path('A', 'B', {cost: false, reverse: true}); +graph.path('A', 'B', {cost: true}); diff --git a/types/node-dijkstra/tsconfig.json b/types/node-dijkstra/tsconfig.json new file mode 100644 index 0000000000..41f3b852bf --- /dev/null +++ b/types/node-dijkstra/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "esModuleInterop": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-dijkstra-tests.ts" + ] +} diff --git a/types/node-dijkstra/tslint.json b/types/node-dijkstra/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/node-dijkstra/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/promise-ftp-common/index.d.ts b/types/promise-ftp-common/index.d.ts new file mode 100644 index 0000000000..4db7fd4405 --- /dev/null +++ b/types/promise-ftp-common/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for promise-ftp-common 1.1 +// Project: https://github.com/realtymaps/promise-ftp-common +// Definitions by: coolreader18 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export enum STATUSES { + NOT_YET_CONNECTED = "not yet connected", + CONNECTING = "connecting", + CONNECTED = "connected", + LOGGING_OUT = "logging out", + DISCONNECTING = "disconnecting", + DISCONNECTED = "disconnected", + RECONNECTING = "reconnecting" +} +export class FtpConnectionError extends Error {} +export class FtpReconnectError extends Error { + constructor( + disconnectError?: string | Error, + connectError?: string | Error, + onCwd?: boolean + ); + connectError: string | Error; + disconnectError: string | Error; +} diff --git a/types/promise-ftp-common/promise-ftp-common-tests.ts b/types/promise-ftp-common/promise-ftp-common-tests.ts new file mode 100644 index 0000000000..57424a8449 --- /dev/null +++ b/types/promise-ftp-common/promise-ftp-common-tests.ts @@ -0,0 +1,16 @@ +import * as PromiseFtpCommon from "promise-ftp-common"; + +// $ExpectType typeof STATUSES +PromiseFtpCommon.STATUSES; + +// $ExpectType typeof FtpReconnectError +PromiseFtpCommon.FtpReconnectError; + +// $ExpectType typeof FtpConnectionError +PromiseFtpCommon.FtpConnectionError; + +// $ExpectType FtpReconnectError +new PromiseFtpCommon.FtpReconnectError(); + +// $ExpectType FtpConnectionError +new PromiseFtpCommon.FtpConnectionError(); diff --git a/types/promise-ftp-common/tsconfig.json b/types/promise-ftp-common/tsconfig.json new file mode 100644 index 0000000000..d8f09b36b9 --- /dev/null +++ b/types/promise-ftp-common/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "promise-ftp-common-tests.ts"] +} diff --git a/types/promise-ftp-common/tslint.json b/types/promise-ftp-common/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/promise-ftp-common/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/promise-ftp/index.d.ts b/types/promise-ftp/index.d.ts new file mode 100644 index 0000000000..9253b4d093 --- /dev/null +++ b/types/promise-ftp/index.d.ts @@ -0,0 +1,257 @@ +// Type definitions for promise-ftp 1.3 +// Project: https://github.com/realtymaps/promise-ftp +// Definitions by: coolreader18 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/// + +import * as FtpClient from "ftp"; +import * as PromiseFtpCommon from "promise-ftp-common"; +import * as Promise from "bluebird"; + +declare namespace PromiseFtp { + interface ERROR_CODES { + 421: "Service not available, closing control connection"; + 425: "Can't open data connection"; + 426: "Connection closed, transfer aborted"; + 450: "Requested file action not taken / File unavailable (e.g., file busy)"; + 451: "Requested action aborted: local error in processing"; + 452: "Requested action not taken / Insufficient storage space in system"; + 500: "Syntax error / Command unrecognized"; + 501: "Syntax error in parameters or arguments"; + 502: "Command not implemented"; + 503: "Bad sequence of commands"; + 504: "Command not implemented for that parameter"; + 530: "Not logged in"; + 532: "Need account for storing files"; + 550: "Requested action not taken / File unavailable (e.g., file not found, no access)"; + 551: "Requested action aborted: page type unknown"; + 552: "Requested file action aborted / Exceeded storage allocation (for current directory or dataset)"; + 553: "Requested action not taken / File name not allowed"; + } + const ERROR_CODES: ERROR_CODES; + // tslint:disable-next-line strict-export-declare-modifiers + export import FtpConnectionError = PromiseFtpCommon.FtpConnectionError; + // tslint:disable-next-line strict-export-declare-modifiers + export import FtpReconnectError = PromiseFtpCommon.FtpReconnectError; + // tslint:disable-next-line strict-export-declare-modifiers + export import STATUSES = PromiseFtpCommon.STATUSES; + + /** + * Options for FtpPromise#connect() + */ + // tslint:disable-next-line strict-export-declare-modifiers + export import Options = FtpClient.Options; + + /** + * Element returned by FtpPromise#list() + */ + // tslint:disable-next-line strict-export-declare-modifiers + export import ListingElement = FtpClient.ListingElement; +} + +declare class PromiseFtp { + /** + * The underlying FtpClient instance + */ + rawClient: FtpClient; + + getConnectionStatus(): PromiseFtpCommon.STATUSES; + /** + * Connect to an FTP server. + */ + connect: (options: PromiseFtp.Options) => Promise; + + /** + * Reconnect with the same options as previously connected with `#connect()`. + */ + reconnect: () => Promise; + + /** + * Close the connection to the server after any/all enqueued + * commands have been executed. + * @returns a promise that resolves with the last error recieved if there + * was an error, true if there was an error but the client didn't recieve it, + * or false if there was no error. + */ + end(): Promise; + + /** + * Close the connection to the server immediately. + */ + destroy(): boolean; + + /** + * Retrieve the directory listing of path. + * @param path - defaults to the current working directory. + * @param useCompression - defaults to false. + * @returns the contents of the specified directory + */ + list(path?: string, useCompression?: boolean): FtpClient.ListingElement[]; + list(useCompression: boolean): FtpClient.ListingElement[]; + + /** + * Optional "standard" commands (RFC 959) + * Retrieve the directory listing of path. + * Similar to `#list()`, except the directory is temporarily changed to path to + * retrieve the directory listing. This is useful for servers that do not + * handle characters like spaces and quotes in directory names well for the + * LIST command. This function is "optional" because it relies on `#pwd()` + * being available. + * @param path - defaults to the current working directory. + * @param useCompression - defaults to false. + * @returns the contents of the specified directory + */ + listSafe( + path?: string, + useCompression?: boolean + ): FtpClient.ListingElement[]; + listSafe(useCompression: boolean): FtpClient.ListingElement[]; + + /** + * Retrieve a file at path from the server. + * @param path - the path of the file to get. + * @param useCompression - defaults to false. + * @returns a stream which empties to the contents of the specified file. + */ + get(path: string, useCompression?: boolean): Promise; + + /** + * Send data to the server to be stored as a file. + * @param input - can be a ReadableStream, a Buffer, or a path to a local file. + * @param destPath - the path of the file to write to. + * @param useCompression - defaults to false. + */ + put( + input: NodeJS.ReadableStream | Buffer | string, + destPath: string, + useCompression?: boolean + ): Promise; + + /** + * Create a new file on the server or append to one that already exists. + * @param input - can be a ReadableStream, a Buffer, or a pathto a local file. + * @param destPath - the path of the file to create or append to. + * @param useCompression - defaults to false. + */ + append( + input: NodeJS.ReadableStream | Buffer | string, + destPath: string, + useCompression?: boolean + ): Promise; + + /** + * Rename a file on the server. + * @param oldPath - the old path of the file. + * @param newPath - the new path to move it to. + */ + rename: (oldPath: string, newPath: string) => Promise; + + /** + * Logout the user from the server. + */ + logout: () => Promise; + + /** + * Delete a file on the server. + */ + delete: (path: string) => Promise; + + /** + * Change the current working directory. + * @param cwd - the path to change the CWD to. + * @returns the current directory if the server replies with the path in the + * response text, otherwise undefined. + */ + cwd(path: string): Promise; + + /** + * Abort the current data transfer (e.g. from `#get()`, `#put()`, or `#list()`) + */ + abort(): Promise; + + /** + * Send command using SITE. + * @param command - the command to send, e.g 'CHMOD 755 foo' or 'QUOTA'. + */ + site(command: string): Promise<{ text: string; code: number }>; + + /** + * Retrieve human-readable information about the server's status. + * @returns a string with the server's status. + */ + status: () => Promise; + + /** + * Set the transfer data type to ASCII. + */ + ascii(): Promise; + + /** + * Set the transfer data type to binary (default at time of connection). + */ + binary(): Promise; + + /** + * Optional "standard" commands (RFC 959) + * Create a new directory on the server. + * @param path - the path of the new directory. + * @param recursive - enables a `mkdir -p` algorithm, defaults to false. + */ + mkdir(path: string, recursive?: boolean): Promise; + + /** + * Optional "standard" commands (RFC 959) + * Remove a directory on the server. + * @param path - the path of the directory to remove. + * @param recursive - enables deleting the directory if not empty, defaults to false. + */ + rmdir(path: string, recursive?: boolean): Promise; + + /** + * Optional "standard" commands (RFC 959) + * Change the working directory to the parent of the current directory. + * Like `cd ..`. + */ + cdup(): Promise; + + /** + * Optional "standard" commands (RFC 959) + * Retrieve the current working directory. + */ + pwd(): Promise; + + /** + * Optional "standard" commands (RFC 959) + * Retrieve information about the system running the server. + * @returns the server's OS. + */ + system(): Promise; + + /** + * Extended commands (RFC 3659) + * Retrieve the size of a file on the server. + * @param path - the path of the file whose size is to be retrieved. + * @returns the size of the specified file. + */ + size(path: string): Promise; + + /** + * Extended commands (RFC 3659) + * Retrieve the last modified date and time for a file or directory. + * @param path - the path of the file/directory whose modified date is to + * be retrieved. + * @returns the last modified date at the specified path. + */ + lastMod(path: string): Promise; + + /** + * Extended commands (RFC 3659) + * Set the file byte offset for the next file transfer action (get/put). + * @param byteOffset - The file byte offset. + */ + restart(byteOffset: number): Promise; +} + +export = PromiseFtp; diff --git a/types/promise-ftp/promise-ftp-tests.ts b/types/promise-ftp/promise-ftp-tests.ts new file mode 100644 index 0000000000..963d38a386 --- /dev/null +++ b/types/promise-ftp/promise-ftp-tests.ts @@ -0,0 +1,4 @@ +import PromiseFtp = require("promise-ftp"); + +// $ExpectType FtpConnectionError +new PromiseFtp.FtpConnectionError(); diff --git a/types/promise-ftp/tsconfig.json b/types/promise-ftp/tsconfig.json new file mode 100644 index 0000000000..cf284b61bc --- /dev/null +++ b/types/promise-ftp/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "promise-ftp-tests.ts"] +} diff --git a/types/promise-ftp/tslint.json b/types/promise-ftp/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/promise-ftp/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/promise-sftp/index.d.ts b/types/promise-sftp/index.d.ts new file mode 100644 index 0000000000..05d941856e --- /dev/null +++ b/types/promise-sftp/index.d.ts @@ -0,0 +1,605 @@ +// Type definitions for promise-sftp 1.3 +// Project: https://github.com/realtymaps/promise-sftp +// Definitions by: coolreader18 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/// + +import * as PromiseFtpCommon from "promise-ftp-common"; +import * as Promise from "bluebird"; +import * as ssh2 from "ssh2"; +import * as ssh2Streams from "ssh2-streams"; +import * as fs from "fs"; + +declare namespace PromiseSftp { + enum ERROR_CODES { + OK, + EOF, + NO_SUCH_FILE, + PERMISSION_DENIED, + FAILURE, + BAD_MESSAGE, + NO_CONNECTION, + CONNECTION_LOST, + OP_UNSUPPORTED, + INVALID_HANDLE, + NO_SUCH_PATH, + FILE_ALREADY_EXISTS, + WRITE_PROTECT, + NO_MEDIA, + NO_SPACE_ON_FILESYSTEM, + QUOTA_EXCEEDED, + UNKNOWN_PRINCIPAL, + LOCK_CONFLICT, + DIR_NOT_EMPTY, + NOT_A_DIRECTORY, + INVALID_FILENAME, + LINK_LOOP, + CANNOT_DELETE, + INVALID_PARAMETER, + FILE_IS_A_DIRECTORY, + BYTE_RANGE_LOCK_CONFLICT, + BYTE_RANGE_LOCK_REFUSED, + DELETE_PENDING, + FILE_CORRUPT, + OWNER_INVALID, + GROUP_INVALID, + NO_MATCHING_BYTE_RANGE_LOCK + } + // tslint:disable-next-line strict-export-declare-modifiers + export import FtpConnectionError = PromiseFtpCommon.FtpConnectionError; + // tslint:disable-next-line strict-export-declare-modifiers + export import FtpReconnectError = PromiseFtpCommon.FtpReconnectError; + // tslint:disable-next-line strict-export-declare-modifiers + export import STATUSES = PromiseFtpCommon.STATUSES; + + /** + * Options for SftpPromise#connect() + */ + type Options = ssh2.ConnectConfig & { + /** + * When using password-based user authentication, set this option to + * handle password change requests. If this option isn't set, and the + * server requests a password change, I haven't tested what will happen. + */ + changePassword?: (message: string, language: string) => Promise; + + /** + * Whether to attempt to automatically reconnect using the existing + * config if the connection is unexpectedly closed. Auto-reconnection is + * lazy, and so will wait until a command needs to be issued before + * attempting to reconnect. + */ + autoReconnect?: boolean; + + /** + * Path and name of a file containing a private key as would be passed + * to the privateKey option. If privateKey is also set, priority is + * given to the privateKey option. + */ + privateKeyFile?: string; + + /** + * Set this option to a function to try keyboard-interactive user + * authentication if primary user authentication method fails. + * + * NOTE: This function may be called more than once, with the same or different prompts. + * @param name - is generally what you'd use as a header or GUI window + * title to describe the purpose of the `prompts` + */ + tryKeyboard?: ( + name: string, + instructions: string, + instructionsLang: string, + prompts: Array<{ + /** The query to pose to the user */ + prompt: string; + /** Whether the user's input should be displayed on-screen */ + echo: boolean; + }> + ) => Array> | Promise; + + /** Alias for `username` */ + user?: string; + + /** Alias for `readyTimeout` */ + connTimeout?: number; + + /** Alias for `readyTimeout` */ + pasvTimeout?: number; + + /** Alias for `keepaliveInterval` */ + keepalive?: number; + }; + + /** Output of `PromiseSftp#list()` */ + interface DirectoryListing { + /** `d` for directory, `-` for file, and `l` for symlink only on *NIX. */ + type: "d" | "-" | "l"; + + /** The name of the entry. */ + name: string; + + /** The last modified date of the entry. */ + date: Date; + + /** The various permissions for this entry. *NIX only */ + rights?: { + user: string; + group: string; + other: string; + }; + + /** The user name or ID that this entry belongs to. *NIX only */ + owner?: string; + + /** The group name or ID that this entry belongs to. *NIX only */ + group?: string; + + /** For symlink entries, this is the symlink's target. *NIX only */ + target?: string; + + /** True if the sticky bit is set for this entry */ + sticky?: boolean; + } + + /** Options for `PromiseSftp#fast{Get,Put}` */ + interface FastOptions { + /** + * Number of concurrent reads + * @default 25 + */ + concurrency?: number; + + /** + * Size of each read in bytes + * @default 32768 + */ + chunkSize: number; + + /** Called every time a part of a file is transferred */ + step?: (totalTransferred: number, chunk: number, total: number) => void; + } + + /** From the [statvfs struct](http://linux.die.net/man/2/statvfs). */ + interface Statvfs { + /** file system block size */ + f_bsize: number; + /** fragment size */ + f_frsize: number; + /** size of fs in f_frsize units */ + f_blocks: number; + /** free blocks */ + f_bfree: number; + /** free blocks for unprivileged users */ + f_bavail: number; + /** inodes */ + f_files: number; + /** free inodes */ + f_ffree: number; + /** free inodes for unprivileged users */ + f_favail: number; + /** file system ID */ + f_fsid: number; + /** mount flags */ + f_flag: number; + /** maximum filename length */ + f_namemax: number; + } +} + +declare class PromiseSftp { + /** + * Connects to an SFTP server; returned promise resolves to the server's + * greeting message. If multiple authentication methods are available based + * on the passed config, they are attempted in the following order: Password + * > Private Key > Agent > keyboard-interactive (if tryKeyboard is set) > + * Host-based > None. NOTE: many of the config properties below are NOT + * relevant for promise-ftp. However, all promise-ftp connect options will + * work here, except for secure, secureOptions, and preserveCwd. + */ + connect(options: PromiseSftp.Options): null | ssh2.SFTPWrapper; + + /** + * Connects to an SFTP server using the config from the most recent call to + * #connect(). + * @returns promise that resolves to the server's greeting message. + */ + reconnect(): Promise; + + /** + * Closes the connection to the server after any/all enqueued commands have + * been executed. + * @returns a promise that resolves to whether or not there was an error + * associated with closing the connection. + */ + end(): Promise; + + /** Alias to `#end()` */ + logout(): Promise; + + /** + * Closes the connection to the server immediately. + * @returns whether the connection was connected prior to the call to **destroy()**. + */ + destroy(): boolean; + + /** + * @returns a string describing the current connection state. + */ + getConnectionStatus(): PromiseSftp.STATUSES; + + /** + * Retrieves a directory listing. + * @param path - The path of the directory to get the listing of. + */ + list(path?: string): Promise; + + /** Alias to `#list()` */ + listSafe(path: string): Promise; + + /** + * Retrieve a file from the server. + * @param path - The file to retrieve from the server. + */ + get(path: string): Promise; + + /** + * Sends data to the server. + * @param destPath - The file to store the data in. If string the path to a + * local file. + */ + put( + input: NodeJS.ReadableStream | Buffer | string, + destPath: string + ): Promise; + + /** + * Same as `#append()`, but appends to `destPath` if it already exists. + */ + append( + input: NodeJS.ReadableStream | Buffer | string, + destPath: string + ): Promise; + + /** + * Renames/moves one file/directory to another on the server. + * @param oldPath - The source file/directory. + * @param newPath - The destination file/directory. + */ + rename(oldPath: string, newPath: string): Promise; + + /** + * Create a new directory. + * @param path - The path to create a new directory at. + * @param recursive - Enables a `mkdir -p` algorithm, defaults to false. + * @param attributes - The attributes to use when creating directories. + */ + mkdir( + path: string, + recursive?: boolean, + attributes?: ssh2Streams.InputAttributes + ): Promise; + mkdir(path: string, attributes: ssh2Streams.InputAttributes): Promise; + + /** + * Remove a directory on the server. + * @param path - The path of the directory to remove. + */ + rmdir(path: string): Promise; + + /** + * Retrieve the size of a file on the server. + * @param path - The path to the file to retrieve the size of. + */ + size(path: string): Promise; + + /** + * Retrieve the last modified date of a file on the server. + * @param path - The path to the file to get the last modified date of. + */ + lastMod(path: string): Date; + + /** + * Sets the file byte offset for the next file transfer action initiated via + * #get() or #put() to `byteOffset`. + */ + restart(byteOffset: number): Promise; + + /** + * Download a file from the server using parallel reads for faster throughput. + * @param remotePath - The path to the remote file to read from. + * @param localPath - The path to the local file to write to. + */ + fastGet( + remotePath: string, + localPath: string, + options?: PromiseSftp.FastOptions + ): Promise; + + /** + * Upload a file to the server using parallel reads for faster throughput. + * @param localPath - The path to the local file to read from. + * @param remotePath - The path to the remote file to write to. + */ + fastPut( + localPath: string, + remotePath: string, + options?: PromiseSftp.FastOptions + ): Promise; + + /** + * Creates a read stream from a file on the server. + * @param path - The path of the file to create a read stream from. + * @returns a new `ReadableStream` for `path`. + */ + createReadStream( + path: string, + options?: + | string + | { + flags?: string; + encoding?: string; + fd?: number; + mode?: number; + autoClose?: boolean; + start?: number; + end?: number; + highWaterMark?: number; + } + ): Promise; + + /** + * Creates a write stream to a file on the server. + * @param path - The path of the file to create a write stream to. + * @returns a new `WriteableStream` for `path`. + */ + createWriteStream( + path: string, + options?: + | string + | { + flags?: string; + encoding?: string; + fd?: number; + mode?: number; + autoClose?: boolean; + start?: number; + end?: number; + highWaterMark?: number; + } + ): Promise; + + /** + * Opens a file on the server. + * @param filename - The path of the file to open. + * @param mode - Any of the modes supported by `fs.open()`. + * @returns a promise that resolves to a `Buffer` containing a handle to the file. + */ + open( + filename: string, + mode: string | number, + attributes?: ssh2Streams.InputAttributes + ): Promise; + + /** + * Close a resource on the server. + * @param handle - A file handle returned from `#open()` or `#opendir()`. + */ + close(handle: Buffer): Promise; + + /** + * Read binary data from a file on the server to a buffer. + * @param handle - A file handle returned from `#open()` or `#opendir()`. + * @param buffer - The buffer to write to. + * @param offset - The offset from the start of the buffer to begin writing to. + * @param length - The number of bytes to read from the resource. + * @param position - The position of the file to begin reading from. + */ + read( + handle: Buffer, + buffer: Buffer, + offset: number, + length: number, + position: number + ): Promise<{ + /** The number of bytes successfully read */ + bytesRead: number; + + /** The buffer passed to `#read()`, but offset-adjusted */ + buffer: Buffer; + + /** The position passed to `#read()` */ + position: number; + }>; + + /** + * Write binary data from a buffer to a file on the server. + * @param handle - A file handle returned from `#open()` or `#opendir()`. + * @param buffer - The buffer to read from. + * @param offset - The offset from the start of the buffer to begin reading from. + * @param length - The number of bytes to read from the buffer. + * @param position - The position of the file to begin writing to. + */ + read( + handle: Buffer, + buffer: Buffer, + offset: number, + length: number, + position: number + ): Promise; + + /** + * Retrieves attributes from a resource on the server. + * @param handle - A file handle returned from `#open()` or `#opendir()` + */ + fstat(handle: Buffer): Promise; + + /** + * Set the attributes for a resource on the server. + * @param handle - A resource handle returned from `#open()` or `#fopen()`. + */ + fsetstat(handle: Buffer, attributes: ssh2Streams.Attributes): Promise; + + /** + * Set the access and modified times for a resource on the server. + * @param handle - A resource handle returned from `#open()` or `#fopen()`. + * @param atime - A Date or unix timestamp representing the new access time for the resource + * @param mtime - A Date or unix timestamp representing the new modify time for the resource + */ + futimes( + handle: Buffer, + atime: Date | number, + mtime: Date | number + ): Promise; + + /** + * Set the ownership for a resource on the server. + * @param handle - A resource handle returned from `#open()` or `#fopen()`. + * @param uid - The id of the new owner user. + * @param gid - The id of the new owner group. + */ + fchown(handle: Buffer, uid: number, gid: number): Promise; + + /** + * Set the mode for a resource on the server. + * @param handle - A resource handle returned from `#open()` or `#fopen()`. + * @param mode - The new mode, a number or a string with an octal number. + */ + fchmod(handle: Buffer, mode: number | string): Promise; + + /** + * Open a directory on the server. + * @param path - The path of the directory to open. + * @returns a buffer with the handle of the opened directory. + */ + opendir(path: string): Promise; + + /** + * Read a directory on the server. + * @param location - The path of the directory to read or a handle returned from `#opendir()`. + */ + readdir( + location: Buffer | string + ): Promise<{ + filename: string; + longname: string; + attrs: ssh2Streams.Attributes; + }>; + + /** + * Remove a file or symlink on the server. + * @param path - The path of the file/symlink to remove. + */ + unlink(path: string): Promise; + + /** Alias for `#unlink()` */ + remove(path: string): Promise; + + /** + * Retrieve attributes for a resource on the server. + * @param path - The path to the resource to retrieve the attributes of. + */ + stat(path: string): Promise; + + /** + * Retrieve attributes for a resource on the server. If the resource is a + * symlink, it retrieves the stats for the link itself instead of the + * resource it refers to. + * @param path - The path to the resource to retrieve the attributes of. + */ + lstat(path: string): Promise; + + /** + * Set the attributes of a resource on the server. + * @param path - The path to the resource to set the attributes of. + * @param attributes - The new attributes for the resource. + */ + setstat(path: string, attributes: ssh2Streams.Attributes): Promise; + + /** + * Set the access and modified times for a resource on the server. + * @param path - The path of the resource to set times of. + * @param atime - A Date or unix timestamp representing the new access time for the resource + * @param mtime - A Date or unix timestamp representing the new modify time for the resource + */ + utimes( + path: string, + atime: Date | number, + mtime: Date | number + ): Promise; + + /** + * Set the ownership for a resource on the server. + * @param path - The path to the resource to change ownership of. + * @param uid - The id of the new owner user. + * @param gid - The id of the new owner group. + */ + chown(path: string, uid: number, gid: number): Promise; + + /** + * Set the mode for a resource on the server. + * @param path - The path of the resource to set the mode of. + * @param mode - The new mode, a number or a string with an octal number. + */ + chmod(path: string, mode: number | string): Promise; + + /** + * Read the target of a symlink on the server. + * @param path - The path of the symlink to read the target of. + */ + readlink(path: string): Promise; + + /** + * Create a symlink on the server. + * @param targetPath - The path to the target of the symlink. + * @param linkPath - The path of the new symlink. + */ + symlink(targetPath: string, linkPath: string): Promise; + + /** + * Get the absolute path from a relative path on the server. + * @param path - The path to get the absolute path of. + */ + realpath(path: string): Promise; + + /** + * **OpenSSH extension** + * Performs POSIX rename(3) on a resource on the server. + * @param srcPath - The original path of the resource. + * @param destPath - The new path to rename the resource to. + */ + ext_openssh_rename(srcPath: string, destPath: string): Promise; + + /** + * **OpenSSH extension** + * Perform POSIX fstatvfs(2) on a resource on the server. + * @param path - The path to get the statvfs of. + */ + ext_openssh_statvfs(path: string): Promise; + + /** + * **OpenSSH extension** + * Perform POSIX fstatvfs(2) on a resource on the server. + * @param handle - A resource handle returned from `#open()` or `#fopen()`. + */ + ext_openssh_fstatvfs(handle: Buffer): Promise; + + /** + * **OpenSSH extension** + * Performs POSIX link(2) to create a hard link on the server. + * @param targetPath - The path of a file to hardlink from. + * @param linkPath - The path of the newly created hardlink. + */ + ext_openssh_hardlink(targetPath: string, linkPath: string): Promise; + + /** + * **OpenSSH extension** + * Perform POSIX fsync(3) on a resource on the server. + * @param handle - A resource handle returned from `#open()` or `#fopen()`. + */ + ext_openssh_fsync(handle: Buffer): Promise; +} + +export = PromiseSftp; diff --git a/types/promise-sftp/promise-sftp-tests.ts b/types/promise-sftp/promise-sftp-tests.ts new file mode 100644 index 0000000000..90a46ab490 --- /dev/null +++ b/types/promise-sftp/promise-sftp-tests.ts @@ -0,0 +1,9 @@ +import PromiseSftp = require("promise-sftp"); + +const sftp = new PromiseSftp(); + +// $ExpectType () => boolean +sftp.destroy; + +// $ExpectType typeof STATUSES +PromiseSftp.STATUSES; diff --git a/types/promise-sftp/tsconfig.json b/types/promise-sftp/tsconfig.json new file mode 100644 index 0000000000..0cdbf4fb36 --- /dev/null +++ b/types/promise-sftp/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "promise-sftp-tests.ts"] +} diff --git a/types/promise-sftp/tslint.json b/types/promise-sftp/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/promise-sftp/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/randomcolor/index.d.ts b/types/randomcolor/index.d.ts index afa6bf4a69..8a95bf6d65 100644 --- a/types/randomcolor/index.d.ts +++ b/types/randomcolor/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for randomColor 0.4.1 +// Type definitions for randomColor 0.5.0 // Project: https://github.com/davidmerfield/randomColor // Definitions by: Mathias Feitzinger , Brady Liles // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -11,6 +11,7 @@ interface RandomColorOptions { count?: number; seed?: number | string; format?: "hsvArray" | "hslArray" | "hsl" | "hsla" | "rgbArray" | "rgb" | "rgba" | "hex"; + alpha?: number; } declare module "randomcolor" { diff --git a/types/react-icon-base/index.d.ts b/types/react-icon-base/index.d.ts index 7459349b82..2103acc3c3 100644 --- a/types/react-icon-base/index.d.ts +++ b/types/react-icon-base/index.d.ts @@ -8,6 +8,8 @@ import * as React from "react"; export interface IconBaseProps extends React.SVGProps { size?: string | number; + style?: any; + color?: string; } export default class IconBaseClass extends React.Component {} diff --git a/types/react-native-text-input-mask/index.d.ts b/types/react-native-text-input-mask/index.d.ts index e95e68d7f7..33505ccc54 100644 --- a/types/react-native-text-input-mask/index.d.ts +++ b/types/react-native-text-input-mask/index.d.ts @@ -9,12 +9,218 @@ import * as ReactNative from "react-native"; export type onChangeTextCallback = (formatted: string, extracted: string) => void; -export interface TextInputMaskProps { +export interface TextInputMaskProps extends ReactNative.ViewProps, ReactNative.TextInputIOSProps, ReactNative.TextInputAndroidProps, ReactNative.AccessibilityProps { maskDefaultValue?: boolean; mask: string; - value?: string; onChangeText: onChangeTextCallback; - keyboardType?: 'default' | 'numeric' | 'email-address' | 'phone-pad'; + + // Export standard TextInputProps from here on. + // Workaround for not being able to override onChangeText + // Copied from React-Native types version: 0.55 + + /** + * Specifies whether fonts should scale to respect Text Size accessibility settings. + * The default is `true`. + */ + allowFontScaling?: boolean; + + /** + * Can tell TextInput to automatically capitalize certain characters. + * characters: all characters, + * words: first letter of each word + * sentences: first letter of each sentence (default) + * none: don't auto capitalize anything + * + * https://facebook.github.io/react-native/docs/textinput.html#autocapitalize + */ + autoCapitalize?: "none" | "sentences" | "words" | "characters"; + + /** + * If false, disables auto-correct. + * The default value is true. + */ + autoCorrect?: boolean; + + /** + * If true, focuses the input on componentDidMount. + * The default value is false. + */ + autoFocus?: boolean; + + /** + * If true, the text field will blur when submitted. + * The default value is true. + */ + blurOnSubmit?: boolean; + + /** + * If true, caret is hidden. The default value is false. + */ + caretHidden?: boolean; + + /** + * Provides an initial value that will change when the user starts typing. + * Useful for simple use-cases where you don't want to deal with listening to events + * and updating the value prop to keep the controlled state in sync. + */ + defaultValue?: string; + + /** + * If false, text is not editable. The default value is true. + */ + editable?: boolean; + + /** + * enum("default", 'numeric', 'email-address', "ascii-capable", 'numbers-and-punctuation', 'url', 'number-pad', 'phone-pad', 'name-phone-pad', + * 'decimal-pad', 'twitter', 'web-search', 'visible-password') + * Determines which keyboard to open, e.g.numeric. + * The following values work across platforms: - default - numeric - email-address - phone-pad + * The following values work on iOS: - ascii-capable - numbers-and-punctuation - url - number-pad - name-phone-pad - decimal-pad - twitter - web-search + * The following values work on Android: - visible-password + */ + keyboardType?: ReactNative.KeyboardTypeOptions; + + /** + * Limits the maximum number of characters that can be entered. + * Use this instead of implementing the logic in JS to avoid flicker. + */ + maxLength?: number; + + /** + * If true, the text input can be multiple lines. The default value is false. + */ + multiline?: boolean; + + /** + * Callback that is called when the text input is blurred + */ + onBlur?: (e: ReactNative.NativeSyntheticEvent) => void; + + /** + * Callback that is called when the text input's text changes. + */ + onChange?: ( + event: { + nativeEvent: { + text: string; + contentSize: { width: number; height: number }; + target: number; + eventCount: number; + }; + } + ) => void; + + /** + * Callback that is called when the text input's content size changes. + * This will be called with + * `{ nativeEvent: { contentSize: { width, height } } }`. + * + * Only called for multiline text inputs. + */ + onContentSizeChange?: (event: { nativeEvent: { contentSize: { width: number; height: number } } }) => void; + + /** + * Callback that is called when text input ends. + */ + onEndEditing?: (event: { nativeEvent: { text: string } }) => void; + + /** + * Callback that is called when the text input is focused + */ + onFocus?: (e: ReactNative.NativeSyntheticEvent) => void; + + /** + * Callback that is called when the text input selection is changed. + */ + onSelectionChange?: (e: ReactNative.NativeSyntheticEvent) => void; + + /** + * Callback that is called when the text input's submit button is pressed. + */ + onSubmitEditing?: (event: { nativeEvent: { text: string } }) => void; + + /** + * Invoked on content scroll with + * `{ nativeEvent: { contentOffset: { x, y } } }`. + * + * May also contain other properties from ScrollEvent but on Android contentSize is not provided for performance reasons. + */ + onScroll?: (e: ReactNative.NativeSyntheticEvent) => void; + + /** + * Callback that is called when a key is pressed. + * This will be called with + * `{ nativeEvent: { key: keyValue } }` + * where keyValue is 'Enter' or 'Backspace' for respective keys and the typed-in character otherwise including ' ' for space. + * + * Fires before onChange callbacks. + * Note: on Android only the inputs from soft keyboard are handled, not the hardware keyboard inputs. + */ + onKeyPress?: (e: ReactNative.NativeSyntheticEvent) => void; + + /** + * The string that will be rendered before text input has been entered + */ + placeholder?: string; + + /** + * The text color of the placeholder string + */ + placeholderTextColor?: string; + + /** + * enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call') + * Determines how the return key should look. + */ + returnKeyType?: ReactNative.ReturnKeyTypeOptions; + + /** + * If true, the text input obscures the text entered so that sensitive text like passwords stay secure. + * The default value is false. + */ + secureTextEntry?: boolean; + + /** + * If true, all text will automatically be selected on focus + */ + selectTextOnFocus?: boolean; + + /** + * The start and end of the text input's selection. Set start and end to + * the same value to position the cursor. + */ + selection?: { start: number; end?: number }; + + /** + * The highlight (and cursor on ios) color of the text input + */ + selectionColor?: string; + + /** + * Styles + */ + style?: ReactNative.StyleProp; + + /** + * Used to locate this view in end-to-end tests + */ + testID?: string; + + /** + * Used to connect to an InputAccessoryView. Not part of react-natives documentation, but present in examples and + * code. + * See https://facebook.github.io/react-native/docs/inputaccessoryview.html for more information. + */ + inputAccessoryViewID?: string; + + /** + * The value to show for the text input. TextInput is a controlled component, + * which means the native value will be forced to match this value prop if provided. + * For most uses this works great, but in some cases this may cause flickering - one common cause is preventing edits by keeping value the same. + * In addition to simply setting the same value, either set editable={false}, + * or set/update maxLength to prevent unwanted edits without flicker. + */ + value?: string; } export default class TextInputMask extends React.Component { } diff --git a/types/react-native-toast-native/index.d.ts b/types/react-native-toast-native/index.d.ts new file mode 100644 index 0000000000..130614290b --- /dev/null +++ b/types/react-native-toast-native/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for react-native-toast-native 0.1 +// Project: https://github.com/onemolegames/react-native-toast-native/blob/master/README.md +// Definitions by: Michele Bombardi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import { Platform } from 'react-native'; + +export interface Style { + width?: number; + height?: number; + backgroundColor?: string; + color?: string; + borderWidth?: number; + borderRadius?: number; + + // iOS-only + borderColor?: string; + + // Android-only + paddingLeft?: number; + paddingRight?: number; + paddingBottom?: number; + paddingTop?: number; + fontSize?: number; + lines?: number; + lineHeight?: number; + xOffset?: number; + yOffset?: number; + letterSpacing?: number; + fontWeight?: string; +} + +interface ToastNative { + // Toast duration constants + SHORT: any; + LONG: any; + + // Toast gravity constants + TOP: any; + BOTTOM: any; + CENTER: any; + + show(message?: string): void; + show(message: string, duration: any, position: any, styles: Style): void; +} + +declare const ToastNative: ToastNative; +export default ToastNative; diff --git a/types/react-native-toast-native/react-native-toast-native-tests.tsx b/types/react-native-toast-native/react-native-toast-native-tests.tsx new file mode 100644 index 0000000000..af9ed9db7b --- /dev/null +++ b/types/react-native-toast-native/react-native-toast-native-tests.tsx @@ -0,0 +1,28 @@ +import * as React from 'react'; +import { View, Button } from 'react-native'; +import Toast, { Style } from 'react-native-toast-native'; + +class Test extends React.Component { + showToast() { + const style: Style = { + color: 'white', + backgroundColor: '#5CB85C', + fontSize: 16, + height: 140, + borderRadius: 15, + fontWeight: 'bold', + yOffset: 40 + }; + + Toast.show("I'm a toast!", Toast.SHORT, Toast.BOTTOM, style); + } + + render() { + return ( + +