greggman / unzipit

Random access unzip library for JavaScript

Home Page:https://greggman.github.io/unzipit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typescript type error when using HTTPRangeReader

t123yh opened this issue · comments

commented
const reader = new HTTPRangeReader(textFieldRef.current.value);
const { entries } = await unzip(reader);

Got error: Argument of type 'HTTPRangeReader' is not assignable to parameter of type 'string | ArrayBuffer | TypedArray | Blob | Reader'.

It seems that in https://github.com/greggman/unzipit/blob/master/dist/unzipit.d.ts , HTTPRangeReader is not classified as a Reader.

Can you test just patch your local unzipit.d.ts by adding implements Reader to HTTPRangeReader?

If that's all that's needed I'll add it

In particular I want to know if I need to add more than that. Thanks!

export class HTTPRangeReader implements Reader {
	constructor(url: string);
}
commented

Only adding implements does not seem to work. I think we have to add members from Reader interface:

export class HTTPRangeReader implements Reader {
  constructor(url: string);
  getLength(): Promise<number>;
  read(offset: number, size: number): Promise<Uint8Array>;
}

The above is tested to be working.

Thanks!

6181c0c