From 6a96efd84a6dfdc6e3f2f44af8bf0d60de99d86e Mon Sep 17 00:00:00 2001 From: Adithya Reddy Date: Fri, 6 Oct 2017 23:52:29 +0530 Subject: [PATCH] Fixed incorrect type for Twit.stream (#20173) The Twit docs [specifically says](https://github.com/ttezel/twit#using-the-streaming-api) that the `stream` function returns an `EventEmitter`. It also says that the `EventEmitter` has [two methods - `start()` and `stop()`](https://github.com/ttezel/twit#streamstop) to start and stop the Twitter stream. The return type was incorrectly specified as a `NodeJS.ReadableStream`. This fixes that. --- types/twit/index.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/types/twit/index.d.ts b/types/twit/index.d.ts index c8687cc6fb..63ca3b747d 100644 --- a/types/twit/index.d.ts +++ b/types/twit/index.d.ts @@ -8,6 +8,7 @@ declare module 'twit' { import { IncomingMessage } from 'http'; + import { EventEmitter } from 'events'; namespace Twit { export type StreamEndpoint = 'statuses/filter' | 'statuses/sample' | 'statuses/firehose' | 'user' | 'site'; @@ -264,6 +265,10 @@ declare module 'twit' { timeout_ms?: number, trusted_cert_fingerprints?: string[], } + export interface Stream extends EventEmitter { + start(): void; + stop(): void; + } } class Twit { @@ -304,7 +309,7 @@ declare module 'twit' { /** * @see https://github.com/ttezel/twit#tstreampath-params */ - stream(path: Twit.StreamEndpoint, params?: Twit.Params): NodeJS.ReadableStream; + stream(path: Twit.StreamEndpoint, params?: Twit.Params): Twit.Stream; } export = Twit;