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

Added lib defs for apollo-link-http@1.2.x #1552

Closed
wants to merge 1 commit into from

Conversation

ctgardner
Copy link

@ctgardner ctgardner commented Nov 19, 2017

Seeking clarity about a few things before merging. (Sorry. First-time lib def author/contributor.)

includeExtensions?: boolean;
credentials?: string;
headers?: any;
fetchOptions?: any;
Copy link
Author

@ctgardner ctgardner Nov 19, 2017

Choose a reason for hiding this comment

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

Should mixed be used here instead (for both headers and fetchOptions)?

Copy link
Member

@gantoine gantoine Dec 17, 2017

Choose a reason for hiding this comment

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

any is fine, as it matches the ts definition.

declare export interface FetchOptions {
uri?: string;
//todo change to type of Global['fetch']
fetch?: any;
Copy link
Author

Choose a reason for hiding this comment

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

What is Global['fetch']? What is the type of Global['fetch']? (This is how the value is assigned in the source.)

Is it OK to use any here? Or mixed?

Copy link
Member

Choose a reason for hiding this comment

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

any is fine, as it matches the ts definition.


declare export class HttpLink {
//todo change type to RequestHandler from 'apollo-link'
requester: any;
Copy link
Author

Choose a reason for hiding this comment

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

The type of requester is RequestHandler from the apollo-link package. What is the appropriate way to declare this? (Keep in mind, apollo-link might not have lib defs either.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Dependencies between libdefs will probably been handled in the coming 3.0 release, which is currently discussed in #1494.

For now I think it's best to just duplicate the RequestHandler inside this libdef (like it's done in react-router-dom & react-router-native for the duplicate types from react-router) and add a // TODO: to delete this in the future when dependencies between libdefs are handled.

}

//todo change return type to ApolloLink from 'apollo-link'
declare export function createHttpLink(opts: FetchOptions): any;
Copy link
Author

Choose a reason for hiding this comment

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

Despite the name, the createHttpLink function seems to return an ApolloLink which is from the apollo-link package. What is the appropriate way to declare this? (Keep in mind, apollo-link might not have lib defs either.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as in my last comment: #1552 (discussion comment)

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

Successfully merging this pull request may close these issues.

None yet

3 participants