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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export type KyInstance #529

Closed
wants to merge 1 commit into from
Closed

Export type KyInstance #529

wants to merge 1 commit into from

Conversation

adematte
Copy link

Thanks for this great lib 馃檹

This is a small PR to export KyInstance to improve typescript support.

This is especially useful when using ky.create(...) to init a ky instance with new defaults in a class constructor. Without KyInstance type being exported it's impossible to type a class property holding the ky instance.

class Foo {
    #kyClient:KyInstance // can't be typed without exporting KyInstance

    constructor() {
        this.#kyClient = ky.create({
            headers: { 'PRIVATE-TOKEN': 'XXXXXXX' }
        })
    }
 // etc...
}

Useful to type a class property when using ky.create
@sindresorhus
Copy link
Owner

Duplicate of #383

@sindresorhus sindresorhus marked this as a duplicate of #383 Sep 19, 2023
@adematte
Copy link
Author

Duplicate of #383

makes perfect sense 馃憣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants