Skip to content

'Create new archive' example raises type error #81

@marcoms

Description

@marcoms
const archiveFile = await Archive.write({
	files: [
		{
			// Error: Property 'file' is missing in type 'File' but required in type 'ArchiveEntryFile'. (TS2741)
			file: new File(['test'], 'test.tar.gz'),

			pathname: 'folder/file.zip',
		},
	],
	outputFileName: 'test.tar.gz',
	compression: ArchiveCompression.GZIP,
	format: ArchiveFormat.USTAR,
	passphrase: null,
});

This is identical to the README.md example except for passing a file instance directly. I currently have the following local patch to prevent the error:

# patches/libarchive.js+2.0.2.patch

diff --git a/node_modules/libarchive.js/dist/build/compiled/libarchive.d.ts b/node_modules/libarchive.js/dist/build/compiled/libarchive.d.ts
index 19ec630..637b9a9 100644
--- a/node_modules/libarchive.js/dist/build/compiled/libarchive.d.ts
+++ b/node_modules/libarchive.js/dist/build/compiled/libarchive.d.ts
@@ -7,7 +7,7 @@ export type ArchiveOptions = {
     createClient?: (worker: any) => any;
 };
 export type ArchiveEntryFile = {
-    file: ArchiveEntryFile;
+    file: File | Blob;
     pathname?: string;
 };
 export type ArchiveWriteOptions = {

Does the above change look correct? If so I can make a PR for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions