Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Request type #1940

Merged
merged 3 commits into from Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions documentation/typescript.md
Expand Up @@ -40,6 +40,8 @@ Here's a list of types that Got exports:

### [`Response<T = unknown>`](https://github.com/sindresorhus/got/blob/ae04c0e36cf3f5b2e356df7d48a5b19988f935a2/source/core/response.ts#L95)

### [`Request`](https://github.com/sindresorhus/got/blob/ecb05343dea3bd35933585a1ec5bcea01348d109/source/core/index.ts#L139)

### [`RequestEvents<T>`](https://github.com/sindresorhus/got/blob/ae04c0e36cf3f5b2e356df7d48a5b19988f935a2/source/core/index.ts#L108)

### [`InstanceDefaults`](https://github.com/sindresorhus/got/blob/ae04c0e36cf3f5b2e356df7d48a5b19988f935a2/source/types.ts#L17)
Expand Down
1 change: 1 addition & 0 deletions source/index.ts
Expand Up @@ -16,6 +16,7 @@ export {got};
export {default as Options} from './core/options.js';
export * from './core/options.js';
export * from './core/response.js';
export {default as Request} from './core/index.js';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export {default as Request} from './core/index.js';
export type {default as Request} from './core/index.js';

?

I don't think we want to export the actual class as that's an implementation detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, fine with me, thanks 🙇

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sindresorhus is right - currently Request is only meant to be used as an interface. Got does a bit more than just new Request:

got/source/create.ts

Lines 57 to 59 in a405e7c

request.options = normalized;
request._noPipe = !normalized.isStream;
void request.flush();

export * from './core/index.js';
export * from './core/errors.js';
export {Delays} from './core/timed-out.js';
Expand Down