Skip to content

Commit c71b8a9

Browse files
authored
🤖 Merge PR DefinitelyTyped#73870 node: fixes for exactOptionalPropertyTypes, test under exOPT by @Renegade334
1 parent 9ec7983 commit c71b8a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+552
-641
lines changed

‎types/node/assert.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ declare module "assert" {
8888
* @since v24.6.0
8989
*/
9090
new(
91-
options?: AssertOptions & { strict?: true },
91+
options?: AssertOptions & { strict?: true | undefined },
9292
): AssertStrict;
9393
new(
9494
options: AssertOptions,

‎types/node/child_process.d.ts‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ declare module "child_process" {
6969
import { Abortable, EventEmitter } from "node:events";
7070
import * as dgram from "node:dgram";
7171
import * as net from "node:net";
72-
import { Pipe, Readable, Stream, Writable } from "node:stream";
72+
import { Readable, Stream, Writable } from "node:stream";
7373
import { URL } from "node:url";
7474
type Serializable = string | object | number | boolean | bigint;
7575
type SendHandle = net.Socket | net.Server | dgram.Socket | undefined;
@@ -139,7 +139,7 @@ declare module "child_process" {
139139
* no IPC channel exists, this property is `undefined`.
140140
* @since v7.1.0
141141
*/
142-
readonly channel?: Pipe | null | undefined;
142+
readonly channel?: Control | null;
143143
/**
144144
* A sparse array of pipes to the child process, corresponding with positions in
145145
* the `stdio` option passed to {@link spawn} that have been set
@@ -612,6 +612,10 @@ declare module "child_process" {
612612
Readable | Writable | null | undefined, // extra, no modification
613613
];
614614
}
615+
interface Control extends EventEmitter {
616+
ref(): void;
617+
unref(): void;
618+
}
615619
interface MessageOptions {
616620
keepOpen?: boolean | undefined;
617621
}
@@ -894,11 +898,12 @@ declare module "child_process" {
894898
interface ExecOptionsWithBufferEncoding extends ExecOptions {
895899
encoding: "buffer" | null; // specify `null`.
896900
}
901+
// TODO: Just Plain Wrongâ„¢ (see also nodejs/node#57392)
897902
interface ExecException extends Error {
898-
cmd?: string | undefined;
899-
killed?: boolean | undefined;
900-
code?: number | undefined;
901-
signal?: NodeJS.Signals | undefined;
903+
cmd?: string;
904+
killed?: boolean;
905+
code?: number;
906+
signal?: NodeJS.Signals;
902907
stdout?: string;
903908
stderr?: string;
904909
}
@@ -1056,10 +1061,11 @@ declare module "child_process" {
10561061
}
10571062
/** @deprecated Use `ExecFileOptions` instead. */
10581063
interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {}
1064+
// TODO: execFile exceptions can take many forms... this accurately describes none of them
10591065
type ExecFileException =
10601066
& Omit<ExecException, "code">
10611067
& Omit<NodeJS.ErrnoException, "code">
1062-
& { code?: string | number | undefined | null };
1068+
& { code?: string | number | null };
10631069
/**
10641070
* The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified
10651071
* executable `file` is spawned directly as a new process making it slightly more
@@ -1320,7 +1326,7 @@ declare module "child_process" {
13201326
stderr: T;
13211327
status: number | null;
13221328
signal: NodeJS.Signals | null;
1323-
error?: Error | undefined;
1329+
error?: Error;
13241330
}
13251331
/**
13261332
* The `child_process.spawnSync()` method is generally identical to {@link spawn} with the exception that the function will not return
@@ -1409,7 +1415,7 @@ declare module "child_process" {
14091415
encoding: BufferEncoding;
14101416
}
14111417
interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
1412-
encoding?: "buffer" | null; // specify `null`.
1418+
encoding?: "buffer" | null | undefined; // specify `null`.
14131419
}
14141420
/**
14151421
* The `child_process.execFileSync()` method is generally identical to {@link execFile} with the exception that the method will not

‎types/node/cluster.d.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ declare module "cluster" {
481481
* ```
482482
* @since v0.7.0
483483
*/
484-
readonly worker?: Worker | undefined;
484+
readonly worker?: Worker;
485485
/**
486486
* A hash that stores the active worker objects, keyed by `id` field. This makes it easy to loop through all the workers. It is only available in the primary process.
487487
*
@@ -497,7 +497,7 @@ declare module "cluster" {
497497
* ```
498498
* @since v0.7.0
499499
*/
500-
readonly workers?: NodeJS.Dict<Worker> | undefined;
500+
readonly workers?: NodeJS.Dict<Worker>;
501501
readonly SCHED_NONE: number;
502502
readonly SCHED_RR: number;
503503
/**
@@ -550,10 +550,9 @@ declare module "cluster" {
550550
prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
551551
prependListener(event: "fork", listener: (worker: Worker) => void): this;
552552
prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
553-
// the handle is a net.Socket or net.Server object, or undefined.
554553
prependListener(
555554
event: "message",
556-
listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void,
555+
listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void,
557556
): this;
558557
prependListener(event: "online", listener: (worker: Worker) => void): this;
559558
prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this;

‎types/node/crypto.d.ts‎

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -510,50 +510,50 @@ declare module "crypto" {
510510
format: "jwk";
511511
}
512512
interface JsonWebKey {
513-
crv?: string | undefined;
514-
d?: string | undefined;
515-
dp?: string | undefined;
516-
dq?: string | undefined;
517-
e?: string | undefined;
518-
k?: string | undefined;
519-
kty?: string | undefined;
520-
n?: string | undefined;
521-
p?: string | undefined;
522-
q?: string | undefined;
523-
qi?: string | undefined;
524-
x?: string | undefined;
525-
y?: string | undefined;
513+
crv?: string;
514+
d?: string;
515+
dp?: string;
516+
dq?: string;
517+
e?: string;
518+
k?: string;
519+
kty?: string;
520+
n?: string;
521+
p?: string;
522+
q?: string;
523+
qi?: string;
524+
x?: string;
525+
y?: string;
526526
[key: string]: unknown;
527527
}
528528
interface AsymmetricKeyDetails {
529529
/**
530530
* Key size in bits (RSA, DSA).
531531
*/
532-
modulusLength?: number | undefined;
532+
modulusLength?: number;
533533
/**
534534
* Public exponent (RSA).
535535
*/
536-
publicExponent?: bigint | undefined;
536+
publicExponent?: bigint;
537537
/**
538538
* Name of the message digest (RSA-PSS).
539539
*/
540-
hashAlgorithm?: string | undefined;
540+
hashAlgorithm?: string;
541541
/**
542542
* Name of the message digest used by MGF1 (RSA-PSS).
543543
*/
544-
mgf1HashAlgorithm?: string | undefined;
544+
mgf1HashAlgorithm?: string;
545545
/**
546546
* Minimal salt length in bytes (RSA-PSS).
547547
*/
548-
saltLength?: number | undefined;
548+
saltLength?: number;
549549
/**
550550
* Size of q in bits (DSA).
551551
*/
552-
divisorLength?: number | undefined;
552+
divisorLength?: number;
553553
/**
554554
* Name of the curve (EC).
555555
*/
556-
namedCurve?: string | undefined;
556+
namedCurve?: string;
557557
}
558558
/**
559559
* Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key,
@@ -598,7 +598,7 @@ declare module "crypto" {
598598
* keys.
599599
* @since v11.6.0
600600
*/
601-
asymmetricKeyType?: KeyType | undefined;
601+
asymmetricKeyType?: KeyType;
602602
/**
603603
* This property exists only on asymmetric keys. Depending on the type of the key,
604604
* this object contains information about the key. None of the information obtained
@@ -612,7 +612,7 @@ declare module "crypto" {
612612
* Other key details might be exposed via this API using additional attributes.
613613
* @since v15.7.0
614614
*/
615-
asymmetricKeyDetails?: AsymmetricKeyDetails | undefined;
615+
asymmetricKeyDetails?: AsymmetricKeyDetails;
616616
/**
617617
* For symmetric keys, the following encoding options can be used:
618618
*
@@ -651,7 +651,7 @@ declare module "crypto" {
651651
* property is `undefined` for asymmetric keys.
652652
* @since v11.6.0
653653
*/
654-
symmetricKeySize?: number | undefined;
654+
symmetricKeySize?: number;
655655
/**
656656
* Converts a `KeyObject` instance to a `CryptoKey`.
657657
* @since 22.10.0
@@ -2512,15 +2512,15 @@ declare module "crypto" {
25122512
/**
25132513
* Name of the message digest
25142514
*/
2515-
hashAlgorithm?: string;
2515+
hashAlgorithm?: string | undefined;
25162516
/**
25172517
* Name of the message digest used by MGF1
25182518
*/
2519-
mgf1HashAlgorithm?: string;
2519+
mgf1HashAlgorithm?: string | undefined;
25202520
/**
25212521
* Minimal salt length in bytes
25222522
*/
2523-
saltLength?: string;
2523+
saltLength?: string | undefined;
25242524
}
25252525
interface DSAKeyPairKeyObjectOptions {
25262526
/**
@@ -2563,15 +2563,15 @@ declare module "crypto" {
25632563
/**
25642564
* Name of the message digest
25652565
*/
2566-
hashAlgorithm?: string;
2566+
hashAlgorithm?: string | undefined;
25672567
/**
25682568
* Name of the message digest used by MGF1
25692569
*/
2570-
mgf1HashAlgorithm?: string;
2570+
mgf1HashAlgorithm?: string | undefined;
25712571
/**
25722572
* Minimal salt length in bytes
25732573
*/
2574-
saltLength?: string;
2574+
saltLength?: string | undefined;
25752575
publicKeyEncoding: {
25762576
type: "spki";
25772577
format: PubF;
@@ -3835,23 +3835,23 @@ declare module "crypto" {
38353835
/**
38363836
* @default 'always'
38373837
*/
3838-
subject?: "always" | "default" | "never";
3838+
subject?: "always" | "default" | "never" | undefined;
38393839
/**
38403840
* @default true
38413841
*/
3842-
wildcards?: boolean;
3842+
wildcards?: boolean | undefined;
38433843
/**
38443844
* @default true
38453845
*/
3846-
partialWildcards?: boolean;
3846+
partialWildcards?: boolean | undefined;
38473847
/**
38483848
* @default false
38493849
*/
3850-
multiLabelWildcards?: boolean;
3850+
multiLabelWildcards?: boolean | undefined;
38513851
/**
38523852
* @default false
38533853
*/
3854-
singleLabelSubdomains?: boolean;
3854+
singleLabelSubdomains?: boolean | undefined;
38553855
}
38563856
/**
38573857
* Encapsulates an X509 certificate and provides read-only access to
@@ -3953,7 +3953,7 @@ declare module "crypto" {
39533953
* available.
39543954
* @since v15.9.0
39553955
*/
3956-
readonly issuerCertificate?: X509Certificate | undefined;
3956+
readonly issuerCertificate: X509Certificate | undefined;
39573957
/**
39583958
* The public key `KeyObject` for this certificate.
39593959
* @since v15.6.0

‎types/node/dns.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ declare module "dns" {
829829
* The number of tries the resolver will try contacting each name server before giving up.
830830
* @default 4
831831
*/
832-
tries?: number;
832+
tries?: number | undefined;
833833
/**
834834
* The max retry timeout, in milliseconds.
835835
* @default 0

‎types/node/events.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ declare module "events" {
484484
* directly rather than as a child class.
485485
* @default new.target.name if instantiated as a child class.
486486
*/
487-
name?: string;
487+
name?: string | undefined;
488488
}
489489

490490
/**

‎types/node/fs.d.ts‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,7 +2634,7 @@ declare module "fs" {
26342634
/**
26352635
* @default null
26362636
*/
2637-
position?: number | undefined | null;
2637+
position?: number | null | undefined;
26382638
}
26392639
/**
26402640
* Write `buffer` to the file specified by `fd`.
@@ -4463,7 +4463,7 @@ declare module "fs" {
44634463
/**
44644464
* @default false
44654465
*/
4466-
recursive?: boolean;
4466+
recursive?: boolean | undefined;
44674467
}
44684468
/**
44694469
* Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html).
@@ -4516,54 +4516,54 @@ declare module "fs" {
45164516
* Dereference symlinks
45174517
* @default false
45184518
*/
4519-
dereference?: boolean;
4519+
dereference?: boolean | undefined;
45204520
/**
45214521
* When `force` is `false`, and the destination
45224522
* exists, throw an error.
45234523
* @default false
45244524
*/
4525-
errorOnExist?: boolean;
4525+
errorOnExist?: boolean | undefined;
45264526
/**
45274527
* Overwrite existing file or directory. _The copy
45284528
* operation will ignore errors if you set this to false and the destination
45294529
* exists. Use the `errorOnExist` option to change this behavior.
45304530
* @default true
45314531
*/
4532-
force?: boolean;
4532+
force?: boolean | undefined;
45334533
/**
45344534
* Modifiers for copy operation. See `mode` flag of {@link copyFileSync()}
45354535
*/
4536-
mode?: number;
4536+
mode?: number | undefined;
45374537
/**
45384538
* When `true` timestamps from `src` will
45394539
* be preserved.
45404540
* @default false
45414541
*/
4542-
preserveTimestamps?: boolean;
4542+
preserveTimestamps?: boolean | undefined;
45434543
/**
45444544
* Copy directories recursively.
45454545
* @default false
45464546
*/
4547-
recursive?: boolean;
4547+
recursive?: boolean | undefined;
45484548
/**
45494549
* When true, path resolution for symlinks will be skipped
45504550
* @default false
45514551
*/
4552-
verbatimSymlinks?: boolean;
4552+
verbatimSymlinks?: boolean | undefined;
45534553
}
45544554
export interface CopyOptions extends CopyOptionsBase {
45554555
/**
45564556
* Function to filter copied files/directories. Return
45574557
* `true` to copy the item, `false` to ignore it.
45584558
*/
4559-
filter?(source: string, destination: string): boolean | Promise<boolean>;
4559+
filter?: ((source: string, destination: string) => boolean | Promise<boolean>) | undefined;
45604560
}
45614561
export interface CopySyncOptions extends CopyOptionsBase {
45624562
/**
45634563
* Function to filter copied files/directories. Return
45644564
* `true` to copy the item, `false` to ignore it.
45654565
*/
4566-
filter?(source: string, destination: string): boolean;
4566+
filter?: ((source: string, destination: string) => boolean) | undefined;
45674567
}
45684568
/**
45694569
* Asynchronously copies the entire directory structure from `src` to `dest`,

0 commit comments

Comments
 (0)