Error when using zip.js 2.8 with TypeScript: Property getData
does not exist on type DirectoryEntry
#602
-
Our project uses Typescript and Angular. After updating to 2.8, new error occurs:
The snippet is:
It works fine with 2.7 I believe it is a bug, since the project follows semantic versioning. If not, could you please release the change withing next major version instead? A changelog would be also very useful. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
In your example, you have to test if private unzipZipBlob = async (zippedBlob: Blob) => {
const stream = new TransformStream();
const response = new Response(stream.readable).blob();
const zipReader = new ZipReader(zippedBlob.stream());
const firstEntry = (await zipReader.getEntries()).shift();
if (!firstEntry || firstEntry.directory) { // <== here
throw new Error(...);
}
await firstEntry.getData(stream);
await zipReader.close();
const unzippedBlob = await response;
return unzippedBlob;
}; |
Beta Was this translation helpful? Give feedback.
In your example, you have to test if
firstEntry.directory
istrue
orfalse
instead of testing iffirstEntry.getData
is truthy. I'm not strictly following semantic versioning ("minor" updates can introduce small breaking changes) and I confirm that the version 2.8.x introduces subtle breaking changes (zip.js is coded in JS). You can find the changelog here: https://github.com/gildas-lormeau/zip.js/releases/tag/v2.8.2