fix: mistyping of stream (#4400)

This commit is contained in:
monotykamary 2021-03-27 00:54:24 +07:00 committed by GitHub
parent c2b558e79b
commit 767f32e6c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

3
types/index.d.ts vendored
View File

@ -1737,13 +1737,12 @@ export declare namespace Knex {
connection(connection: any): this;
debug(enabled: boolean): this;
transacting(trx: Transaction): this;
stream(): AsyncIterable<ArrayMember<T>>;
stream(handler: (readable: stream.PassThrough) => any): Promise<any>;
stream(
options: Readonly<{ [key: string]: any }>,
handler: (readable: stream.PassThrough) => any
): Promise<any>;
stream(options?: Readonly<{ [key: string]: any }>): stream.PassThrough;
stream(options?: Readonly<{ [key: string]: any }>): stream.PassThrough & AsyncIterable<ArrayMember<T>>;
pipe<T extends NodeJS.WritableStream>(
writable: T,
options?: Readonly<{ [key: string]: any }>

View File

@ -1,4 +1,5 @@
import { knex, Knex } from 'knex';
import { PassThrough } from 'stream';
////////////////////////////////////////////////////////////////////////////////////////
// //
@ -132,9 +133,12 @@ const main = async () => {
[ null ]
);
// $ExpectType AsyncIterable<User>
// $ExpectType PassThrough & AsyncIterable<User>
knexInstance<User>('users').select('*').stream();
// $ExpectType PassThrough
knexInstance<User>('users').select('*').stream().pipe(new PassThrough());
// $ExpectType User[]
await knexInstance<User>('user').where('name', ['a', 'b', 'c']);