sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.27k stars 935 forks source link

RetryError is not exported #1920

Closed superlc closed 2 years ago

superlc commented 2 years ago

Describe the bug

import { RetryError } from 'got' image

Expected behavior

import { RetryError } from 'got' ...

Code to reproduce

...

Checklist

szmarczak commented 2 years ago

https://github.com/sindresorhus/got/blob/30aad388ba1a11144be35356f020ababf4bffc79/source/index.ts#L20

https://github.com/sindresorhus/got/blob/30aad388ba1a11144be35356f020ababf4bffc79/source/core/errors.ts#L166

superlc commented 2 years ago

I have read the source code. The code of the href you gave is correct, but when I import { RetryError } from 'got', It shows that image I was so confused.

superlc commented 2 years ago

https://github.com/sindresorhus/got/blob/30aad388ba1a11144be35356f020ababf4bffc79/source/index.ts#L20

https://github.com/sindresorhus/got/blob/30aad388ba1a11144be35356f020ababf4bffc79/source/core/errors.ts#L166

I have no problem with source code. If you read dist code carefully, you could find it out that no RetryError in types file.

szmarczak commented 2 years ago

The exported types.d.ts file is not used as the types entry in package.json, it's just a helper. Because it's defined in the source code, it's also exported here:

https://cdn.jsdelivr.net/npm/got@12.0.0-beta.4/dist/source/core/errors.d.ts

export declare class RetryError extends RequestError {

which is imported by https://cdn.jsdelivr.net/npm/got@12.0.0-beta.4/dist/source/index.d.ts

szmarczak commented 2 years ago

Can you set up a repro please?

superlc commented 2 years ago

Can you set up a repro please?

After I installed the package of version 12.0.0-beta.4, it works. I can use RetryError now.