[Typescript]: How to decompress .tar.gz file and get files in memory

I'm developing an Angular project without BE service.

I'd like to know how to decompress .tar.gz file and process it in memory(not it in the disk).

ex: read and parse specific files.

I followed this solution to decompress it:

How do I extract data from a .tar.gz file (stored in the cloud) from a browser)

  • Here is my code
import * as pako from "pako";
import * as untar from "untar";

onFileSelected(e: Event) {
    const target = as HTMLInputElement;
    if (target.files) {
      //decompress file
      const f = target.files[0];
       .then((arr) => arr.buffer)
       .then(untar)   //<--  Error: untar pkg has no @types/untar                
       .then(files => {                

The solution guides me to use Pako and untar packages to decompress the loaded file stream.

But untar pkg doesn't have @types/untar to provide the pkg module for Typescript.

The post's reply also suggests using tarball pkg, but it still has no @types/tarball

So I can not continue decompressing work.

Does anyone have any ideas to decompress .tar.gz?

many thanks :)


  • Use any Type: If the package doesn't have TypeScript types, you can use any to bypass type checking. For example, const untar: any = require('untar');.