panva / openid-client

OAuth 2 / OpenID Connect Client API for JavaScript Runtimes
MIT License
1.83k stars 392 forks source link

Typescript compile error when parent project using got >= 10 #253

Closed jwheeler-gs closed 4 years ago

jwheeler-gs commented 4 years ago

Typescript projects which have a dependency on the "got" library at major version 10 or newer and also a dependency on "openid-client"@3.15.0 fail to compile.

Openid-client depends on Got version 9. Everything compiles successfully if the parent project is also on Got version 9, but fails on version 10 or newer with the following error:

node_modules/openid-client/types/index.d.ts:12:10 - error TS2614: Module '"../../../../../../../my-project/node_modules/got/dist/source"' has no exported member 'GotOptions'. Did you mean to use 'import GotOptions from "../../../../../../../my-project/node_modules/got/dist/source"' instead?

12 import { GotOptions, GotPromise } from 'got';

node_modules/openid-client/types/index.d.ts:12:22 - error TS2614: Module '"../../../../../../../my-project/node_modules/got/dist/source"' has no exported member 'GotPromise'. Did you mean to use 'import GotPromise from "../../../../../../../my-project/node_modules/got/dist/source"' instead?

12 import { GotOptions, GotPromise } from 'got';

I did try adding @types/got@9 to my project's dev dependencies, but unfortunately this did not help.

Any idea how to fix or work around this problem?

panva commented 4 years ago

Any idea how to fix or work around this problem?

AFAIK openid-client does everything correctly, it requires types from a version it depends on using @types/got. If you install a different version on a top level it's typescript's job to recognize the different modules that provide types.

Take it up with got or typescript directly please.

jwheeler-gs commented 4 years ago

Any chance this project could be upgraded to got version 10 or 11 in the near future? Starting with 10, got is now typescript and no longer needs a @types/got dependency.

panva commented 4 years ago

Not without requiring a new major release, which I don't have a good reason for. Yet. And FWIW, the name of the game for next major will be to remove got as a dependency altogether and just rely on Node's http/https

This is really stupid of typescript...

jwheeler-gs commented 4 years ago

In case anyone else runs into this same issue, I've created a related issue in the Typescript project: https://github.com/microsoft/TypeScript/issues/38233