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

Add TypeScript definition #20

Merged
merged 12 commits into from
Sep 17, 2018
Merged

Add TypeScript definition #20

merged 12 commits into from
Sep 17, 2018

Conversation

rick-yo
Copy link
Contributor

@rick-yo rick-yo commented Sep 7, 2018

Fixes #12

@sindresorhus
Copy link
Owner

Thanks for submitting this. Can you follow this style guide: https://github.com/sindresorhus/typescript-definition-style-guide

index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
@rick-yo
Copy link
Contributor Author

rick-yo commented Sep 7, 2018

hey, I have changed typings according to review

@sindresorhus
Copy link
Owner

Thanks. Still needs tests and some more things mentioned in the style guide. Try going through it point for point.

index.d.ts Outdated
put (input: Request | string, options?: Options): Promise<Response>;
patch (input: Request | string, options?: Options): Promise<Response>;
head (input: Request | string, options?: Options): Promise<Response>;
delete (input: Request | string, options?: Options): Promise<Response>;
Copy link
Owner

Choose a reason for hiding this comment

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

There's a lot of duplication on these. Is there any way to reuse the declaration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as far as I know, there is nothing in typescript can reuse these declarations. at least axios declare in this way

Copy link
Contributor

Choose a reason for hiding this comment

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

Sometimes, in simple cases, copy-paste doesn't hurt and is even simpler. I think this is such case when it's totally fine. Easily digestable by readers

@sindresorhus
Copy link
Owner

Also note this:

Returns a Response object with Body methods added for convenience. So you can, for example, call ky.json() directly on the Response without having to await it first.

I don't see that reflected in the type definition.

index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
@rick-yo
Copy link
Contributor Author

rick-yo commented Sep 8, 2018

Hey, types test has been added, and some changes. Hope it will work fine

@sindresorhus sindresorhus changed the title add typescript typings Add TypeScript definition Sep 10, 2018
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated

/**
* Create a new ky instance with some defaults overridden with your own.
* @returns new Ky instance
Copy link
Owner

Choose a reason for hiding this comment

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

new Ky instance => New Ky instance.

index.test-d.ts Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

// @brandon93s @calebboyd In case you would be able to help review :)

index.d.ts Outdated Show resolved Hide resolved
index.test-d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
@kirillgroshkov kirillgroshkov mentioned this pull request Sep 11, 2018
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

Nice work, @luv-sic. Looks good now :)

@sindresorhus sindresorhus merged commit 3e4222d into sindresorhus:master Sep 17, 2018
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.

3 participants