Browse Source

revert util.d.ts to original (different spacing & capitalization)

kb/add-usage-guide
Trent Larson 12 months ago
parent
commit
0fabccd410
  1. 293
      src/util.d.ts

293
src/util.d.ts

@ -105,10 +105,7 @@ declare module "util" {
| "date" | "date"
| "regexp" | "regexp"
| "module"; | "module";
export type CustomInspectFunction = ( export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => any; // TODO: , inspect: inspect
depth: number,
options: InspectOptionsStylized,
) => unknown; // TODO: , inspect: inspect
export interface InspectOptionsStylized extends InspectOptions { export interface InspectOptionsStylized extends InspectOptions {
stylize(text: string, styleType: Style): string; stylize(text: string, styleType: Style): string;
} }
@ -169,11 +166,7 @@ declare module "util" {
* ``` * ```
* @since v10.0.0 * @since v10.0.0
*/ */
export function formatWithOptions( export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
inspectOptions: InspectOptions,
format?: any,
...param: any[]
): string;
/** /**
* Returns the string name for a numeric error code that comes from a Node.js API. * Returns the string name for a numeric error code that comes from a Node.js API.
* The mapping between error codes and error names is platform-dependent. * The mapping between error codes and error names is platform-dependent.
@ -444,12 +437,7 @@ declare module "util" {
* @param object Any JavaScript primitive or `Object`. * @param object Any JavaScript primitive or `Object`.
* @return The representation of `object`. * @return The representation of `object`.
*/ */
export function inspect( export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
object: any,
showHidden?: boolean,
depth?: number | null,
color?: boolean,
): string;
export function inspect(object: any, options?: InspectOptions): string; export function inspect(object: any, options?: InspectOptions): string;
export namespace inspect { export namespace inspect {
let colors: NodeJS.Dict<[number, number]>; let colors: NodeJS.Dict<[number, number]>;
@ -607,10 +595,7 @@ declare module "util" {
* @since v0.3.0 * @since v0.3.0
* @legacy Use ES2015 class syntax and `extends` keyword instead. * @legacy Use ES2015 class syntax and `extends` keyword instead.
*/ */
export function inherits( export function inherits(constructor: unknown, superConstructor: unknown): void;
constructor: unknown,
superConstructor: unknown,
): void;
export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void; export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void;
export interface DebugLogger extends DebugLoggerFunction { export interface DebugLogger extends DebugLoggerFunction {
enabled: boolean; enabled: boolean;
@ -672,10 +657,7 @@ declare module "util" {
* @param callback A callback invoked the first time the logging function is called with a function argument that is a more optimized logging function. * @param callback A callback invoked the first time the logging function is called with a function argument that is a more optimized logging function.
* @return The logging function * @return The logging function
*/ */
export function debuglog( export function debuglog(section: string, callback?: (fn: DebugLoggerFunction) => void): DebugLogger;
section: string,
callback?: (fn: DebugLoggerFunction) => void,
): DebugLogger;
export const debug: typeof debuglog; export const debug: typeof debuglog;
/** /**
* Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`. * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
@ -765,9 +747,7 @@ declare module "util" {
* @since v0.11.5 * @since v0.11.5
* @deprecated Since v4.0.0 - Use `value === undefined || value === null` instead. * @deprecated Since v4.0.0 - Use `value === undefined || value === null` instead.
*/ */
export function isNullOrUndefined( export function isNullOrUndefined(object: unknown): object is null | undefined;
object: unknown,
): object is null | undefined;
/** /**
* Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`. * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
* *
@ -938,11 +918,7 @@ declare module "util" {
* @param code A deprecation code. See the `list of deprecated APIs` for a list of codes. * @param code A deprecation code. See the `list of deprecated APIs` for a list of codes.
* @return The deprecated function wrapped to emit a warning. * @return The deprecated function wrapped to emit a warning.
*/ */
export function deprecate<T extends Function>( export function deprecate<T extends Function>(fn: T, msg: string, code?: string): T;
fn: T,
msg: string,
code?: string,
): T;
/** /**
* Returns `true` if there is deep strict equality between `val1` and `val2`. * Returns `true` if there is deep strict equality between `val1` and `val2`.
* Otherwise, returns `false`. * Otherwise, returns `false`.
@ -1011,9 +987,7 @@ declare module "util" {
* @param fn An `async` function * @param fn An `async` function
* @return a callback style function * @return a callback style function
*/ */
export function callbackify( export function callbackify(fn: () => Promise<void>): (callback: (err: NodeJS.ErrnoException) => void) => void;
fn: () => Promise<void>,
): (callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<TResult>( export function callbackify<TResult>(
fn: () => Promise<TResult>, fn: () => Promise<TResult>,
): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void; ): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
@ -1022,49 +996,22 @@ declare module "util" {
): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void; ): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, TResult>( export function callbackify<T1, TResult>(
fn: (arg1: T1) => Promise<TResult>, fn: (arg1: T1) => Promise<TResult>,
): ( ): (arg1: T1, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
arg1: T1,
callback: (err: NodeJS.ErrnoException, result: TResult) => void,
) => void;
export function callbackify<T1, T2>( export function callbackify<T1, T2>(
fn: (arg1: T1, arg2: T2) => Promise<void>, fn: (arg1: T1, arg2: T2) => Promise<void>,
): ( ): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void;
arg1: T1,
arg2: T2,
callback: (err: NodeJS.ErrnoException) => void,
) => void;
export function callbackify<T1, T2, TResult>( export function callbackify<T1, T2, TResult>(
fn: (arg1: T1, arg2: T2) => Promise<TResult>, fn: (arg1: T1, arg2: T2) => Promise<TResult>,
): ( ): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
arg1: T1,
arg2: T2,
callback: (err: NodeJS.ErrnoException | null, result: TResult) => void,
) => void;
export function callbackify<T1, T2, T3>( export function callbackify<T1, T2, T3>(
fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<void>, fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<void>,
): ( ): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void;
arg1: T1,
arg2: T2,
arg3: T3,
callback: (err: NodeJS.ErrnoException) => void,
) => void;
export function callbackify<T1, T2, T3, TResult>( export function callbackify<T1, T2, T3, TResult>(
fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>, fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>,
): ( ): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
arg1: T1,
arg2: T2,
arg3: T3,
callback: (err: NodeJS.ErrnoException | null, result: TResult) => void,
) => void;
export function callbackify<T1, T2, T3, T4>( export function callbackify<T1, T2, T3, T4>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>, fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>,
): ( ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
callback: (err: NodeJS.ErrnoException) => void,
) => void;
export function callbackify<T1, T2, T3, T4, TResult>( export function callbackify<T1, T2, T3, T4, TResult>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>, fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>,
): ( ): (
@ -1076,14 +1023,7 @@ declare module "util" {
) => void; ) => void;
export function callbackify<T1, T2, T3, T4, T5>( export function callbackify<T1, T2, T3, T4, T5>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>, fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>,
): ( ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
callback: (err: NodeJS.ErrnoException) => void,
) => void;
export function callbackify<T1, T2, T3, T4, T5, TResult>( export function callbackify<T1, T2, T3, T4, T5, TResult>(
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>, fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>,
): ( ): (
@ -1095,14 +1035,7 @@ declare module "util" {
callback: (err: NodeJS.ErrnoException | null, result: TResult) => void, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void,
) => void; ) => void;
export function callbackify<T1, T2, T3, T4, T5, T6>( export function callbackify<T1, T2, T3, T4, T5, T6>(
fn: ( fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>,
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
) => Promise<void>,
): ( ): (
arg1: T1, arg1: T1,
arg2: T2, arg2: T2,
@ -1113,14 +1046,7 @@ declare module "util" {
callback: (err: NodeJS.ErrnoException) => void, callback: (err: NodeJS.ErrnoException) => void,
) => void; ) => void;
export function callbackify<T1, T2, T3, T4, T5, T6, TResult>( export function callbackify<T1, T2, T3, T4, T5, T6, TResult>(
fn: ( fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>,
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
) => Promise<TResult>,
): ( ): (
arg1: T1, arg1: T1,
arg2: T2, arg2: T2,
@ -1130,12 +1056,10 @@ declare module "util" {
arg6: T6, arg6: T6,
callback: (err: NodeJS.ErrnoException | null, result: TResult) => void, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void,
) => void; ) => void;
export interface CustomPromisifyLegacy<TCustom extends Function> export interface CustomPromisifyLegacy<TCustom extends Function> extends Function {
extends Function {
__promisify__: TCustom; __promisify__: TCustom;
} }
export interface CustomPromisifySymbol<TCustom extends Function> export interface CustomPromisifySymbol<TCustom extends Function> extends Function {
extends Function {
[promisify.custom]: TCustom; [promisify.custom]: TCustom;
} }
export type CustomPromisify<TCustom extends Function> = export type CustomPromisify<TCustom extends Function> =
@ -1210,79 +1134,38 @@ declare module "util" {
* ``` * ```
* @since v8.0.0 * @since v8.0.0
*/ */
export function promisify<TCustom extends Function>( export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
fn: CustomPromisify<TCustom>,
): TCustom;
export function promisify<TResult>( export function promisify<TResult>(
fn: (callback: (err: any, result: TResult) => void) => void, fn: (callback: (err: any, result: TResult) => void) => void,
): () => Promise<TResult>; ): () => Promise<TResult>;
export function promisify( export function promisify(fn: (callback: (err?: any) => void) => void): () => Promise<void>;
fn: (callback: (err?: any) => void) => void,
): () => Promise<void>;
export function promisify<T1, TResult>( export function promisify<T1, TResult>(
fn: (arg1: T1, callback: (err: any, result: TResult) => void) => void, fn: (arg1: T1, callback: (err: any, result: TResult) => void) => void,
): (arg1: T1) => Promise<TResult>; ): (arg1: T1) => Promise<TResult>;
export function promisify<T1>( export function promisify<T1>(fn: (arg1: T1, callback: (err?: any) => void) => void): (arg1: T1) => Promise<void>;
fn: (arg1: T1, callback: (err?: any) => void) => void,
): (arg1: T1) => Promise<void>;
export function promisify<T1, T2, TResult>( export function promisify<T1, T2, TResult>(
fn: ( fn: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => void) => void,
arg1: T1,
arg2: T2,
callback: (err: any, result: TResult) => void,
) => void,
): (arg1: T1, arg2: T2) => Promise<TResult>; ): (arg1: T1, arg2: T2) => Promise<TResult>;
export function promisify<T1, T2>( export function promisify<T1, T2>(
fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void, fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void,
): (arg1: T1, arg2: T2) => Promise<void>; ): (arg1: T1, arg2: T2) => Promise<void>;
export function promisify<T1, T2, T3, TResult>( export function promisify<T1, T2, T3, TResult>(
fn: ( fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => void) => void,
arg1: T1,
arg2: T2,
arg3: T3,
callback: (err: any, result: TResult) => void,
) => void,
): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>; ): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
export function promisify<T1, T2, T3>( export function promisify<T1, T2, T3>(
fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err?: any) => void) => void, fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err?: any) => void) => void,
): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>; ): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
export function promisify<T1, T2, T3, T4, TResult>( export function promisify<T1, T2, T3, T4, TResult>(
fn: ( fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void,
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
callback: (err: any, result: TResult) => void,
) => void,
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>; ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
export function promisify<T1, T2, T3, T4>( export function promisify<T1, T2, T3, T4>(
fn: ( fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err?: any) => void) => void,
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
callback: (err?: any) => void,
) => void,
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>; ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
export function promisify<T1, T2, T3, T4, T5, TResult>( export function promisify<T1, T2, T3, T4, T5, TResult>(
fn: ( fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void,
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
callback: (err: any, result: TResult) => void,
) => void,
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>; ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
export function promisify<T1, T2, T3, T4, T5>( export function promisify<T1, T2, T3, T4, T5>(
fn: ( fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void,
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
callback: (err?: any) => void,
) => void,
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>; ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
export function promisify(fn: Function): Function; export function promisify(fn: Function): Function;
export namespace promisify { export namespace promisify {
@ -1389,10 +1272,7 @@ declare module "util" {
*/ */
encodeInto(src: string, dest: Uint8Array): EncodeIntoResult; encodeInto(src: string, dest: Uint8Array): EncodeIntoResult;
} }
import { import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from "util";
TextDecoder as _TextDecoder,
TextEncoder as _TextEncoder,
} from "util";
global { global {
/** /**
* `TextDecoder` class is a global reference for `require('util').TextDecoder` * `TextDecoder` class is a global reference for `require('util').TextDecoder`
@ -1402,8 +1282,7 @@ declare module "util" {
var TextDecoder: typeof globalThis extends { var TextDecoder: typeof globalThis extends {
onmessage: any; onmessage: any;
TextDecoder: infer TextDecoder; TextDecoder: infer TextDecoder;
} } ? TextDecoder
? TextDecoder
: typeof _TextDecoder; : typeof _TextDecoder;
/** /**
* `TextEncoder` class is a global reference for `require('util').TextEncoder` * `TextEncoder` class is a global reference for `require('util').TextEncoder`
@ -1413,8 +1292,7 @@ declare module "util" {
var TextEncoder: typeof globalThis extends { var TextEncoder: typeof globalThis extends {
onmessage: any; onmessage: any;
TextEncoder: infer TextEncoder; TextEncoder: infer TextEncoder;
} } ? TextEncoder
? TextEncoder
: typeof _TextEncoder; : typeof _TextEncoder;
} }
@ -1447,9 +1325,7 @@ declare module "util" {
* @param config Used to provide arguments for parsing and to configure the parser. `config` supports the following properties: * @param config Used to provide arguments for parsing and to configure the parser. `config` supports the following properties:
* @return The parsed command line arguments: * @return The parsed command line arguments:
*/ */
export function parseArgs<T extends ParseArgsConfig>( export function parseArgs<T extends ParseArgsConfig>(config?: T): ParsedResults<T>;
config?: T,
): ParsedResults<T>;
interface ParseArgsOptionConfig { interface ParseArgsOptionConfig {
/** /**
* Type of argument. * Type of argument.
@ -1512,39 +1388,24 @@ declare module "util" {
This is technically incorrect but is a much nicer UX for the common case. This is technically incorrect but is a much nicer UX for the common case.
The IfDefaultsTrue version is for things which default to true; the IfDefaultsFalse version is for things which default to false. The IfDefaultsTrue version is for things which default to true; the IfDefaultsFalse version is for things which default to false.
*/ */
type IfDefaultsTrue<T, IfTrue, IfFalse> = T extends true type IfDefaultsTrue<T, IfTrue, IfFalse> = T extends true ? IfTrue
? IfTrue : T extends false ? IfFalse
: T extends false
? IfFalse
: IfTrue; : IfTrue;
// we put the `extends false` condition first here because `undefined` compares like `any` when `strictNullChecks: false` // we put the `extends false` condition first here because `undefined` compares like `any` when `strictNullChecks: false`
type IfDefaultsFalse<T, IfTrue, IfFalse> = T extends false type IfDefaultsFalse<T, IfTrue, IfFalse> = T extends false ? IfFalse
? IfFalse : T extends true ? IfTrue
: T extends true
? IfTrue
: IfFalse; : IfFalse;
type ExtractOptionValue< type ExtractOptionValue<T extends ParseArgsConfig, O extends ParseArgsOptionConfig> = IfDefaultsTrue<
T extends ParseArgsConfig,
O extends ParseArgsOptionConfig,
> = IfDefaultsTrue<
T["strict"], T["strict"],
O["type"] extends "string" O["type"] extends "string" ? string : O["type"] extends "boolean" ? boolean : string | boolean,
? string
: O["type"] extends "boolean"
? boolean
: string | boolean,
string | boolean string | boolean
>; >;
type ParsedValues<T extends ParseArgsConfig> = IfDefaultsTrue< type ParsedValues<T extends ParseArgsConfig> =
T["strict"], & IfDefaultsTrue<T["strict"], unknown, { [longOption: string]: undefined | string | boolean }>
unknown, & (T["options"] extends ParseArgsOptionsConfig ? {
{ [longOption: string]: undefined | string | boolean }
> &
(T["options"] extends ParseArgsOptionsConfig
? {
-readonly [LongOption in keyof T["options"]]: IfDefaultsFalse< -readonly [LongOption in keyof T["options"]]: IfDefaultsFalse<
T["options"][LongOption]["multiple"], T["options"][LongOption]["multiple"],
undefined | Array<ExtractOptionValue<T, T["options"][LongOption]>>, undefined | Array<ExtractOptionValue<T, T["options"][LongOption]>>,
@ -1562,8 +1423,7 @@ declare module "util" {
type PreciseTokenForOptions< type PreciseTokenForOptions<
K extends string, K extends string,
O extends ParseArgsOptionConfig, O extends ParseArgsOptionConfig,
> = O["type"] extends "string" > = O["type"] extends "string" ? {
? {
kind: "option"; kind: "option";
index: number; index: number;
name: K; name: K;
@ -1571,8 +1431,7 @@ declare module "util" {
value: string; value: string;
inlineValue: boolean; inlineValue: boolean;
} }
: O["type"] extends "boolean" : O["type"] extends "boolean" ? {
? {
kind: "option"; kind: "option";
index: number; index: number;
name: K; name: K;
@ -1586,35 +1445,20 @@ declare module "util" {
T extends ParseArgsConfig, T extends ParseArgsConfig,
K extends keyof T["options"] = keyof T["options"], K extends keyof T["options"] = keyof T["options"],
> = K extends unknown > = K extends unknown
? T["options"] extends ParseArgsOptionsConfig ? T["options"] extends ParseArgsOptionsConfig ? PreciseTokenForOptions<K & string, T["options"][K]>
? PreciseTokenForOptions<K & string, T["options"][K]>
: OptionToken : OptionToken
: never; : never;
type ParsedOptionToken<T extends ParseArgsConfig> = IfDefaultsTrue< type ParsedOptionToken<T extends ParseArgsConfig> = IfDefaultsTrue<T["strict"], TokenForOptions<T>, OptionToken>;
T["strict"],
TokenForOptions<T>,
OptionToken
>;
type ParsedPositionalToken<T extends ParseArgsConfig> = IfDefaultsTrue< type ParsedPositionalToken<T extends ParseArgsConfig> = IfDefaultsTrue<
T["strict"], T["strict"],
IfDefaultsFalse< IfDefaultsFalse<T["allowPositionals"], { kind: "positional"; index: number; value: string }, never>,
T["allowPositionals"], IfDefaultsTrue<T["allowPositionals"], { kind: "positional"; index: number; value: string }, never>
{ kind: "positional"; index: number; value: string },
never
>,
IfDefaultsTrue<
T["allowPositionals"],
{ kind: "positional"; index: number; value: string },
never
>
>; >;
type ParsedTokens<T extends ParseArgsConfig> = Array< type ParsedTokens<T extends ParseArgsConfig> = Array<
| ParsedOptionToken<T> ParsedOptionToken<T> | ParsedPositionalToken<T> | { kind: "option-terminator"; index: number }
| ParsedPositionalToken<T>
| { kind: "option-terminator"; index: number }
>; >;
type PreciseParsedResults<T extends ParseArgsConfig> = IfDefaultsFalse< type PreciseParsedResults<T extends ParseArgsConfig> = IfDefaultsFalse<
@ -1631,14 +1475,7 @@ declare module "util" {
>; >;
type OptionToken = type OptionToken =
| { | { kind: "option"; index: number; name: string; rawName: string; value: string; inlineValue: boolean }
kind: "option";
index: number;
name: string;
rawName: string;
value: string;
inlineValue: boolean;
}
| { | {
kind: "option"; kind: "option";
index: number; index: number;
@ -1655,14 +1492,9 @@ declare module "util" {
// If ParseArgsConfig extends T, then the user passed config constructed elsewhere. // If ParseArgsConfig extends T, then the user passed config constructed elsewhere.
// So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above. // So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above.
type ParsedResults<T extends ParseArgsConfig> = ParseArgsConfig extends T type ParsedResults<T extends ParseArgsConfig> = ParseArgsConfig extends T ? {
? {
values: { values: {
[longOption: string]: [longOption: string]: undefined | string | boolean | Array<string | boolean>;
| undefined
| string
| boolean
| Array<string | boolean>;
}; };
positionals: string[]; positionals: string[];
tokens?: Token[]; tokens?: Token[];
@ -1922,7 +1754,7 @@ declare module "util/types" {
* ``` * ```
* @since v10.0.0 * @since v10.0.0
*/ */
function isBooleanObject(object: unknown): object is boolean; function isBooleanObject(object: unknown): object is Boolean;
/** /**
* Returns `true` if the value is any boxed primitive object, e.g. created * Returns `true` if the value is any boxed primitive object, e.g. created
* by `new Boolean()`, `new String()` or `Object(Symbol())`. * by `new Boolean()`, `new String()` or `Object(Symbol())`.
@ -1938,9 +1770,7 @@ declare module "util/types" {
* ``` * ```
* @since v10.11.0 * @since v10.11.0
*/ */
function isBoxedPrimitive( function isBoxedPrimitive(object: unknown): object is String | Number | BigInt | Boolean | Symbol;
object: unknown,
): object is string | number | bigint | boolean | symbol;
/** /**
* Returns `true` if the value is a built-in [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) instance. * Returns `true` if the value is a built-in [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) instance.
* *
@ -2094,10 +1924,7 @@ declare module "util/types" {
*/ */
function isMap<T>( function isMap<T>(
object: T | {}, object: T | {},
): object is T extends ReadonlyMap<any, any> ): object is T extends ReadonlyMap<any, any> ? (unknown extends T ? never : ReadonlyMap<any, any>)
? unknown extends T
? never
: ReadonlyMap<any, any>
: Map<unknown, unknown>; : Map<unknown, unknown>;
/** /**
* Returns `true` if the value is an iterator returned for a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance. * Returns `true` if the value is an iterator returned for a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance.
@ -2172,7 +1999,7 @@ declare module "util/types" {
* ``` * ```
* @since v10.0.0 * @since v10.0.0
*/ */
function isNumberObject(object: unknown): object is number; function isNumberObject(object: unknown): object is Number;
/** /**
* Returns `true` if the value is a built-in [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). * Returns `true` if the value is a built-in [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
* *
@ -2214,11 +2041,7 @@ declare module "util/types" {
*/ */
function isSet<T>( function isSet<T>(
object: T | {}, object: T | {},
): object is T extends ReadonlySet<any> ): object is T extends ReadonlySet<any> ? (unknown extends T ? never : ReadonlySet<any>) : Set<unknown>;
? unknown extends T
? never
: ReadonlySet<any>
: Set<unknown>;
/** /**
* Returns `true` if the value is an iterator returned for a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance. * Returns `true` if the value is an iterator returned for a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance.
* *
@ -2254,7 +2077,7 @@ declare module "util/types" {
* ``` * ```
* @since v10.0.0 * @since v10.0.0
*/ */
function isStringObject(object: unknown): object is string; function isStringObject(object: unknown): object is String;
/** /**
* Returns `true` if the value is a symbol object, created * Returns `true` if the value is a symbol object, created
* by calling `Object()` on a `Symbol` primitive. * by calling `Object()` on a `Symbol` primitive.
@ -2266,7 +2089,7 @@ declare module "util/types" {
* ``` * ```
* @since v10.0.0 * @since v10.0.0
*/ */
function isSymbolObject(object: unknown): object is symbol; function isSymbolObject(object: unknown): object is Symbol;
/** /**
* Returns `true` if the value is a built-in [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) instance. * Returns `true` if the value is a built-in [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) instance.
* *

Loading…
Cancel
Save