Skip to content

Commit 0615342

Browse files
authored
🤖 Merge PR DefinitelyTyped#71986 [node] Add missing constants to node:constants, add missing dlopen types to v18 by @Renegade334
1 parent f0671a5 commit 0615342

File tree

9 files changed

+104
-413
lines changed

9 files changed

+104
-413
lines changed

‎types/node/constants.d.ts‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
1+
/**
2+
* @deprecated The `node:constants` module is deprecated. When requiring access to constants
3+
* relevant to specific Node.js builtin modules, developers should instead refer
4+
* to the `constants` property exposed by the relevant module. For instance,
5+
* `require('node:fs').constants` and `require('node:os').constants`.
6+
*/
27
declare module "constants" {
3-
import { constants as osConstants, SignalConstants } from "node:os";
4-
import { constants as cryptoConstants } from "node:crypto";
5-
import { constants as fsConstants } from "node:fs";
6-
7-
const exp:
8-
& typeof osConstants.errno
9-
& typeof osConstants.priority
10-
& SignalConstants
11-
& typeof cryptoConstants
12-
& typeof fsConstants;
13-
export = exp;
8+
const constants:
9+
& typeof import("node:os").constants.dlopen
10+
& typeof import("node:os").constants.errno
11+
& typeof import("node:os").constants.priority
12+
& typeof import("node:os").constants.signals
13+
& typeof import("node:fs").constants
14+
& typeof import("node:crypto").constants;
15+
export = constants;
1416
}
1517

