Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.0.1][Type Regression] Property 'write' in type 'Pack' is not assignable to the same property in base type 'Minipass<Buffer, ContiguousData>'. #413

Closed
maka-io opened this issue Apr 17, 2024 · 3 comments

Comments

@maka-io
Copy link

maka-io commented Apr 17, 2024

With 7.0.1:

node_modules/tar/dist/commonjs/pack.d.ts:70:5 - error TS2416: Property 'end' in type 'Pack' is not assignable to the same property in base type 'Minipass<Buffer, ContiguousData>'.
  Type '(path?: string | ReadEntry | undefined) => this' is not assignable to type '{ (cb?: (() => void) | undefined): this; (chunk: any, cb?: (() => void) | undefined): this; (chunk: any, encoding?: Encoding | undefined, cb?: (() => void) | undefined): this; }'.
    Types of parameters 'path' and 'cb' are incompatible.
      Type '(() => void) | undefined' is not assignable to type 'string | ReadEntry | undefined'.
        Type '() => void' is not assignable to type 'string | ReadEntry | undefined'.

70     end(path?: string | ReadEntry): this;
       ~~~

This works with version 6.2.1:

public async extractTarGz(tarFilePath: string, destDirectory: string): Promise<void> {
    function getFileSize(filePath: string) {
      const stats = fs.statSync(filePath);
      return stats.size;
    }

    // extract graphic
    const graphic = (process.platform === 'win32') ? '>' : '\u{1F4E6}';
    const totalSize = getFileSize(tarFilePath);
    const progressBar = new Progress(totalSize, "Extracting", graphic);

    return new Promise((resolve, reject) => {
      const extractor = tar.extract({ cwd: destDirectory });

      fs.createReadStream(tarFilePath)
        .pipe(zlib.createGunzip())  // decompressing gzip file before passing it to tar
        .pipe(extractor as ReturnType<typeof tar.extract> & NodeJS.WritableStream)
        .on('data', (chunk) => {
          progressBar.update(chunk.length);
        })
        .on('end', () => {
          progressBar.complete();
          resolve();
        })
        .on('error', (err) => {
          reject(err);
        });
    });
  }
@pamelalozano16
Copy link

I think the problem might be because the minipass version is outdated.
Current version: "minipass": "^5.0.0"
Latest version: "minipass": "^7.0.4"

@isaacs
Copy link
Owner

isaacs commented Apr 23, 2024

Yeah, if you don't give the lib the deps in the range it expects, it's not gonna work.

Builds fine on my machine, please provide a reproducible test case and steps to view the error.

@isaacs isaacs closed this as completed Apr 23, 2024
@pamelalozano16
Copy link

pamelalozano16 commented Apr 30, 2024

Here's a minimal repo that reproduces the error: https://gist.github.com/nex3/b7b308d5b5c8d46173454beb1be844f0.
To run: npm install, npx tsc.

Regarding the outdated dependency, I noticed that node-tar depends on minipass@5.0.0. I see you're behind both projects, is there a particular reason for sticking with this version? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants