motdotla / dotenv

Loads environment variables from .env for nodejs projects.
https://www.dotenvx.com
BSD 2-Clause "Simplified" License
19.04k stars 854 forks source link

fix missing URL import in types #751

Closed Jakousa closed 1 year ago

Jakousa commented 1 year ago

What:

Adds missing import to types.

Why:

The types are missing import which results in

node_modules/dotenv/lib/main.d.ts:29:19 - error TS2304: Cannot find name 'URL'.

29   path?: string | URL;

See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19799.

motdotla commented 1 year ago

The types stuff is never ending. Is there a way to do this in the package.json instead of adding code?

TylerHaigh commented 1 year ago

Hi all,

Since this change we have observed the following error in our application

node_modules/dotenv/lib/main.d.ts:3:26 - error TS2307: Cannot find module 'node:url' or its corresponding type declarations.

3 import type { URL } from 'node:url';

Is there something additional we need to add to make this work?

TylerHaigh commented 1 year ago

Update: Our project was using @types/node@13 - bumping this to at either @types/node@14 or @16 works (@18 didn't work)

motdotla commented 1 year ago

Thank you. For anyone else experiencing @TylerHaigh's issue do the same for now.

I might consider reverting this PR. It is getting annoying how type changes have so many side effects for others - causing perfectly fine working software to cause failures.

Abramovick commented 1 year ago

I'm also facing this error! Though mine is slightly different

node_modules/dotenv/lib/main.d.ts:3:26 - error TS2307: Cannot find module 'node:url' or its corresponding type declarations.

3 import type { URL } from 'node:url';
                           ~~~~~~~~~~