From 669da2ca54100d794eb511816e03dc5ac2084e1d Mon Sep 17 00:00:00 2001 From: Dominique Date: Fri, 16 Mar 2018 17:26:58 +0100 Subject: [PATCH] got-typings: use proper options for got download --- types/decompress/index.d.ts | 56 +++++++++++++++++++------------------ types/download/index.d.ts | 48 +++++++++++++------------------ 2 files changed, 48 insertions(+), 56 deletions(-) diff --git a/types/decompress/index.d.ts b/types/decompress/index.d.ts index c2211b3434..a493f81a0d 100644 --- a/types/decompress/index.d.ts +++ b/types/decompress/index.d.ts @@ -7,33 +7,35 @@ export = decompress; -declare function decompress(input: string | Buffer, output: string, opts?: Options): Promise; +declare function decompress(input: string | Buffer, output: string, opts?: decompress.DecompressOptions): Promise; -interface File { - data: Buffer; - mode: number; - mtime: string; - path: string; - type: string; -} +declare namespace decompress { + interface File { + data: Buffer; + mode: number; + mtime: string; + path: string; + type: string; + } -interface Options { - /** - * Filter out files before extracting - */ - filter?(file: File): boolean; - /** - * Map files before extracting - */ - map?(file: File): File; - /** - * Array of plugins to use. - * Default: [decompressTar(), decompressTarbz2(), decompressTargz(), decompressUnzip()] - */ - plugins?: any[]; - /** - * Remove leading directory components from extracted files. - * Default: 0 - */ - strip?: number; + interface DecompressOptions { + /** + * Filter out files before extracting + */ + filter?(file: File): boolean; + /** + * Map files before extracting + */ + map?(file: File): File; + /** + * Array of plugins to use. + * Default: [decompressTar(), decompressTarbz2(), decompressTargz(), decompressUnzip()] + */ + plugins?: any[]; + /** + * Remove leading directory components from extracted files. + * Default: 0 + */ + strip?: number; + } } diff --git a/types/download/index.d.ts b/types/download/index.d.ts index cffc282832..56eb6cc16d 100644 --- a/types/download/index.d.ts +++ b/types/download/index.d.ts @@ -5,38 +5,28 @@ // TypeScript Version: 2.2 /// +import { DecompressOptions } from 'decompress'; +import { GotBodyOptions, TimeoutOptions } from 'got'; -interface TimeoutOptions { - connect?: number; - socket?: number; - request?: number; -} -type RetryFunction = (retry: number, error: any) => number; +declare namespace download { + type RetryFunction = (retry: number, error: any) => number; -interface DownloadOptions { - body?: string | Buffer | NodeJS.ReadableStream; - encoding?: string | null; - query?: string | object; - timeout?: number | TimeoutOptions; - retries?: number | RetryFunction; - followRedirect?: boolean; - decompress?: boolean; - useElectronNet?: boolean; - /** - * If set to true, try extracting the file using decompress. - */ - extract?: boolean; - /** - * Name of the saved file. - */ - filename?: string; - /** - * Proxy endpoint - */ - proxy?: string; + interface DownloadOptions extends DecompressOptions, GotBodyOptions { + /** + * If set to true, try extracting the file using decompress. + */ + extract?: boolean; + /** + * Name of the saved file. + */ + filename?: string; + /** + * Proxy endpoint + */ + proxy?: string; + } } -declare namespace download {} -declare function download(url: string, destination?: string, options?: DownloadOptions): Promise & NodeJS.WritableStream & NodeJS.ReadableStream; +declare function download(url: string, destination?: string, options?: download.DownloadOptions): Promise & NodeJS.WritableStream & NodeJS.ReadableStream; export = download;