Skip to content

Commit 8bfd7c3

Browse files
authored
🤖 Merge PR DefinitelyTyped#72922 node: util.parseEnv() returns string dictionary by @Renegade334
1 parent fc56df8 commit 8bfd7c3

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

‎types/node/test/util.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ util.format();
7171

7272
util.formatWithOptions({ colors: true }, "See object %O", { foo: 42 });
7373

74-
util.parseEnv("HELLO=world\nHELLO=oh my\n");
74+
{
75+
const dotenv = util.parseEnv("HELLO=world\nHELLO=oh my\n");
76+
dotenv.HELLO; // $ExpectType string | undefined
77+
}
7578

7679
console.log(util.styleText("red", "Error! Error!"));
7780
console.log(

‎types/node/util.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ declare module "util" {
14111411
* @param content The raw contents of a `.env` file.
14121412
* @since v20.12.0
14131413
*/
1414-
export function parseEnv(content: string): object;
1414+
export function parseEnv(content: string): NodeJS.Dict<string>;
14151415
// https://nodejs.org/docs/latest/api/util.html#foreground-colors
14161416
type ForegroundColors =
14171417
| "black"

‎types/node/v20/test/util.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ util.format();
6262

6363
util.formatWithOptions({ colors: true }, "See object %O", { foo: 42 });
6464

65-
util.parseEnv("HELLO=world\nHELLO=oh my\n");
65+
{
66+
const dotenv = util.parseEnv("HELLO=world\nHELLO=oh my\n");
67+
dotenv.HELLO; // $ExpectType string | undefined
68+
}
6669

6770
console.log(util.styleText("red", "Error! Error!"));
6871
console.log(

‎types/node/v20/util.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ declare module "util" {
11861186
* @param content The raw contents of a `.env` file.
11871187
* @since v20.12.0
11881188
*/
1189-
export function parseEnv(content: string): object;
1189+
export function parseEnv(content: string): NodeJS.Dict<string>;
11901190
// https://nodejs.org/docs/latest/api/util.html#foreground-colors
11911191
type ForegroundColors =
11921192
| "black"

0 commit comments

Comments
 (0)