-
Notifications
You must be signed in to change notification settings - Fork 111
Added type definitions to make it Typescript compatible #176
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
base: master
Are you sure you want to change the base?
Changes from 3 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,67 @@ | ||
| interface FBOptions { | ||
| accessToken: string; | ||
| appId: string; | ||
| appSecret: string; | ||
| version?: string; | ||
| proxy?: string; | ||
| timeout?: number; | ||
| scope?: string; | ||
| redirectUri?: string; | ||
| Promise?: Promise<any>; | ||
| } | ||
|
|
||
| interface FBAPIInterface { | ||
| path: string; | ||
| method?: string; | ||
| params?: object; | ||
| callback?: Function; | ||
| } | ||
|
|
||
| interface FBKeyOrOptions { | ||
| key: string; | ||
| options: FBOptions; | ||
| } | ||
|
|
||
| interface SignedRequestResponse { | ||
| oauthToken: string; | ||
| userId: string; | ||
| userCountry: string; | ||
| } | ||
|
|
||
| interface UsageInterface { | ||
| callCount: number; | ||
| totalTime: number; | ||
| totalCPUTime: number; | ||
| } | ||
|
|
||
| export class Facebook { | ||
|
shibulijack marked this conversation as resolved.
|
||
| constructor(options?: FBOptions); | ||
|
|
||
| api(arguments: FBAPIInterface): Promise<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. api and napi args are not a single arguments object, they're separate ordered arguments. You'll need overloading here as well to differentiate between |
||
|
|
||
| extend(options: FBOptions): Facebook; | ||
|
|
||
| getAccessToken(): string; | ||
|
|
||
| getAppUsage(): UsageInterface; | ||
|
|
||
| getPageUsage(): UsageInterface; | ||
|
|
||
| getLoginUrl(options: FBOptions): string; | ||
|
|
||
| napi(arguments: FBAPIInterface): void; | ||
|
|
||
| options(keyOrOptions: keyof FBKeyOrOptions): 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. No, this needs overloading, not another interface type. Something like: options(): FBOptions
options(key: K): ... // (I'm not sure which to use here but there should be a way to use keyof and also get TS to automatically infer the correct return type
options(options: FBOptions): void |
||
|
|
||
| parseSignedRequest(signedRequest: string, appSecret: string): SignedRequestResponse; | ||
|
|
||
| setAccessToken(accessToken: string): void; | ||
|
|
||
| withAccessToken(accessToken: string): Facebook; | ||
| } | ||
|
|
||
| export const version: string; | ||
|
|
||
| export function FacebookApiException(res: Response): Error; | ||
|
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.
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. Also I'm pretty sure Error extensions are implemented using class and extends instead of functions. |
||
|
|
||
| export const FB: Facebook; | ||
|
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. This is also a default export. |
||
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.
A bunch of options appear to be missing.
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.
I used the ones mentioned in the README. Turns out the list wasn't exhaustive. I'll update the options with the ones listed in the source code.