From 3ff20100b78ba0ce09b8d133dc3f2604f451ca60 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Wed, 6 Feb 2019 13:43:12 -0800 Subject: [PATCH 1/2] fix(unzip): fix Yauzl typings Both `open` and `openReadStream` have overloads, so `promisify` can't know which one to choose and chooses the last one (which doesn't include options). Additionally, once we specify those two overloads, optional args become `arg | undefined` which is subtly different than not providing an arg (which is what we want to be able to do), so we specify onEntry's `openReadStream` callback explicitly as well (to have options be optional). I think this last point is also why we can't just update `yauzl`'s types to have both `options` and `callback` be optional, because `options` when `promisified` will be unioned with `undefined`, not optional (meaning you can't just leave it off, you'd have to actually pass `undefined` as the value if you want to use it). https://github.com/Microsoft/TypeScript/issues/13570 https://github.com/Microsoft/TypeScript/issues/13195 --- .vscode/settings.json | 3 +++ src/android/utils/.apk.ts.swp | Bin 0 -> 12288 bytes src/utils/unzip.ts | 10 +++++----- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 src/android/utils/.apk.ts.swp diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3662b37 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} \ No newline at end of file diff --git a/src/android/utils/.apk.ts.swp b/src/android/utils/.apk.ts.swp new file mode 100644 index 0000000000000000000000000000000000000000..0431a0595b2ca721be8177ef2d2f585e81f83a7a GIT binary patch literal 12288 zcmeI2PmAP47{+S_5!6+24_@C@u+z{}+11N3(#kB%VGg@2ihp1jq&lfg7oAjvN@Zr+ zan?_uCqWSfMLhTc1kWB6?|M-16NneVlNX<=PP%7$-QDrHSb?Y0mAv)jeSh^P&~zqO z-q^W8*Z5V2?J35-dgSljKfis3eRRT@Qnka#F!Z`O(x2FMBj#C`lhk7R2i)@ zCq-~T^9$=FZOXV9n6+t4e}Wr(2P zo?z^2sDZ9Qe_dqkJLnte6X-+e1L%F|HdH|hnnK&q!_cpfGxiJgCG-XKIaETM&>xR6 z_A#^t{f^vz>~j3x=NY$1AQFfKB7sOC5{LvMf&V*!6GmjEYpteZ5_P?kk4R*AwN$zJ zO;JfYc?l7j(TzKMe7qcT;ha^I*2#t!O6N%;Hc9CDkj5{Q;M%*4$734!Z-XH}5M?Xx zbR{^}b*VDE*lIM-rmDRMzovHvfHBPU<;p->J>Ao8unE4(*^R)uU_f|q!22{%Pe@~Acz{F}MXsAx6T$7tG@ zZmXW{=)&}&o77+>^!|{J89TMIS{~AMrG=fpRh74dZKO@A?lRZgqL6mTYkxSw#g@x` zHUgsMJ7l!QSj7D2(T4<>p?)rBf0vJv^Vc6RP- z^FAje%SM8bANb}M`D+fJ6*oE=NSzNxl!T0Xi>x#rO*j9JDY 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'); From fb321cf6102d2249c1bbaeeafa93c96c6117d203 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Thu, 7 Feb 2019 08:16:13 -0800 Subject: [PATCH 2/2] chore(): update .gitignore --- .gitignore | 2 ++ .vscode/settings.json | 3 --- src/android/utils/.apk.ts.swp | Bin 12288 -> 0 bytes 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 .vscode/settings.json delete mode 100644 src/android/utils/.apk.ts.swp 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/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 3662b37..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "typescript.tsdk": "node_modules/typescript/lib" -} \ No newline at end of file diff --git a/src/android/utils/.apk.ts.swp b/src/android/utils/.apk.ts.swp deleted file mode 100644 index 0431a0595b2ca721be8177ef2d2f585e81f83a7a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2PmAP47{+S_5!6+24_@C@u+z{}+11N3(#kB%VGg@2ihp1jq&lfg7oAjvN@Zr+ zan?_uCqWSfMLhTc1kWB6?|M-16NneVlNX<=PP%7$-QDrHSb?Y0mAv)jeSh^P&~zqO z-q^W8*Z5V2?J35-dgSljKfis3eRRT@Qnka#F!Z`O(x2FMBj#C`lhk7R2i)@ zCq-~T^9$=FZOXV9n6+t4e}Wr(2P zo?z^2sDZ9Qe_dqkJLnte6X-+e1L%F|HdH|hnnK&q!_cpfGxiJgCG-XKIaETM&>xR6 z_A#^t{f^vz>~j3x=NY$1AQFfKB7sOC5{LvMf&V*!6GmjEYpteZ5_P?kk4R*AwN$zJ zO;JfYc?l7j(TzKMe7qcT;ha^I*2#t!O6N%;Hc9CDkj5{Q;M%*4$734!Z-XH}5M?Xx zbR{^}b*VDE*lIM-rmDRMzovHvfHBPU<;p->J>Ao8unE4(*^R)uU_f|q!22{%Pe@~Acz{F}MXsAx6T$7tG@ zZmXW{=)&}&o77+>^!|{J89TMIS{~AMrG=fpRh74dZKO@A?lRZgqL6mTYkxSw#g@x` zHUgsMJ7l!QSj7D2(T4<>p?)rBf0vJv^Vc6RP- z^FAje%SM8bANb}M`D+fJ6*oE=NSzNxl!T0Xi>x#rO*j9JDY