From 4878ac3f21d8eedbe98eab7e6fa39e0a151b9d90 Mon Sep 17 00:00:00 2001 From: Matthew Turner Date: Thu, 9 Jan 2020 08:09:27 +1100 Subject: [PATCH] Use types from tar-stream as return types of tar-fs (#41282) * Use types from tar-stream as return types of tar-fs * Re-export tar-stream types --- types/tar-fs/index.d.ts | 10 ++++++---- types/tar-fs/tar-fs-tests.ts | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/types/tar-fs/index.d.ts b/types/tar-fs/index.d.ts index 9d6d6c20a4..09a645840b 100644 --- a/types/tar-fs/index.d.ts +++ b/types/tar-fs/index.d.ts @@ -9,11 +9,13 @@ /// import fs = require('fs'); -import stream = require('stream'); +import tarStream = require('tar-stream'); -// Replace these return values with the value of tar-stream when it becomes available -export function pack(cwd: string, opts?: PackOptions): stream.Readable; -export function extract(cwd: string, opts?: ExtractOptions): stream.Writable; +export function pack(cwd: string, opts?: PackOptions): tarStream.Pack; +export function extract(cwd: string, opts?: ExtractOptions): tarStream.Extract; + +export type Pack = tarStream.Pack; +export type Extract = tarStream.Extract; export interface Options { ignore?: (name: string) => boolean; diff --git a/types/tar-fs/tar-fs-tests.ts b/types/tar-fs/tar-fs-tests.ts index a419f907cb..6acbdd4c75 100644 --- a/types/tar-fs/tar-fs-tests.ts +++ b/types/tar-fs/tar-fs-tests.ts @@ -1,7 +1,6 @@ import tar = require("tar-fs"); import fs = require("fs"); import path = require("path"); -import stream = require("stream"); /* * Default test @@ -96,3 +95,9 @@ tar.pack('./my-directory', { strict: false, dereference: true, }); + +/* + * Return type of tar-stream + */ +tar.pack('./my-directory').entry({ name: 'generated-file.txt' }, '1234'); +tar.pack('./my-directory').finalize();