From b34953791ce3fcae9a0a3ebe10f7bebf0d49dd32 Mon Sep 17 00:00:00 2001 From: Bobby Powers Date: Fri, 25 Sep 2015 16:08:16 -0400 Subject: [PATCH] node: WritableStream.write() should use a union for Buffer|string I'm converting a node program I originally wrote in JS to TS, and without this, the following pattern causes tsc to error out (tested under 1.6): ``` let buf = current.read(); // current is a ReadableStream if (buf !== null) output.write(buf); ``` With: ``` src/bin/cat.ts(28,17): error TS2345: Argument of type 'string | Buffer' is not assignable to parameter of type 'string'. ``` --- node/node.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index 2dfa0fc2b8..140a72c748 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -193,8 +193,7 @@ declare module NodeJS { export interface WritableStream extends EventEmitter { writable: boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; + write(buffer: Buffer|string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; end(): void; end(buffer: Buffer, cb?: Function): void;