correct typings for twit

This commit is contained in:
sa
2017-12-24 03:05:51 -05:00
parent 39e82ad981
commit 9daa98d177
2 changed files with 22 additions and 5 deletions

21
types/twit/index.d.ts vendored
View File

@@ -1,6 +1,7 @@
// Type definitions for twit 2.2
// Project: https://github.com/ttezel/twit
// Definitions by: Volox <https://github.com/Volox>
// lostfictions <https://github.com/lostfictions>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -208,12 +209,22 @@ declare module 'twit' {
query?: string,
max_id_str?: string
}
export interface Errors {
errors: {
code: number
message: string
}[]
}
export interface SearchResults {
statuses: Twitter.Status[],
search_metadata: Twitter.Metadata,
}
}
export interface Response {
statuses: Twitter.Status[],
search_metadata: Twitter.Metadata,
}
export type Response = object
interface MediaParam {
file_path: string
}
@@ -250,7 +261,7 @@ declare module 'twit' {
}
export interface PromiseResponse {
data: Response,
responde: IncomingMessage,
resp: IncomingMessage,
}
export interface Callback {
(err: Error, result: Response, response: IncomingMessage): void

View File

@@ -5,3 +5,9 @@ const t = new Twit( {
consumer_secret: '',
app_only_auth: true,
} );
t.post('statuses/update', { status: 'hello!' }).then(res => {
const status = res.data as Twit.Twitter.Status
console.log(status.id_str)
console.log(res.resp.statusCode)
})