-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
declare module "apollo-link-http" { | ||
declare export interface FetchOptions { | ||
uri?: string; | ||
//todo change to type of Global['fetch'] | ||
fetch?: any; | ||
includeExtensions?: boolean; | ||
credentials?: string; | ||
headers?: any; | ||
fetchOptions?: any; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
//todo change return type to ApolloLink from 'apollo-link' | ||
declare export function createHttpLink(opts: FetchOptions): any; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Despite the name, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as in my last comment: #1552 (discussion comment) |
||
|
||
declare export class HttpLink { | ||
//todo change type to RequestHandler from 'apollo-link' | ||
requester: any; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dependencies between libdefs will probably been handled in the coming For now I think it's best to just duplicate the |
||
constructor(opts: FetchOptions): HttpLink; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// @flow | ||
import { createHttpLink, HttpLink } from "apollo-link-http"; | ||
import type { FetchOptions } from "apollo-link-http"; | ||
|
||
const options: FetchOptions = {}; | ||
|
||
// $ExpectError | ||
options.uri = 123; | ||
options.uri = "/uri"; | ||
|
||
//todo test options.fetch | ||
|
||
// $ExpectError | ||
options.includeExtensions = "false"; | ||
options.includeExtensions = false; | ||
|
||
// $ExpectError | ||
options.credentials = 123; | ||
options.credentials = "credentials"; | ||
|
||
// $ExpectError | ||
options.foobar = "foobar"; | ||
|
||
//todo change type to ApolloLink from 'apollo-link' | ||
let apolloLink: any; | ||
// $ExpectError | ||
apolloLink = createHttpLink({ uri: 123 }); | ||
apolloLink = createHttpLink(options); | ||
|
||
let httpLink: HttpLink; | ||
// $ExpectError | ||
httpLink = new HttpLink({ uri: 123 }); | ||
httpLink = new HttpLink(options); | ||
|
||
//todo change type to RequestHandler from 'apollo-link' | ||
const requester: any = httpLink.requester; |
There was a problem hiding this comment.
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 ofGlobal['fetch']
? (This is how the value is assigned in the source.)Is it OK to use
any
here? Ormixed
?There was a problem hiding this comment.
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 thets
definition.