Skip to content

Commit d261c18

Browse files
authored
🤖 Merge PR DefinitelyTyped#70262 [node] Update typings to v22.4.0 by @Semigradsky
1 parent d16c69b commit d261c18

File tree

5 files changed

+141
-2
lines changed

5 files changed

+141
-2
lines changed

types/node/globals.d.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,84 @@ declare global {
103103
};
104104
// #endregion borrowed
105105

106+
// #region Storage
107+
/**
108+
* This Web Storage API interface provides access to a particular domain's session or local storage. It allows, for example, the addition, modification, or deletion of stored data items.
109+
*
110+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage)
111+
*/
112+
interface Storage {
113+
/**
114+
* Returns the number of key/value pairs.
115+
*
116+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/length)
117+
*/
118+
readonly length: number;
119+
/**
120+
* Removes all key/value pairs, if there are any.
121+
*
122+
* Dispatches a storage event on Window objects holding an equivalent Storage object.
123+
*
124+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/clear)
125+
*/
126+
clear(): void;
127+
/**
128+
* Returns the current value associated with the given key, or null if the given key does not exist.
129+
*
130+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/getItem)
131+
*/
132+
getItem(key: string): string | null;
133+
/**
134+
* Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
135+
*
136+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/key)
137+
*/
138+
key(index: number): string | null;
139+
/**
140+
* Removes the key/value pair with the given key, if a key/value pair with the given key exists.
141+
*
142+
* Dispatches a storage event on Window objects holding an equivalent Storage object.
143+
*
144+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/removeItem)
145+
*/
146+
removeItem(key: string): void;
147+
/**
148+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
149+
*
150+
* Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set. (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)
151+
*
152+
* Dispatches a storage event on Window objects holding an equivalent Storage object.
153+
*
154+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/setItem)
155+
*/
156+
setItem(key: string, value: string): void;
157+
}
158+
159+
var Storage: typeof globalThis extends { onmessage: any; Storage: infer T } ? T
160+
: {
161+
prototype: Storage;
162+
new(): Storage;
163+
};
164+
165+
/**
166+
* A browser-compatible implementation of [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
167+
* Data is stored unencrypted in the file specified by the `--localstorage-file` CLI flag.
168+
* Any modification of this data outside of the Web Storage API is not supported.
169+
* Enable this API with the `--experimental-webstorage` CLI flag.
170+
* @since v22.4.0
171+
*/
172+
var localStorage: Storage;
173+
174+
/**
175+
* A browser-compatible implementation of [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage).
176+
* Data is stored in memory, with a storage quota of 10 MB.
177+
* Any modification of this data outside of the Web Storage API is not supported.
178+
* Enable this API with the `--experimental-webstorage` CLI flag.
179+
* @since v22.4.0
180+
*/
181+
var sessionStorage: Storage;
182+
// #endregion Storage
183+
106184
// #region Disposable
107185
interface SymbolConstructor {
108186
/**

types/node/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"private": true,
33
"name": "@types/node",
4-
"version": "22.3.9999",
4+
"version": "22.4.9999",
55
"nonNpm": "conflict",
66
"nonNpmDescription": "Node.js",
77
"projects": [
88
"https://nodejs.org/"
99
],
1010
"tsconfigs": ["tsconfig.dom.json", "tsconfig.non-dom.json"],
1111
"dependencies": {
12-
"undici-types": "~6.18.2"
12+
"undici-types": "~6.19.2"
1313
},
1414
"devDependencies": {
1515
"@types/node": "workspace:."

types/node/test/util.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,58 @@ access("file/that/does/not/exist", (err) => {
336336
const result = util.parseArgs(config);
337337
}
338338

339+
{
340+
// args are passed `type: "boolean"` and allow negative options
341+
const result = util.parseArgs({
342+
args: ["--no-alpha"],
343+
options: {
344+
alpha: { type: "boolean" },
345+
},
346+
allowNegative: true,
347+
});
348+
// $ExpectType boolean | undefined
349+
result.values.alpha; // false
350+
}
351+
352+
{
353+
// args are passed `default: "true"` and allow negative options
354+
const result = util.parseArgs({
355+
args: ["--no-alpha"],
356+
options: {
357+
alpha: { type: "boolean", default: true },
358+
},
359+
allowNegative: true,
360+
});
361+
// $ExpectType boolean | undefined
362+
result.values.alpha; // false
363+
}
364+
365+
{
366+
// allow negative options and multiple as true
367+
const result = util.parseArgs({
368+
args: ["--no-alpha", "--alpha", "--no-alpha"],
369+
options: {
370+
alpha: { type: "boolean", multiple: true },
371+
},
372+
allowNegative: true,
373+
});
374+
// $ExpectType boolean[] | undefined
375+
result.values.alpha; // [false, true, false]
376+
}
377+
378+
{
379+
// allow negative options and passed multiple arguments
380+
const result = util.parseArgs({
381+
args: ["--no-alpha", "--alpha"],
382+
options: {
383+
alpha: { type: "boolean" },
384+
},
385+
allowNegative: true,
386+
});
387+
// $ExpectType boolean | undefined
388+
result.values.alpha; // true
389+
}
390+
339391
{
340392
const controller: AbortController = util.transferableAbortController();
341393
const signal: AbortSignal = util.transferableAbortSignal(controller.signal);

types/node/tls.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ declare module "tls" {
843843
ciphers?: string | undefined;
844844
/**
845845
* Name of an OpenSSL engine which can provide the client certificate.
846+
* @deprecated
846847
*/
847848
clientCertEngine?: string | undefined;
848849
/**
@@ -885,12 +886,14 @@ declare module "tls" {
885886
/**
886887
* Name of an OpenSSL engine to get private key from. Should be used
887888
* together with privateKeyIdentifier.
889+
* @deprecated
888890
*/
889891
privateKeyEngine?: string | undefined;
890892
/**
891893
* Identifier of a private key managed by an OpenSSL engine. Should be
892894
* used together with privateKeyEngine. Should not be set together with
893895
* key, because both options define a private key in different ways.
896+
* @deprecated
894897
*/
895898
privateKeyIdentifier?: string | undefined;
896899
/**

types/node/util.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,12 @@ declare module "util" {
14801480
* Whether this command accepts positional arguments.
14811481
*/
14821482
allowPositionals?: boolean | undefined;
1483+
/**
1484+
* If `true`, allows explicitly setting boolean options to `false` by prefixing the option name with `--no-`.
1485+
* @default false
1486+
* @since v22.4.0
1487+
*/
1488+
allowNegative?: boolean | undefined;
14831489
/**
14841490
* Return the parsed tokens. This is useful for extending the built-in behavior,
14851491
* from adding additional checks through to reprocessing the tokens in different ways.

0 commit comments

Comments
 (0)