Skip to content

TypeScript cannot figure out which Got type to use #954

@scttcper

Description

@scttcper

What would you like to discuss?

With @types/got we could use type GotOptions and be able to pass this to got.get(options) however with v10 the types are string | OptionsOfDefaultResponseBody and OptionsOfDefaultResponseBody and its friends are not available to import at the root of the project. I was wondering if this was on purpose.

What i'm looking for and not sure how to do with v10

const options: GotOptions = {
	url: 'https://example.com',
};
const response = await got(options);

Also, this example from the docs isn't working for me and I'm wondering if it should accept a partial? Opened #953 with a demo

got.mergeOptions(got.defaults.options, {
	responseType: 'json',
});

Checklist

  • I have read the documentation.

Really excited about the release of v10 🎉

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalThe issue related to an external projecttypesThe issue is related to TypeScript✭ help wanted ✭

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions