overlookmotel/yauzl-promise

TypeScript: zipFile missing from type declaration?

Closed this issue · 3 comments

Console.logging out an Entry object reveals that the Entry object has a reference to the ZipFile type that it belongs to, however this is missing from the type declaration?

For example:

import yauzl from 'yauzl-promise';

const zipFile = await yauzl.open(filePath);
const entry = await zipFile.readEntries(1);
console.log(entry)

The above will provide an object that has, in addition to the types defined in the base yauzl's Entry class, an extra "zipFile" property.
Because the extra property is not defined TypeScript won't let you access it.

I made the following change to the index.d.ts in yauzl-promise to expose this property:

export class Entry extends BaseEntry {
    openReadStream(options?: ZipFileOptions): Promise<Readable>;
    zipFile?: ZipFile // <---- Added this line
}

Please let me know if this was intentional and I am missing something.

Alternatively:

import { Entry as BaseEntry, ZipFile } from 'yauzl-promise';

class Entry extends BaseEntry {
  zipFile?: ZipFile;
}

This package does not provide types. So I don't know where those types have come from, but the issue should be reported there, rather than on this repo.

Sorry it's taken over a year to come back on this!

Oh yeah... I'm not sure how I didn't realise this. I wonder where I got the types from then, oh well, thanks anyway 👍