From 28ed9e7537333481c41d2d500ddda3a0e200efd2 Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Sat, 10 Jan 2026 19:25:26 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74230=20[node]:=20?= =?UTF-8?q?Fix=20the=20return=20type=20of=20fs.mkdtempDisposableSync=20bei?= =?UTF-8?q?ng=20an=20asyncDisposable=20by=20@thgreasi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/node/fs.d.ts | 6 +++--- types/node/fs/promises.d.ts | 15 ++++++++++++++- types/node/node-tests/fs.ts | 6 +++--- types/node/v24/fs.d.ts | 6 +++--- types/node/v24/fs/promises.d.ts | 15 ++++++++++++++- types/node/v24/test/fs.ts | 6 +++--- 6 files changed, 40 insertions(+), 14 deletions(-) diff --git a/types/node/fs.d.ts b/types/node/fs.d.ts index 6eb69846b449ff..63af06dce1270e 100644 --- a/types/node/fs.d.ts +++ b/types/node/fs.d.ts @@ -2152,7 +2152,7 @@ declare module "node:fs" { * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. */ function mkdtempSync(prefix: string, options?: EncodingOption): string | NonSharedBuffer; - interface DisposableTempDir extends AsyncDisposable { + interface DisposableTempDir extends Disposable { /** * The path of the created directory. */ @@ -2160,11 +2160,11 @@ declare module "node:fs" { /** * A function which removes the created directory. */ - remove(): Promise; + remove(): void; /** * The same as `remove`. */ - [Symbol.asyncDispose](): Promise; + [Symbol.dispose](): void; } /** * Returns a disposable object whose `path` property holds the created directory diff --git a/types/node/fs/promises.d.ts b/types/node/fs/promises.d.ts index ded1b243c0b162..e4d249d9924193 100644 --- a/types/node/fs/promises.d.ts +++ b/types/node/fs/promises.d.ts @@ -20,7 +20,6 @@ declare module "node:fs/promises" { CopyOptions, Dir, Dirent, - DisposableTempDir, EncodingOption, GlobOptions, GlobOptionsWithFileTypes, @@ -980,6 +979,20 @@ declare module "node:fs/promises" { prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null, ): Promise; + interface DisposableTempDir extends AsyncDisposable { + /** + * The path of the created directory. + */ + path: string; + /** + * A function which removes the created directory. + */ + remove(): Promise; + /** + * The same as `remove`. + */ + [Symbol.asyncDispose](): Promise; + } /** * The resulting Promise holds an async-disposable object whose `path` property * holds the created directory path. When the object is disposed, the directory diff --git a/types/node/node-tests/fs.ts b/types/node/node-tests/fs.ts index 1ed38a397b978c..c91a9d238738bf 100644 --- a/types/node/node-tests/fs.ts +++ b/types/node/node-tests/fs.ts @@ -238,10 +238,10 @@ async function testPromisify() { const disposable = fs.mkdtempDisposableSync("/tmp/foo-"); // $ExpectType string disposable.path; - // $ExpectType Promise + // $ExpectType void disposable.remove(); - // $ExpectType Promise - disposable[Symbol.asyncDispose](); + // $ExpectType void + disposable[Symbol.dispose](); fs.promises.mkdtempDisposable("/tmp/foo-").then((result) => { // $ExpectType string diff --git a/types/node/v24/fs.d.ts b/types/node/v24/fs.d.ts index b300ca45ae0190..24f37dcfd79bc7 100644 --- a/types/node/v24/fs.d.ts +++ b/types/node/v24/fs.d.ts @@ -2193,7 +2193,7 @@ declare module "fs" { * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. */ export function mkdtempSync(prefix: string, options?: EncodingOption): string | NonSharedBuffer; - export interface DisposableTempDir extends AsyncDisposable { + export interface DisposableTempDir extends Disposable { /** * The path of the created directory. */ @@ -2201,11 +2201,11 @@ declare module "fs" { /** * A function which removes the created directory. */ - remove(): Promise; + remove(): void; /** * The same as `remove`. */ - [Symbol.asyncDispose](): Promise; + [Symbol.dispose](): void; } /** * Returns a disposable object whose `path` property holds the created directory diff --git a/types/node/v24/fs/promises.d.ts b/types/node/v24/fs/promises.d.ts index 986b6da5c6d6aa..6612bff37b2425 100644 --- a/types/node/v24/fs/promises.d.ts +++ b/types/node/v24/fs/promises.d.ts @@ -21,7 +21,6 @@ declare module "fs/promises" { CopyOptions, Dir, Dirent, - DisposableTempDir, EncodingOption, GlobOptions, GlobOptionsWithFileTypes, @@ -981,6 +980,20 @@ declare module "fs/promises" { prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null, ): Promise; + interface DisposableTempDir extends AsyncDisposable { + /** + * The path of the created directory. + */ + path: string; + /** + * A function which removes the created directory. + */ + remove(): Promise; + /** + * The same as `remove`. + */ + [Symbol.asyncDispose](): Promise; + } /** * The resulting Promise holds an async-disposable object whose `path` property * holds the created directory path. When the object is disposed, the directory diff --git a/types/node/v24/test/fs.ts b/types/node/v24/test/fs.ts index 1c41788e61ca2f..653d234aee5b4f 100644 --- a/types/node/v24/test/fs.ts +++ b/types/node/v24/test/fs.ts @@ -238,10 +238,10 @@ async function testPromisify() { const disposable = fs.mkdtempDisposableSync("/tmp/foo-"); // $ExpectType string disposable.path; - // $ExpectType Promise + // $ExpectType void disposable.remove(); - // $ExpectType Promise - disposable[Symbol.asyncDispose](); + // $ExpectType void + disposable[Symbol.dispose](); fs.promises.mkdtempDisposable("/tmp/foo-").then((result) => { // $ExpectType string