Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions types/node/fs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2152,19 +2152,19 @@ 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.
*/
path: string;
/**
* A function which removes the created directory.
*/
remove(): Promise<void>;
remove(): void;
/**
* The same as `remove`.
*/
[Symbol.asyncDispose](): Promise<void>;
[Symbol.dispose](): void;
}
/**
* Returns a disposable object whose `path` property holds the created directory
Expand Down
15 changes: 14 additions & 1 deletion types/node/fs/promises.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ declare module "node:fs/promises" {
CopyOptions,
Dir,
Dirent,
DisposableTempDir,
EncodingOption,
GlobOptions,
GlobOptionsWithFileTypes,
Expand Down Expand Up @@ -980,6 +979,20 @@ declare module "node:fs/promises" {
prefix: string,
options?: ObjectEncodingOptions | BufferEncoding | null,
): Promise<string | NonSharedBuffer>;
interface DisposableTempDir extends AsyncDisposable {
/**
* The path of the created directory.
*/
path: string;
/**
* A function which removes the created directory.
*/
remove(): Promise<void>;
/**
* The same as `remove`.
*/
[Symbol.asyncDispose](): Promise<void>;
}
/**
* The resulting Promise holds an async-disposable object whose `path` property
* holds the created directory path. When the object is disposed, the directory
Expand Down
6 changes: 3 additions & 3 deletions types/node/node-tests/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ async function testPromisify() {
const disposable = fs.mkdtempDisposableSync("/tmp/foo-");
// $ExpectType string
disposable.path;
// $ExpectType Promise<void>
// $ExpectType void
disposable.remove();
// $ExpectType Promise<void>
disposable[Symbol.asyncDispose]();
// $ExpectType void
disposable[Symbol.dispose]();

fs.promises.mkdtempDisposable("/tmp/foo-").then((result) => {
// $ExpectType string
Expand Down
6 changes: 3 additions & 3 deletions types/node/v24/fs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2193,19 +2193,19 @@ 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.
*/
path: string;
/**
* A function which removes the created directory.
*/
remove(): Promise<void>;
remove(): void;
/**
* The same as `remove`.
*/
[Symbol.asyncDispose](): Promise<void>;
[Symbol.dispose](): void;
}
/**
* Returns a disposable object whose `path` property holds the created directory
Expand Down
15 changes: 14 additions & 1 deletion types/node/v24/fs/promises.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ declare module "fs/promises" {
CopyOptions,
Dir,
Dirent,
DisposableTempDir,
EncodingOption,
GlobOptions,
GlobOptionsWithFileTypes,
Expand Down Expand Up @@ -981,6 +980,20 @@ declare module "fs/promises" {
prefix: string,
options?: ObjectEncodingOptions | BufferEncoding | null,
): Promise<string | NonSharedBuffer>;
interface DisposableTempDir extends AsyncDisposable {
/**
* The path of the created directory.
*/
path: string;
/**
* A function which removes the created directory.
*/
remove(): Promise<void>;
/**
* The same as `remove`.
*/
[Symbol.asyncDispose](): Promise<void>;
}
/**
* The resulting Promise holds an async-disposable object whose `path` property
* holds the created directory path. When the object is disposed, the directory
Expand Down
6 changes: 3 additions & 3 deletions types/node/v24/test/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ async function testPromisify() {
const disposable = fs.mkdtempDisposableSync("/tmp/foo-");
// $ExpectType string
disposable.path;
// $ExpectType Promise<void>
// $ExpectType void
disposable.remove();
// $ExpectType Promise<void>
disposable[Symbol.asyncDispose]();
// $ExpectType void
disposable[Symbol.dispose]();

fs.promises.mkdtempDisposable("/tmp/foo-").then((result) => {
// $ExpectType string
Expand Down