From 9daa98d1775dafe79f1eabbbb6172a65ee5aa367 Mon Sep 17 00:00:00 2001 From: sa Date: Sun, 24 Dec 2017 03:05:51 -0500 Subject: [PATCH] correct typings for twit --- types/twit/index.d.ts | 21 ++++++++++++++++----- types/twit/twit-tests.ts | 6 ++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/types/twit/index.d.ts b/types/twit/index.d.ts index 337a51b476..91d683833e 100644 --- a/types/twit/index.d.ts +++ b/types/twit/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for twit 2.2 // Project: https://github.com/ttezel/twit // Definitions by: Volox +// 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 diff --git a/types/twit/twit-tests.ts b/types/twit/twit-tests.ts index e346771f35..c74f5d6855 100644 --- a/types/twit/twit-tests.ts +++ b/types/twit/twit-tests.ts @@ -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) +})