-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[node] bigint options for fstat and lstat #50120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -536,70 +536,85 @@ declare module "fs" { | |
* Asynchronous stat(2) - Get file status. | ||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. | ||
*/ | ||
export function stat(path: PathLike, options: BigIntOptions, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void; | ||
export function stat(path: PathLike, options: StatOptions, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void; | ||
export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; | ||
export function stat(path: PathLike, options: StatOptions & { bigint?: false } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; | ||
export function stat(path: PathLike, options: StatOptions & { bigint: true }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the advantage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It actually looks easier to see why this matters with the options inline. |
||
export function stat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the I think omitting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its possible you could have a weakly defined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, the |
||
|
||
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. | ||
export namespace stat { | ||
/** | ||
* Asynchronous stat(2) - Get file status. | ||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. | ||
*/ | ||
function __promisify__(path: PathLike, options: BigIntOptions): Promise<BigIntStats>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should |
||
function __promisify__(path: PathLike, options: StatOptions): Promise<Stats | BigIntStats>; | ||
function __promisify__(path: PathLike): Promise<Stats>; | ||
function __promisify__(path: PathLike, options?: StatOptions & { bigint?: false }): Promise<Stats>; | ||
function __promisify__(path: PathLike, options: StatOptions & { bigint: true }): Promise<BigIntStats>; | ||
function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>; | ||
} | ||
|
||
/** | ||
* Synchronous stat(2) - Get file status. | ||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. | ||
*/ | ||
export function statSync(path: PathLike, options: BigIntOptions): BigIntStats; | ||
export function statSync(path: PathLike, options: StatOptions): Stats | BigIntStats; | ||
export function statSync(path: PathLike): Stats; | ||
export function statSync(path: PathLike, options?: StatOptions & { bigint?: false }): Stats; | ||
export function statSync(path: PathLike, options: StatOptions & { bigint: true }): BigIntStats; | ||
export function statSync(path: PathLike, options?: StatOptions): Stats | BigIntStats; | ||
|
||
/** | ||
* Asynchronous fstat(2) - Get file status. | ||
* @param fd A file descriptor. | ||
*/ | ||
export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; | ||
export function fstat(fd: number, options: StatOptions & { bigint?: false } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; | ||
export function fstat(fd: number, options: StatOptions & { bigint: true }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void; | ||
export function fstat(fd: number, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void; | ||
|
||
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. | ||
export namespace fstat { | ||
/** | ||
* Asynchronous fstat(2) - Get file status. | ||
* @param fd A file descriptor. | ||
*/ | ||
function __promisify__(fd: number): Promise<Stats>; | ||
function __promisify__(fd: number, options?: StatOptions & { bigint?: false }): Promise<Stats>; | ||
function __promisify__(fd: number, options: StatOptions & { bigint: true }): Promise<BigIntStats>; | ||
function __promisify__(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>; | ||
} | ||
|
||
/** | ||
* Synchronous fstat(2) - Get file status. | ||
* @param fd A file descriptor. | ||
*/ | ||
export function fstatSync(fd: number): Stats; | ||
export function fstatSync(fd: number, options?: StatOptions & { bigint?: false }): Stats; | ||
export function fstatSync(fd: number, options: StatOptions & { bigint: true }): BigIntStats; | ||
export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats; | ||
|
||
/** | ||
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links. | ||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. | ||
*/ | ||
export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; | ||
export function lstat(path: PathLike, options: StatOptions & { bigint?: false } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; | ||
export function lstat(path: PathLike, options: StatOptions & { bigint: true }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void; | ||
export function lstat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void; | ||
|
||
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. | ||
export namespace lstat { | ||
/** | ||
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links. | ||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. | ||
*/ | ||
function __promisify__(path: PathLike): Promise<Stats>; | ||
function __promisify__(path: PathLike, options?: StatOptions & { bigint?: false }): Promise<Stats>; | ||
function __promisify__(path: PathLike, options: StatOptions & { bigint: true }): Promise<BigIntStats>; | ||
function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>; | ||
} | ||
|
||
/** | ||
* Synchronous lstat(2) - Get file status. Does not dereference symbolic links. | ||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. | ||
*/ | ||
export function lstatSync(path: PathLike): Stats; | ||
export function lstatSync(path: PathLike, options?: StatOptions & { bigint?: false }): Stats; | ||
export function lstatSync(path: PathLike, options: StatOptions & { bigint: true }): BigIntStats; | ||
export function lstatSync(path: PathLike, options?: StatOptions): Stats | BigIntStats; | ||
|
||
/** | ||
* Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file. | ||
|
@@ -2234,6 +2249,6 @@ declare module "fs" { | |
} | ||
|
||
export interface StatOptions { | ||
bigint: boolean; | ||
bigint?: boolean; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is quite some copy paste of this compound type.
What about adding something like this instead:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually looks easier to see why this matters with the options inline. Are you recommending it be
StatOptions & NoBigIntOptions
? Or are you recommending aNoBigIntOptions
interface that inherits fromStatOptions
? If the latter, The naming ofBigIntOptions
/NoBigIntOptions
seems very ambiguous to me. Personally, I'd rather see either:StatOptions & { bigint: true }
(as is written), orBigIntStatOptions
/NoBigIntStatOptions
(indicating the specific variations ofStatOptions
Personally I think (1) is easier to read and reason over.