diff --git a/.gitignore b/.gitignore index b186605..dd80c18 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*.swp dist node_modules .DS_Store +.vscode diff --git a/src/utils/unzip.ts b/src/utils/unzip.ts index 507d095..9b81ffe 100644 --- a/src/utils/unzip.ts +++ b/src/utils/unzip.ts @@ -1,11 +1,11 @@ import { Readable } from 'stream'; import { promisify } from 'util'; -import { Entry, Options, ZipFile } from 'yauzl'; +import { Entry, Options, ZipFile, ZipFileOptions } from 'yauzl'; -// Override so promisify typing correctly infers params -export type YauzlOpenReadStream = (entry: Entry, callback?: (err: Error, stream: Readable) => void) => Promise; -type YauzlOpen = (path: string, options: Options, callback?: (err: Error, zipfile: ZipFile) => void) => void; -type UnzipOnEntry = (entry: Entry, zipfile: ZipFile, openReadStream: YauzlOpenReadStream) => void; +// Specify which of possible overloads is being promisified +type YauzlOpenReadStream = (entry: Entry, options?: ZipFileOptions, callback?: (err: Error, stream: Readable) => void) => void; +type YauzlOpen = (path: string, options?: Options, callback?: (err: Error, zipfile: ZipFile) => void) => void; +type UnzipOnEntry = (entry: Entry, zipfile: ZipFile, openReadStream: (arg1: Entry, arg2?: ZipFileOptions) => Promise) => void; export async function unzip(srcPath: string, onEntry: UnzipOnEntry) { const yauzl = await import('yauzl');