From 384abb417bc77feb850399b41ab8831d45992b50 Mon Sep 17 00:00:00 2001 From: kasuparu Date: Fri, 6 Oct 2017 20:23:30 +0200 Subject: [PATCH] [async] [i2c-bus] Improve async.auto() typing, fix i2c-bus typos (#20131) --- types/async/index.d.ts | 8 +++++++- types/i2c-bus/index.d.ts | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/types/async/index.d.ts b/types/async/index.d.ts index f443ebf627..80f2888a8b 100644 --- a/types/async/index.d.ts +++ b/types/async/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/caolan/async // Definitions by: Boris Yankov , Arseniy Maximov , Joe Herman , Angus Fenying , Pascal Martin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 export as namespace async; @@ -23,6 +24,11 @@ export interface AsyncBooleanIterator { (item: T, callback: AsyncBooleanRe export interface AsyncWorker { (task: T, callback: ErrorCallback): void; } export interface AsyncVoidFunction { (callback: ErrorCallback): void; } +export type AsyncAutoTasks, E> = { [K in keyof R]: AsyncAutoTask } +export type AsyncAutoTask, E> = AsyncAutoTaskFunctionWithoutDependencies | (keyof R | AsyncAutoTaskFunction)[]; +export interface AsyncAutoTaskFunctionWithoutDependencies { (cb: AsyncResultCallback | ErrorCallback): void; } +export interface AsyncAutoTaskFunction, E> { (results: R, cb: AsyncResultCallback | ErrorCallback): void; } + export interface AsyncQueue { length(): number; started: boolean; @@ -183,7 +189,7 @@ export function queue(worker: AsyncWorker, concurrency?: number): As export function queue(worker: AsyncResultIterator, concurrency?: number): AsyncQueue; export function priorityQueue(worker: AsyncWorker, concurrency: number): AsyncPriorityQueue; export function cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; -export function auto(tasks: any, concurrency?: number, callback?: AsyncResultCallback): void; +export function auto, E>(tasks: AsyncAutoTasks, concurrency?: number, callback?: AsyncResultCallback): void; export function autoInject(tasks: any, callback?: AsyncResultCallback): void; export function retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; export function retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; diff --git a/types/i2c-bus/index.d.ts b/types/i2c-bus/index.d.ts index e03432b75d..ebb06e83ae 100644 --- a/types/i2c-bus/index.d.ts +++ b/types/i2c-bus/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/fivdi/i2c-bus // Definitions by: Jason Heard // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// @@ -318,6 +319,8 @@ export interface I2cBus { * * @param {number} address * I2C device address. + * @param {number} command + * The command code. * @param {number} bit * The data bit to write (0 or 1). * @param {CompletionCallback} callback @@ -330,6 +333,8 @@ export interface I2cBus { * * @param {number} address * I2C device address. + * @param {number} command + * The command code. * @param {number} bit * The data bit to write (0 or 1). */ @@ -383,7 +388,7 @@ export interface I2cBus { * @return {I2cBus} * A new I2cBus object. */ -export function open(busNumber: number, calback: CompletionCallback): I2cBus; +export function open(busNumber: number, callback: CompletionCallback): I2cBus; /** * Synchronous open.