1618
declare module "node:constants" {
Lines changed: 7 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,8 @@
11
import * as constants from "node:constants";
2-
{
3-
let str: string;
4-
let num: number;
5-
num = constants.SIGHUP;
6-
num = constants.SIGINT;
7-
num = constants.SIGQUIT;
8-
num = constants.SIGILL;
9-
num = constants.SIGTRAP;
10-
num = constants.SIGABRT;
11-
num = constants.SIGIOT;
12-
num = constants.SIGBUS;
13-
num = constants.SIGFPE;
14-
num = constants.SIGKILL;
15-
num = constants.SIGUSR1;
16-
num = constants.SIGSEGV;
17-
num = constants.SIGUSR2;
18-
num = constants.SIGPIPE;
19-
num = constants.SIGALRM;
20-
num = constants.SIGTERM;
21-
num = constants.SIGCHLD;
22-
num = constants.SIGSTKFLT;
23-
num = constants.SIGCONT;
24-
num = constants.SIGSTOP;
25-
num = constants.SIGTSTP;
26-
num = constants.SIGTTIN;
27-
num = constants.SIGTTOU;
28-
num = constants.SIGURG;
29-
num = constants.SIGXCPU;
30-
num = constants.SIGXFSZ;
31-
num = constants.SIGVTALRM;
32-
num = constants.SIGPROF;
33-
num = constants.SIGWINCH;
34-
num = constants.SIGIO;
35-
num = constants.SIGPOLL;
36-
num = constants.SIGPWR;
37-
num = constants.SIGSYS;
38-
num = constants.SIGUNUSED;
39-
num = constants.O_RDONLY;
40-
num = constants.O_WRONLY;
41-
num = constants.O_RDWR;
42-
num = constants.S_IFMT;
43-
num = constants.S_IFREG;
44-
num = constants.S_IFDIR;
45-
num = constants.S_IFCHR;
46-
num = constants.S_IFBLK;
47-
num = constants.S_IFIFO;
48-
num = constants.S_IFLNK;
49-
num = constants.S_IFSOCK;
50-
num = constants.O_CREAT;
51-
num = constants.O_EXCL;
52-
num = constants.O_NOCTTY;
53-
num = constants.O_TRUNC;
54-
num = constants.O_APPEND;
55-
num = constants.O_DIRECTORY;
56-
num = constants.O_NOATIME;
57-
num = constants.O_NOFOLLOW;
58-
num = constants.O_SYNC;
59-
num = constants.O_DSYNC;
60-
num = constants.O_DIRECT;
61-
num = constants.O_NONBLOCK;
62-
num = constants.S_IRWXU;
63-
num = constants.S_IRUSR;
64-
num = constants.S_IWUSR;
65-
num = constants.S_IXUSR;
66-
num = constants.S_IRWXG;
67-
num = constants.S_IRGRP;
68-
num = constants.S_IWGRP;
69-
num = constants.S_IXGRP;
70-
num = constants.S_IRWXO;
71-
num = constants.S_IROTH;
72-
num = constants.S_IWOTH;
73-
num = constants.S_IXOTH;
74-
num = constants.F_OK;
75-
num = constants.R_OK;
76-
num = constants.W_OK;
77-
num = constants.X_OK;
78-
num = constants.SSL_OP_ALL;
79-
num = constants.SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION;
80-
num = constants.SSL_OP_CIPHER_SERVER_PREFERENCE;
81-
num = constants.SSL_OP_CISCO_ANYCONNECT;
82-
num = constants.SSL_OP_COOKIE_EXCHANGE;
83-
num = constants.SSL_OP_CRYPTOPRO_TLSEXT_BUG;
84-
num = constants.SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
85-
num = constants.SSL_OP_LEGACY_SERVER_CONNECT;
86-
num = constants.SSL_OP_NO_COMPRESSION;
87-
num = constants.SSL_OP_NO_QUERY_MTU;
88-
num = constants.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;
89-
num = constants.SSL_OP_NO_SSLv2;
90-
num = constants.SSL_OP_NO_SSLv3;
91-
num = constants.SSL_OP_NO_TICKET;
92-
num = constants.SSL_OP_NO_TLSv1;
93-
num = constants.SSL_OP_NO_TLSv1_1;
94-
num = constants.SSL_OP_NO_TLSv1_2;
95-
num = constants.SSL_OP_TLS_ROLLBACK_BUG;
96-
num = constants.ENGINE_METHOD_RSA;
97-
num = constants.ENGINE_METHOD_DSA;
98-
num = constants.ENGINE_METHOD_DH;
99-
num = constants.ENGINE_METHOD_RAND;
100-
num = constants.ENGINE_METHOD_CIPHERS;
101-
num = constants.ENGINE_METHOD_DIGESTS;
102-
num = constants.ENGINE_METHOD_PKEY_METHS;
103-
num = constants.ENGINE_METHOD_PKEY_ASN1_METHS;
104-
num = constants.ENGINE_METHOD_ALL;
105-
num = constants.ENGINE_METHOD_NONE;
106-
num = constants.DH_CHECK_P_NOT_SAFE_PRIME;
107-
num = constants.DH_CHECK_P_NOT_PRIME;
108-
num = constants.DH_UNABLE_TO_CHECK_GENERATOR;
109-
num = constants.DH_NOT_SUITABLE_GENERATOR;
110-
num = constants.RSA_PKCS1_PADDING;
111-
num = constants.RSA_SSLV23_PADDING;
112-
num = constants.RSA_NO_PADDING;
113-
num = constants.RSA_PKCS1_OAEP_PADDING;
114-
num = constants.RSA_X931_PADDING;
115-
num = constants.RSA_PKCS1_PSS_PADDING;
116-
num = constants.POINT_CONVERSION_COMPRESSED;
117-
num = constants.POINT_CONVERSION_UNCOMPRESSED;
118-
num = constants.POINT_CONVERSION_HYBRID;
119-
str = constants.defaultCoreCipherList;
120-
str = constants.defaultCipherList;
121-
}
2+
3+
const dlopen: typeof import("node:os").constants.dlopen = constants;
4+
const errno: typeof import("node:os").constants.errno = constants;
5+
const priority: typeof import("node:os").constants.priority = constants;
6+
const signals: typeof import("node:os").constants.signals = constants;
7+
const fs: typeof import("node:fs").constants = constants;
8+
const crypto: typeof import("node:crypto").constants = constants;

‎types/node/v18/constants.d.ts‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
1+
/**
2+
* @deprecated The `node:constants` module is deprecated. When requiring access to constants
3+
* relevant to specific Node.js builtin modules, developers should instead refer
4+
* to the `constants` property exposed by the relevant module. For instance,
5+
* `require('node:fs').constants` and `require('node:os').constants`.
6+
*/
27
declare module "constants" {
3-
import { constants as osConstants, SignalConstants } from "node:os";
4-
import { constants as cryptoConstants } from "node:crypto";
5-
import { constants as fsConstants } from "node:fs";
6-
7-
const exp:
8-
& typeof osConstants.errno
9-
& typeof osConstants.priority
10-
& SignalConstants
11-
& typeof cryptoConstants
12-
& typeof fsConstants;
13-
export = exp;
8+
const constants:
9+
& typeof import("node:os").constants.dlopen
10+
& typeof import("node:os").constants.errno
11+
& typeof import("node:os").constants.priority
12+
& typeof import("node:os").constants.signals
13+
& typeof import("node:fs").constants
14+
& typeof import("node:crypto").constants;
15+
export = constants;
1416
}
1517

1618
declare module "node:constants" {

‎types/node/v18/os.d.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,13 @@ declare module "os" {
382382
const WSA_E_CANCELLED: number;
383383
const WSAEREFUSED: number;
384384
}
385+
namespace dlopen {
386+
const RTLD_LAZY: number;
387+
const RTLD_NOW: number;
388+
const RTLD_GLOBAL: number;
389+
const RTLD_LOCAL: number;
390+
const RTLD_DEEPBIND: number;
391+
}
385392
namespace priority {
386393
const PRIORITY_LOW: number;
387394
const PRIORITY_BELOW_NORMAL: number;

‎types/node/v18/process.d.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,33 @@ declare module "process" {
509509
* @since v0.7.2
510510
*/
511511
debugPort: number;
512+
/**
513+
* The `process.dlopen()` method allows dynamically loading shared objects. It is primarily used by `require()` to load C++ Addons, and
514+
* should not be used directly, except in special cases. In other words, `require()` should be preferred over `process.dlopen()`
515+
* unless there are specific reasons such as custom dlopen flags or loading from ES modules.
516+
*
517+
* The `flags` argument is an integer that allows to specify dlopen behavior. See the `[os.constants.dlopen](https://nodejs.org/docs/latest-v20.x/api/os.html#dlopen-constants)`
518+
* documentation for details.
519+
*
520+
* An important requirement when calling `process.dlopen()` is that the `module` instance must be passed. Functions exported by the C++ Addon
521+
* are then accessible via `module.exports`.
522+
*
523+
* The example below shows how to load a C++ Addon, named `local.node`, that exports a `foo` function. All the symbols are loaded before the call returns, by passing the `RTLD_NOW` constant.
524+
* In this example the constant is assumed to be available.
525+
*
526+
* ```js
527+
* import { dlopen } from 'node:process';
528+
* import { constants } from 'node:os';
529+
* import { fileURLToPath } from 'node:url';
530+
*
531+
* const module = { exports: {} };
532+
* dlopen(module, fileURLToPath(new URL('local.node', import.meta.url)),
533+
* constants.dlopen.RTLD_NOW);
534+
* module.exports.foo();
535+
* ```
536+
* @since v0.1.16
537+
*/
538+
dlopen(module: object, filename: string, flags?: number): void;
512539
/**
513540
* The `process.emitWarning()` method can be used to emit custom or application
514541
* specific process warnings. These can be listened for by adding a handler to the `'warning'` event.
Lines changed: 7 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,8 @@
11
import * as constants from "node:constants";
2-
{
3-
let str: string;
4-
let num: number;
5-
num = constants.SIGHUP;
6-
num = constants.SIGINT;
7-
num = constants.SIGQUIT;
8-
num = constants.SIGILL;
9-
num = constants.SIGTRAP;
10-
num = constants.SIGABRT;
11-
num = constants.SIGIOT;
12-
num = constants.SIGBUS;
13-
num = constants.SIGFPE;
14-
num = constants.SIGKILL;
15-
num = constants.SIGUSR1;
16-
num = constants.SIGSEGV;
17-
num = constants.SIGUSR2;
18-
num = constants.SIGPIPE;
19-
num = constants.SIGALRM;
20-
num = constants.SIGTERM;
21-
num = constants.SIGCHLD;
22-
num = constants.SIGSTKFLT;
23-
num = constants.SIGCONT;
24-
num = constants.SIGSTOP;
25-
num = constants.SIGTSTP;
26-
num = constants.SIGTTIN;
27-
num = constants.SIGTTOU;
28-
num = constants.SIGURG;
29-
num = constants.SIGXCPU;
30-
num = constants.SIGXFSZ;
31-
num = constants.SIGVTALRM;
32-
num = constants.SIGPROF;
33-
num = constants.SIGWINCH;
34-
num = constants.SIGIO;
35-
num = constants.SIGPOLL;
36-
num = constants.SIGPWR;
37-
num = constants.SIGSYS;
38-
num = constants.SIGUNUSED;
39-
num = constants.O_RDONLY;
40-
num = constants.O_WRONLY;
41-
num = constants.O_RDWR;
42-
num = constants.S_IFMT;
43-
num = constants.S_IFREG;
44-
num = constants.S_IFDIR;
45-
num = constants.S_IFCHR;
46-
num = constants.S_IFBLK;
47-
num = constants.S_IFIFO;
48-
num = constants.S_IFLNK;
49-
num = constants.S_IFSOCK;
50-
num = constants.O_CREAT;
51-
num = constants.O_EXCL;
52-
num = constants.O_NOCTTY;
53-
num = constants.O_TRUNC;
54-
num = constants.O_APPEND;
55-
num = constants.O_DIRECTORY;
56-
num = constants.O_NOATIME;
57-
num = constants.O_NOFOLLOW;
58-
num = constants.O_SYNC;
59-
num = constants.O_DSYNC;
60-
num = constants.O_DIRECT;
61-
num = constants.O_NONBLOCK;
62-
num = constants.S_IRWXU;
63-
num = constants.S_IRUSR;
64-
num = constants.S_IWUSR;
65-
num = constants.S_IXUSR;
66-
num = constants.S_IRWXG;
67-
num = constants.S_IRGRP;
68-
num = constants.S_IWGRP;
69-
num = constants.S_IXGRP;
70-
num = constants.S_IRWXO;
71-
num = constants.S_IROTH;
72-
num = constants.S_IWOTH;
73-
num = constants.S_IXOTH;
74-
num = constants.F_OK;
75-
num = constants.R_OK;
76-
num = constants.W_OK;
77-
num = constants.X_OK;
78-
num = constants.SSL_OP_ALL;
79-
num = constants.SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION;
80-
num = constants.SSL_OP_CIPHER_SERVER_PREFERENCE;
81-
num = constants.SSL_OP_CISCO_ANYCONNECT;
82-
num = constants.SSL_OP_COOKIE_EXCHANGE;
83-
num = constants.SSL_OP_CRYPTOPRO_TLSEXT_BUG;
84-
num = constants.SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
85-
num = constants.SSL_OP_EPHEMERAL_RSA;
86-
num = constants.SSL_OP_LEGACY_SERVER_CONNECT;
87-
num = constants.SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER;
88-
num = constants.SSL_OP_MICROSOFT_SESS_ID_BUG;
89-
num = constants.SSL_OP_MSIE_SSLV2_RSA_PADDING;
90-
num = constants.SSL_OP_NETSCAPE_CA_DN_BUG;
91-
num = constants.SSL_OP_NETSCAPE_CHALLENGE_BUG;
92-
num = constants.SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG;
93-
num = constants.SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG;
94-
num = constants.SSL_OP_NO_COMPRESSION;
95-
num = constants.SSL_OP_NO_QUERY_MTU;
96-
num = constants.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;
97-
num = constants.SSL_OP_NO_SSLv2;
98-
num = constants.SSL_OP_NO_SSLv3;
99-
num = constants.SSL_OP_NO_TICKET;
100-
num = constants.SSL_OP_NO_TLSv1;
101-
num = constants.SSL_OP_NO_TLSv1_1;
102-
num = constants.SSL_OP_NO_TLSv1_2;
103-
num = constants.SSL_OP_PKCS1_CHECK_1;
104-
num = constants.SSL_OP_PKCS1_CHECK_2;
105-
num = constants.SSL_OP_SINGLE_DH_USE;
106-
num = constants.SSL_OP_SINGLE_ECDH_USE;
107-
num = constants.SSL_OP_SSLEAY_080_CLIENT_DH_BUG;
108-
num = constants.SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG;
109-
num = constants.SSL_OP_TLS_BLOCK_PADDING_BUG;
110-
num = constants.SSL_OP_TLS_D5_BUG;
111-
num = constants.SSL_OP_TLS_ROLLBACK_BUG;
112-
num = constants.ENGINE_METHOD_RSA;
113-
num = constants.ENGINE_METHOD_DSA;
114-
num = constants.ENGINE_METHOD_DH;
115-
num = constants.ENGINE_METHOD_RAND;
116-
num = constants.ENGINE_METHOD_CIPHERS;
117-
num = constants.ENGINE_METHOD_DIGESTS;
118-
num = constants.ENGINE_METHOD_PKEY_METHS;
119-
num = constants.ENGINE_METHOD_PKEY_ASN1_METHS;
120-
num = constants.ENGINE_METHOD_ALL;
121-
num = constants.ENGINE_METHOD_NONE;
122-
num = constants.DH_CHECK_P_NOT_SAFE_PRIME;
123-
num = constants.DH_CHECK_P_NOT_PRIME;
124-
num = constants.DH_UNABLE_TO_CHECK_GENERATOR;
125-
num = constants.DH_NOT_SUITABLE_GENERATOR;
126-
num = constants.ALPN_ENABLED;
127-
num = constants.RSA_PKCS1_PADDING;
128-
num = constants.RSA_SSLV23_PADDING;
129-
num = constants.RSA_NO_PADDING;
130-
num = constants.RSA_PKCS1_OAEP_PADDING;
131-
num = constants.RSA_X931_PADDING;
132-
num = constants.RSA_PKCS1_PSS_PADDING;
133-
num = constants.POINT_CONVERSION_COMPRESSED;
134-
num = constants.POINT_CONVERSION_UNCOMPRESSED;
135-
num = constants.POINT_CONVERSION_HYBRID;
136-
str = constants.defaultCoreCipherList;
137-
str = constants.defaultCipherList;
138-
}
2+
3+
const dlopen: typeof import("node:os").constants.dlopen = constants;
4+
const errno: typeof import("node:os").constants.errno = constants;
5+
const priority: typeof import("node:os").constants.priority = constants;
6+
const signals: typeof import("node:os").constants.signals = constants;
7+
const fs: typeof import("node:fs").constants = constants;
8+
const crypto: typeof import("node:crypto").constants = constants;

0 commit comments

Comments
 (0)