Created
January 5, 2022 22:05
-
-
Save peterblazejewicz/a485fcddb9b732fc356abe25af6ee290 to your computer and use it in GitHub Desktop.
0001-pr-review.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From df02cbd00bebd0b2ae77302c35ffe8fef47a7343 Mon Sep 17 00:00:00 2001 | |
From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz?= | |
<peterblazejewicz@users.noreply.github.com> | |
Date: Wed, 5 Jan 2022 22:57:18 +0100 | |
Subject: [PATCH] pr review | |
--- | |
types/async-busboy/async-busboy-tests.ts | 2 +- | |
types/async-busboy/tsconfig.json | 5 + | |
types/busboy/busboy-tests.ts | 369 ++++++++++------------- | |
types/busboy/index.d.ts | 182 ++++++----- | |
types/busboy/v0/busboy-tests.ts | 261 ++++++++++++++++ | |
types/busboy/v0/index.d.ts | 164 ++++++++++ | |
types/busboy/v0/tsconfig.json | 28 ++ | |
types/busboy/v0/tslint.json | 3 + | |
types/connect-busboy/index.d.ts | 10 +- | |
types/express-fileupload/tsconfig.json | 5 + | |
types/koa-joi-router/index.d.ts | 8 +- | |
types/multy/index.d.ts | 13 +- | |
types/multy/tsconfig.json | 5 + | |
13 files changed, 755 insertions(+), 300 deletions(-) | |
create mode 100644 types/busboy/v0/busboy-tests.ts | |
create mode 100644 types/busboy/v0/index.d.ts | |
create mode 100644 types/busboy/v0/tsconfig.json | |
create mode 100644 types/busboy/v0/tslint.json | |
diff --git a/types/async-busboy/async-busboy-tests.ts b/types/async-busboy/async-busboy-tests.ts | |
index f053e9f229..e625640542 100644 | |
--- a/types/async-busboy/async-busboy-tests.ts | |
+++ b/types/async-busboy/async-busboy-tests.ts | |
@@ -8,7 +8,7 @@ type Result = asyncBusboy.Result; | |
type OnFileResult = asyncBusboy.OnFileResult; | |
type FileReadStream = asyncBusboy.FileReadStream; | |
-const req = null as any as IncomingMessage; | |
+declare const req: IncomingMessage; | |
const resultPromise = asyncBusboy(req); // $ExpectType Promise<Result> | |
asyncBusboy(req, {}); // $ExpectType Promise<Result> | |
diff --git a/types/async-busboy/tsconfig.json b/types/async-busboy/tsconfig.json | |
index 6dbcd063c5..3cd1d2601b 100644 | |
--- a/types/async-busboy/tsconfig.json | |
+++ b/types/async-busboy/tsconfig.json | |
@@ -12,6 +12,11 @@ | |
"typeRoots": [ | |
"../" | |
], | |
+ "paths": { | |
+ "busboy": [ | |
+ "busboy/v0" | |
+ ] | |
+ }, | |
"types": [], | |
"noEmit": true, | |
"forceConsistentCasingInFileNames": true | |
diff --git a/types/busboy/busboy-tests.ts b/types/busboy/busboy-tests.ts | |
index 2cb299f0ef..56f8e41cca 100644 | |
--- a/types/busboy/busboy-tests.ts | |
+++ b/types/busboy/busboy-tests.ts | |
@@ -1,261 +1,222 @@ | |
-import Busboy = require('busboy'); | |
+import busboy = require('busboy'); | |
-// test type exports | |
-type Constructor = Busboy.BusboyConstructor; | |
-type Config = Busboy.BusboyConfig; | |
-type Headers = Busboy.BusboyHeaders; | |
-type BB = Busboy.Busboy; | |
-type Events = Busboy.BusboyEvents; | |
- | |
-new Busboy({}); // $ExpectError | |
-const busboy = Busboy({ headers: { 'content-type': 'foo' } }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' } }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, highWaterMark: 1000 }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, fileHwm: 1000 }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, defCharset: 'utf8' }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, preservePath: true }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, limits: { fieldNameSize: 200 } }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, limits: { fieldSize: 200 } }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, limits: { fields: 200 } }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, limits: { fileSize: 200 } }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, limits: { files: 200 } }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, limits: { parts: 200 } }); // $ExpectType Busboy | |
-new Busboy({ headers: { 'content-type': 'foo' }, limits: { headerPairs: 200 } }); // $ExpectType Busboy | |
+// $ExpectType Busboy | |
+const bb = busboy({ | |
+ headers: { 'content-type': 'foo' }, | |
+ highWaterMark: 1000, | |
+ fileHwm: 1000, | |
+ defCharset: 'utf8', | |
+ preservePath: true, | |
+ limits: { | |
+ fieldNameSize: 200, | |
+ fieldSize: 200, | |
+ fields: 200, | |
+ fileSize: 200, | |
+ files: 200, | |
+ parts: 200, | |
+ headerPairs: 200, | |
+ }, | |
+}); | |
-busboy.addListener('file', (fieldname, file, filename, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- file; // $ExpectType Readable | |
- filename; // $ExpectType string | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.addListener('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- val; // $ExpectType string | |
- fieldnameTruncated; // $ExpectType boolean | |
- valTruncated; // $ExpectType boolean | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.addListener('partsLimit', () => {}); | |
-busboy.addListener('partsLimit', foo => {}); // $ExpectError | |
-busboy.addListener('filesLimit', () => {}); | |
-busboy.addListener('filesLimit', foo => {}); // $ExpectError | |
-busboy.addListener('fieldsLimit', () => {}); | |
-busboy.addListener('fieldsLimit', foo => {}); // $ExpectError | |
-busboy.addListener('error', e => { | |
+bb.addListener('file', (name, stream, info) => { | |
+ name; // $ExpectType string | |
+ stream; // $ExpectType Readable | |
+ info; // $ExpectType FileInfo | |
+}); | |
+bb.addListener('field', (name, value, info) => { | |
+ name; // $ExpectType string | |
+ value; // $ExpectType string | |
+ info; // $ExpectType FieldInfo | |
+}); | |
+bb.addListener('partsLimit', () => {}); | |
+bb.addListener('partsLimit', foo => {}); // $ExpectError | |
+bb.addListener('filesLimit', () => {}); | |
+bb.addListener('filesLimit', foo => {}); // $ExpectError | |
+bb.addListener('fieldsLimit', () => {}); | |
+bb.addListener('fieldsLimit', foo => {}); // $ExpectError | |
+bb.addListener('error', e => { | |
e; // $ExpectType unknown | |
}); | |
-busboy.addListener('finish', () => {}); | |
-busboy.addListener('finish', foo => {}); // $ExpectError | |
+bb.addListener('close', () => {}); | |
+bb.addListener('close', foo => {}); // $ExpectError | |
// test fallback | |
-busboy.on('foo', foo => { | |
+bb.on('foo', foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.on(Symbol('foo'), foo => { | |
+bb.on(Symbol('foo'), foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.on('file', (fieldname, file, filename, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- file; // $ExpectType Readable | |
- filename; // $ExpectType string | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.on('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- val; // $ExpectType string | |
- fieldnameTruncated; // $ExpectType boolean | |
- valTruncated; // $ExpectType boolean | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.on('partsLimit', () => {}); | |
-busboy.on('partsLimit', foo => {}); // $ExpectError | |
-busboy.on('filesLimit', () => {}); | |
-busboy.on('filesLimit', foo => {}); // $ExpectError | |
-busboy.on('fieldsLimit', () => {}); | |
-busboy.on('fieldsLimit', foo => {}); // $ExpectError | |
-busboy.on('error', e => { | |
+bb.on('file', (name, stream, info) => { | |
+ name; // $ExpectType string | |
+ stream; // $ExpectType Readable | |
+ info; // $ExpectType FileInfo | |
+}); | |
+bb.on('field', (name, value, info) => { | |
+ name; // $ExpectType string | |
+ value; // $ExpectType string | |
+ info; // $ExpectType FieldInfo | |
+}); | |
+bb.on('partsLimit', () => {}); | |
+bb.on('partsLimit', foo => {}); // $ExpectError | |
+bb.on('filesLimit', () => {}); | |
+bb.on('filesLimit', foo => {}); // $ExpectError | |
+bb.on('fieldsLimit', () => {}); | |
+bb.on('fieldsLimit', foo => {}); // $ExpectError | |
+bb.on('error', e => { | |
e; // $ExpectType unknown | |
}); | |
-busboy.on('finish', () => {}); | |
-busboy.on('finish', foo => {}); // $ExpectError | |
+bb.on('close', () => {}); | |
+bb.on('close', foo => {}); // $ExpectError | |
// test fallback | |
-busboy.on('foo', foo => { | |
+bb.on('foo', foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.on(Symbol('foo'), foo => { | |
+bb.on(Symbol('foo'), foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.once('file', (fieldname, file, filename, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- file; // $ExpectType Readable | |
- filename; // $ExpectType string | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.once('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- val; // $ExpectType string | |
- fieldnameTruncated; // $ExpectType boolean | |
- valTruncated; // $ExpectType boolean | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.once('partsLimit', () => {}); | |
-busboy.once('partsLimit', foo => {}); // $ExpectError | |
-busboy.once('filesLimit', () => {}); | |
-busboy.once('filesLimit', foo => {}); // $ExpectError | |
-busboy.once('fieldsLimit', () => {}); | |
-busboy.once('fieldsLimit', foo => {}); // $ExpectError | |
-busboy.once('error', e => { | |
+bb.once('file', (name, stream, info) => { | |
+ name; // $ExpectType string | |
+ stream; // $ExpectType Readable | |
+ info; // $ExpectType FileInfo | |
+}); | |
+bb.once('field', (name, value, info) => { | |
+ name; // $ExpectType string | |
+ value; // $ExpectType string | |
+ info; // $ExpectType FieldInfo | |
+}); | |
+bb.once('partsLimit', () => {}); | |
+bb.once('partsLimit', foo => {}); // $ExpectError | |
+bb.once('filesLimit', () => {}); | |
+bb.once('filesLimit', foo => {}); // $ExpectError | |
+bb.once('fieldsLimit', () => {}); | |
+bb.once('fieldsLimit', foo => {}); // $ExpectError | |
+bb.once('error', e => { | |
e; // $ExpectType unknown | |
}); | |
-busboy.once('finish', () => {}); | |
-busboy.once('finish', foo => {}); // $ExpectError | |
+bb.once('close', () => {}); | |
+bb.once('close', foo => {}); // $ExpectError | |
// test fallback | |
-busboy.once('foo', foo => { | |
+bb.once('foo', foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.once(Symbol('foo'), foo => { | |
+bb.once(Symbol('foo'), foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.removeListener('file', (fieldname, file, filename, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- file; // $ExpectType Readable | |
- filename; // $ExpectType string | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.removeListener('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- val; // $ExpectType string | |
- fieldnameTruncated; // $ExpectType boolean | |
- valTruncated; // $ExpectType boolean | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.removeListener('partsLimit', () => {}); | |
-busboy.removeListener('partsLimit', foo => {}); // $ExpectError | |
-busboy.removeListener('filesLimit', () => {}); | |
-busboy.removeListener('filesLimit', foo => {}); // $ExpectError | |
-busboy.removeListener('fieldsLimit', () => {}); | |
-busboy.removeListener('fieldsLimit', foo => {}); // $ExpectError | |
-busboy.removeListener('error', e => { | |
+bb.removeListener('file', (name, stream, info) => { | |
+ name; // $ExpectType string | |
+ stream; // $ExpectType Readable | |
+ info; // $ExpectType FileInfo | |
+}); | |
+bb.removeListener('field', (name, value, info) => { | |
+ name; // $ExpectType string | |
+ value; // $ExpectType string | |
+ info; // $ExpectType FieldInfo | |
+}); | |
+bb.removeListener('partsLimit', () => {}); | |
+bb.removeListener('partsLimit', foo => {}); // $ExpectError | |
+bb.removeListener('filesLimit', () => {}); | |
+bb.removeListener('filesLimit', foo => {}); // $ExpectError | |
+bb.removeListener('fieldsLimit', () => {}); | |
+bb.removeListener('fieldsLimit', foo => {}); // $ExpectError | |
+bb.removeListener('error', e => { | |
e; // $ExpectType unknown | |
}); | |
-busboy.removeListener('finish', () => {}); | |
-busboy.removeListener('finish', foo => {}); // $ExpectError | |
+bb.removeListener('close', () => {}); | |
+bb.removeListener('close', foo => {}); // $ExpectError | |
// test fallback | |
-busboy.removeListener('foo', foo => { | |
+bb.removeListener('foo', foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.removeListener(Symbol('foo'), foo => { | |
+bb.removeListener(Symbol('foo'), foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.off('file', (fieldname, file, filename, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- file; // $ExpectType Readable | |
- filename; // $ExpectType string | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.off('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- val; // $ExpectType string | |
- fieldnameTruncated; // $ExpectType boolean | |
- valTruncated; // $ExpectType boolean | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.off('partsLimit', () => {}); | |
-busboy.off('partsLimit', foo => {}); // $ExpectError | |
-busboy.off('filesLimit', () => {}); | |
-busboy.off('filesLimit', foo => {}); // $ExpectError | |
-busboy.off('fieldsLimit', () => {}); | |
-busboy.off('fieldsLimit', foo => {}); // $ExpectError | |
-busboy.off('error', e => { | |
+bb.off('file', (name, stream, info) => { | |
+ name; // $ExpectType string | |
+ stream; // $ExpectType Readable | |
+ info; // $ExpectType FileInfo | |
+}); | |
+bb.off('field', (name, value, info) => { | |
+ name; // $ExpectType string | |
+ value; // $ExpectType string | |
+ info; // $ExpectType FieldInfo | |
+}); | |
+bb.off('partsLimit', () => {}); | |
+bb.off('partsLimit', foo => {}); // $ExpectError | |
+bb.off('filesLimit', () => {}); | |
+bb.off('filesLimit', foo => {}); // $ExpectError | |
+bb.off('fieldsLimit', () => {}); | |
+bb.off('fieldsLimit', foo => {}); // $ExpectError | |
+bb.off('error', e => { | |
e; // $ExpectType unknown | |
}); | |
-busboy.off('finish', () => {}); | |
-busboy.off('finish', foo => {}); // $ExpectError | |
+bb.off('close', () => {}); | |
+bb.off('close', foo => {}); // $ExpectError | |
// test fallback | |
-busboy.off('foo', foo => { | |
+bb.off('foo', foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.off(Symbol('foo'), foo => { | |
+bb.off(Symbol('foo'), foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.prependListener('file', (fieldname, file, filename, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- file; // $ExpectType Readable | |
- filename; // $ExpectType string | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.prependListener('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- val; // $ExpectType string | |
- fieldnameTruncated; // $ExpectType boolean | |
- valTruncated; // $ExpectType boolean | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.prependListener('partsLimit', () => {}); | |
-busboy.prependListener('partsLimit', foo => {}); // $ExpectError | |
-busboy.prependListener('filesLimit', () => {}); | |
-busboy.prependListener('filesLimit', foo => {}); // $ExpectError | |
-busboy.prependListener('fieldsLimit', () => {}); | |
-busboy.prependListener('fieldsLimit', foo => {}); // $ExpectError | |
-busboy.prependListener('error', e => { | |
+bb.prependListener('file', (name, stream, info) => { | |
+ name; // $ExpectType string | |
+ stream; // $ExpectType Readable | |
+ info; // $ExpectType FileInfo | |
+}); | |
+bb.prependListener('field', (name, value, info) => { | |
+ name; // $ExpectType string | |
+ value; // $ExpectType string | |
+ info; // $ExpectType FieldInfo | |
+}); | |
+bb.prependListener('partsLimit', () => {}); | |
+bb.prependListener('partsLimit', foo => {}); // $ExpectError | |
+bb.prependListener('filesLimit', () => {}); | |
+bb.prependListener('filesLimit', foo => {}); // $ExpectError | |
+bb.prependListener('fieldsLimit', () => {}); | |
+bb.prependListener('fieldsLimit', foo => {}); // $ExpectError | |
+bb.prependListener('error', e => { | |
e; // $ExpectType unknown | |
}); | |
-busboy.prependListener('finish', () => {}); | |
-busboy.prependListener('finish', foo => {}); // $ExpectError | |
+bb.prependListener('close', () => {}); | |
+bb.prependListener('close', foo => {}); // $ExpectError | |
// test fallback | |
-busboy.prependListener('foo', foo => { | |
+bb.prependListener('foo', foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.prependListener(Symbol('foo'), foo => { | |
+bb.prependListener(Symbol('foo'), foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.prependOnceListener('file', (fieldname, file, filename, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- file; // $ExpectType Readable | |
- filename; // $ExpectType string | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.prependOnceListener('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
- fieldname; // $ExpectType string | |
- val; // $ExpectType string | |
- fieldnameTruncated; // $ExpectType boolean | |
- valTruncated; // $ExpectType boolean | |
- encoding; // $ExpectType string | |
- mimetype; // $ExpectType string | |
-}); | |
-busboy.prependOnceListener('partsLimit', () => {}); | |
-busboy.prependOnceListener('partsLimit', foo => {}); // $ExpectError | |
-busboy.prependOnceListener('filesLimit', () => {}); | |
-busboy.prependOnceListener('filesLimit', foo => {}); // $ExpectError | |
-busboy.prependOnceListener('fieldsLimit', () => {}); | |
-busboy.prependOnceListener('fieldsLimit', foo => {}); // $ExpectError | |
-busboy.prependOnceListener('error', e => { | |
+bb.prependOnceListener('file', (name, stream, info) => { | |
+ name; // $ExpectType string | |
+ stream; // $ExpectType Readable | |
+ info; // $ExpectType FileInfo | |
+}); | |
+bb.prependOnceListener('field', (name, value, info) => { | |
+ name; // $ExpectType string | |
+ value; // $ExpectType string | |
+ info; // $ExpectType FieldInfo | |
+}); | |
+bb.prependOnceListener('partsLimit', () => {}); | |
+bb.prependOnceListener('partsLimit', foo => {}); // $ExpectError | |
+bb.prependOnceListener('filesLimit', () => {}); | |
+bb.prependOnceListener('filesLimit', foo => {}); // $ExpectError | |
+bb.prependOnceListener('fieldsLimit', () => {}); | |
+bb.prependOnceListener('fieldsLimit', foo => {}); // $ExpectError | |
+bb.prependOnceListener('error', e => { | |
e; // $ExpectType unknown | |
}); | |
-busboy.prependOnceListener('finish', () => {}); | |
-busboy.prependOnceListener('finish', foo => {}); // $ExpectError | |
+bb.prependOnceListener('close', () => {}); | |
+bb.prependOnceListener('close', foo => {}); // $ExpectError | |
// test fallback | |
-busboy.prependOnceListener('foo', foo => { | |
+bb.prependOnceListener('foo', foo => { | |
foo; // $ExpectType any | |
}); | |
-busboy.prependOnceListener(Symbol('foo'), foo => { | |
+bb.prependOnceListener(Symbol('foo'), foo => { | |
foo; // $ExpectType any | |
}); | |
diff --git a/types/busboy/index.d.ts b/types/busboy/index.d.ts | |
index eeddcb8229..c6d3d33e2d 100644 | |
--- a/types/busboy/index.d.ts | |
+++ b/types/busboy/index.d.ts | |
@@ -1,90 +1,107 @@ | |
-// Type definitions for busboy 0.3 | |
-// Project: https://www.npmjs.com/package/busboy | |
+// Type definitions for busboy 1.3 | |
+// Project: https://github.com/mscdex/busboy | |
// Definitions by: Jacob Baskin <https://github.com/jacobbaskin> | |
// BendingBender <https://github.com/BendingBender> | |
+// Martin Badin <https://github.com/martin-badin> | |
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | |
/// <reference types="node" /> | |
-import * as http from 'http'; | |
+import { IncomingHttpHeaders } from 'http'; | |
import { Readable, Writable } from 'stream'; | |
-export = busboy; | |
+declare namespace busboy { | |
+ interface Limits { | |
+ /** | |
+ * Max field name size (in bytes). | |
+ * | |
+ * @default 100 | |
+ */ | |
+ fieldNameSize?: number | undefined; | |
+ | |
+ /** | |
+ * Max field value size (in bytes). | |
+ * | |
+ * @default 1048576 (1MB) | |
+ */ | |
+ fieldSize?: number | undefined; | |
-declare const busboy: busboy.BusboyConstructor; | |
+ /** | |
+ * Max number of non-file fields. | |
+ * | |
+ * @default Infinity | |
+ */ | |
+ fields?: number | undefined; | |
+ | |
+ /** | |
+ * For multipart forms, the max file size (in bytes). | |
+ * | |
+ * @default Infinity | |
+ */ | |
+ fileSize?: number | undefined; | |
+ | |
+ /** | |
+ * For multipart forms, the max number of file fields. | |
+ * | |
+ * @default Infinity | |
+ */ | |
+ files?: number | undefined; | |
+ | |
+ /** | |
+ * For multipart forms, the max number of parts (fields + files). | |
+ * | |
+ * @default Infinity | |
+ */ | |
+ parts?: number | undefined; | |
+ | |
+ /** | |
+ * For multipart forms, the max number of header key-value pairs to parse. | |
+ * | |
+ * @default 2000 (same as node's http module) | |
+ */ | |
+ headerPairs?: number | undefined; | |
+ } | |
-declare namespace busboy { | |
interface BusboyConfig { | |
/** | |
* These are the HTTP headers of the incoming request, which are used by individual parsers. | |
*/ | |
- headers: BusboyHeaders; | |
+ headers?: IncomingHttpHeaders | undefined; | |
+ | |
/** | |
- * `highWaterMark` to use for this Busboy instance. | |
- * @default WritableStream default. | |
+ * 'highWaterMark' to use for the parser stream | |
+ * | |
+ * @default stream.Writable | |
*/ | |
highWaterMark?: number | undefined; | |
+ | |
/** | |
- * highWaterMark to use for file streams. | |
- * @default ReadableStream default. | |
+ * 'highWaterMark' to use for individual file streams | |
+ * | |
+ * @default stream.Readable | |
*/ | |
fileHwm?: number | undefined; | |
+ | |
/** | |
* Default character set to use when one isn't defined. | |
+ * | |
* @default 'utf8' | |
*/ | |
defCharset?: string | undefined; | |
+ | |
/** | |
- * If paths in the multipart 'filename' field shall be preserved. | |
+ * If paths in filenames from file parts in a 'multipart/form-data' request shall be preserved. | |
+ * | |
* @default false | |
*/ | |
preservePath?: boolean | undefined; | |
+ | |
/** | |
* Various limits on incoming data. | |
*/ | |
- limits?: | |
- | { | |
- /** | |
- * Max field name size (in bytes) | |
- * @default 100 bytes | |
- */ | |
- fieldNameSize?: number | undefined; | |
- /** | |
- * Max field value size (in bytes) | |
- * @default 1MB | |
- */ | |
- fieldSize?: number | undefined; | |
- /** | |
- * Max number of non-file fields | |
- * @default Infinity | |
- */ | |
- fields?: number | undefined; | |
- /** | |
- * For multipart forms, the max file size (in bytes) | |
- * @default Infinity | |
- */ | |
- fileSize?: number | undefined; | |
- /** | |
- * For multipart forms, the max number of file fields | |
- * @default Infinity | |
- */ | |
- files?: number | undefined; | |
- /** | |
- * For multipart forms, the max number of parts (fields + files) | |
- * @default Infinity | |
- */ | |
- parts?: number | undefined; | |
- /** | |
- * For multipart forms, the max number of header key=>value pairs to parse | |
- * @default 2000 (same as node's http) | |
- */ | |
- headerPairs?: number | undefined; | |
- } | |
- | undefined; | |
+ limits?: Limits | undefined; | |
} | |
- type BusboyHeaders = { 'content-type': string } & http.IncomingHttpHeaders; | |
- | |
interface Busboy extends Writable { | |
addListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this; | |
addListener(event: string | symbol, listener: (...args: any[]) => void): this; | |
@@ -108,6 +125,20 @@ declare namespace busboy { | |
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; | |
} | |
+ interface Info { | |
+ encoding: string; | |
+ mimeType: string; | |
+ } | |
+ | |
+ interface FileInfo extends Info { | |
+ filename: string; | |
+ } | |
+ | |
+ interface FieldInfo extends Info { | |
+ nameTruncated: boolean; | |
+ valueTruncated: boolean; | |
+ } | |
+ | |
interface BusboyEvents { | |
/** | |
* Emitted for each new file form field found. | |
@@ -123,42 +154,45 @@ declare namespace busboy { | |
* @param listener.transferEncoding Contains the 'Content-Transfer-Encoding' value for the file stream. | |
* @param listener.mimeType Contains the 'Content-Type' value for the file stream. | |
*/ | |
- file: ( | |
- fieldname: string, | |
- stream: Readable, | |
- filename: string, | |
- transferEncoding: string, | |
- mimeType: string, | |
- ) => void; | |
+ file: (name: string, stream: Readable, info: FileInfo) => void; | |
+ | |
/** | |
* Emitted for each new non-file field found. | |
*/ | |
- field: ( | |
- fieldname: string, | |
- value: string, | |
- fieldnameTruncated: boolean, | |
- valueTruncated: boolean, | |
- transferEncoding: string, | |
- mimeType: string, | |
- ) => void; | |
- finish: () => void; | |
+ field: (name: string, value: string, info: FieldInfo) => void; | |
+ | |
/** | |
* Emitted when specified `parts` limit has been reached. No more 'file' or 'field' events will be emitted. | |
*/ | |
partsLimit: () => void; | |
+ | |
/** | |
- * Emitted when specified `files` limit has been reached. No more 'file' events will be emitted. | |
+ * Emitted when specified `files` limit has been reached. No more 'file' events will be emitted. | |
*/ | |
filesLimit: () => void; | |
+ | |
/** | |
* Emitted when specified `fields` limit has been reached. No more 'field' events will be emitted. | |
*/ | |
fieldsLimit: () => void; | |
+ | |
error: (error: unknown) => void; | |
- } | |
- interface BusboyConstructor { | |
- (options: BusboyConfig): Busboy; | |
- new (options: BusboyConfig): Busboy; | |
+ /** | |
+ * @deprecated | |
+ * @since 1.0 | |
+ */ | |
+ finish: () => void; | |
+ | |
+ /** | |
+ * Use 'close' event instead of 'finish' event when you need to execute | |
+ * | |
+ * @since 1.0 | |
+ */ | |
+ close: () => void; | |
} | |
} | |
+ | |
+declare function busboy(config: busboy.BusboyConfig): busboy.Busboy; | |
+ | |
+export = busboy; | |
diff --git a/types/busboy/v0/busboy-tests.ts b/types/busboy/v0/busboy-tests.ts | |
new file mode 100644 | |
index 0000000000..2cb299f0ef | |
--- /dev/null | |
+++ b/types/busboy/v0/busboy-tests.ts | |
@@ -0,0 +1,261 @@ | |
+import Busboy = require('busboy'); | |
+ | |
+// test type exports | |
+type Constructor = Busboy.BusboyConstructor; | |
+type Config = Busboy.BusboyConfig; | |
+type Headers = Busboy.BusboyHeaders; | |
+type BB = Busboy.Busboy; | |
+type Events = Busboy.BusboyEvents; | |
+ | |
+new Busboy({}); // $ExpectError | |
+const busboy = Busboy({ headers: { 'content-type': 'foo' } }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' } }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, highWaterMark: 1000 }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, fileHwm: 1000 }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, defCharset: 'utf8' }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, preservePath: true }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, limits: { fieldNameSize: 200 } }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, limits: { fieldSize: 200 } }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, limits: { fields: 200 } }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, limits: { fileSize: 200 } }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, limits: { files: 200 } }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, limits: { parts: 200 } }); // $ExpectType Busboy | |
+new Busboy({ headers: { 'content-type': 'foo' }, limits: { headerPairs: 200 } }); // $ExpectType Busboy | |
+ | |
+busboy.addListener('file', (fieldname, file, filename, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ file; // $ExpectType Readable | |
+ filename; // $ExpectType string | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.addListener('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ val; // $ExpectType string | |
+ fieldnameTruncated; // $ExpectType boolean | |
+ valTruncated; // $ExpectType boolean | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.addListener('partsLimit', () => {}); | |
+busboy.addListener('partsLimit', foo => {}); // $ExpectError | |
+busboy.addListener('filesLimit', () => {}); | |
+busboy.addListener('filesLimit', foo => {}); // $ExpectError | |
+busboy.addListener('fieldsLimit', () => {}); | |
+busboy.addListener('fieldsLimit', foo => {}); // $ExpectError | |
+busboy.addListener('error', e => { | |
+ e; // $ExpectType unknown | |
+}); | |
+busboy.addListener('finish', () => {}); | |
+busboy.addListener('finish', foo => {}); // $ExpectError | |
+// test fallback | |
+busboy.on('foo', foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+busboy.on(Symbol('foo'), foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+ | |
+busboy.on('file', (fieldname, file, filename, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ file; // $ExpectType Readable | |
+ filename; // $ExpectType string | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.on('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ val; // $ExpectType string | |
+ fieldnameTruncated; // $ExpectType boolean | |
+ valTruncated; // $ExpectType boolean | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.on('partsLimit', () => {}); | |
+busboy.on('partsLimit', foo => {}); // $ExpectError | |
+busboy.on('filesLimit', () => {}); | |
+busboy.on('filesLimit', foo => {}); // $ExpectError | |
+busboy.on('fieldsLimit', () => {}); | |
+busboy.on('fieldsLimit', foo => {}); // $ExpectError | |
+busboy.on('error', e => { | |
+ e; // $ExpectType unknown | |
+}); | |
+busboy.on('finish', () => {}); | |
+busboy.on('finish', foo => {}); // $ExpectError | |
+// test fallback | |
+busboy.on('foo', foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+busboy.on(Symbol('foo'), foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+ | |
+busboy.once('file', (fieldname, file, filename, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ file; // $ExpectType Readable | |
+ filename; // $ExpectType string | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.once('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ val; // $ExpectType string | |
+ fieldnameTruncated; // $ExpectType boolean | |
+ valTruncated; // $ExpectType boolean | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.once('partsLimit', () => {}); | |
+busboy.once('partsLimit', foo => {}); // $ExpectError | |
+busboy.once('filesLimit', () => {}); | |
+busboy.once('filesLimit', foo => {}); // $ExpectError | |
+busboy.once('fieldsLimit', () => {}); | |
+busboy.once('fieldsLimit', foo => {}); // $ExpectError | |
+busboy.once('error', e => { | |
+ e; // $ExpectType unknown | |
+}); | |
+busboy.once('finish', () => {}); | |
+busboy.once('finish', foo => {}); // $ExpectError | |
+// test fallback | |
+busboy.once('foo', foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+busboy.once(Symbol('foo'), foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+ | |
+busboy.removeListener('file', (fieldname, file, filename, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ file; // $ExpectType Readable | |
+ filename; // $ExpectType string | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.removeListener('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ val; // $ExpectType string | |
+ fieldnameTruncated; // $ExpectType boolean | |
+ valTruncated; // $ExpectType boolean | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.removeListener('partsLimit', () => {}); | |
+busboy.removeListener('partsLimit', foo => {}); // $ExpectError | |
+busboy.removeListener('filesLimit', () => {}); | |
+busboy.removeListener('filesLimit', foo => {}); // $ExpectError | |
+busboy.removeListener('fieldsLimit', () => {}); | |
+busboy.removeListener('fieldsLimit', foo => {}); // $ExpectError | |
+busboy.removeListener('error', e => { | |
+ e; // $ExpectType unknown | |
+}); | |
+busboy.removeListener('finish', () => {}); | |
+busboy.removeListener('finish', foo => {}); // $ExpectError | |
+// test fallback | |
+busboy.removeListener('foo', foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+busboy.removeListener(Symbol('foo'), foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+ | |
+busboy.off('file', (fieldname, file, filename, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ file; // $ExpectType Readable | |
+ filename; // $ExpectType string | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.off('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ val; // $ExpectType string | |
+ fieldnameTruncated; // $ExpectType boolean | |
+ valTruncated; // $ExpectType boolean | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.off('partsLimit', () => {}); | |
+busboy.off('partsLimit', foo => {}); // $ExpectError | |
+busboy.off('filesLimit', () => {}); | |
+busboy.off('filesLimit', foo => {}); // $ExpectError | |
+busboy.off('fieldsLimit', () => {}); | |
+busboy.off('fieldsLimit', foo => {}); // $ExpectError | |
+busboy.off('error', e => { | |
+ e; // $ExpectType unknown | |
+}); | |
+busboy.off('finish', () => {}); | |
+busboy.off('finish', foo => {}); // $ExpectError | |
+// test fallback | |
+busboy.off('foo', foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+busboy.off(Symbol('foo'), foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+ | |
+busboy.prependListener('file', (fieldname, file, filename, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ file; // $ExpectType Readable | |
+ filename; // $ExpectType string | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.prependListener('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ val; // $ExpectType string | |
+ fieldnameTruncated; // $ExpectType boolean | |
+ valTruncated; // $ExpectType boolean | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.prependListener('partsLimit', () => {}); | |
+busboy.prependListener('partsLimit', foo => {}); // $ExpectError | |
+busboy.prependListener('filesLimit', () => {}); | |
+busboy.prependListener('filesLimit', foo => {}); // $ExpectError | |
+busboy.prependListener('fieldsLimit', () => {}); | |
+busboy.prependListener('fieldsLimit', foo => {}); // $ExpectError | |
+busboy.prependListener('error', e => { | |
+ e; // $ExpectType unknown | |
+}); | |
+busboy.prependListener('finish', () => {}); | |
+busboy.prependListener('finish', foo => {}); // $ExpectError | |
+// test fallback | |
+busboy.prependListener('foo', foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+busboy.prependListener(Symbol('foo'), foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+ | |
+busboy.prependOnceListener('file', (fieldname, file, filename, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ file; // $ExpectType Readable | |
+ filename; // $ExpectType string | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.prependOnceListener('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => { | |
+ fieldname; // $ExpectType string | |
+ val; // $ExpectType string | |
+ fieldnameTruncated; // $ExpectType boolean | |
+ valTruncated; // $ExpectType boolean | |
+ encoding; // $ExpectType string | |
+ mimetype; // $ExpectType string | |
+}); | |
+busboy.prependOnceListener('partsLimit', () => {}); | |
+busboy.prependOnceListener('partsLimit', foo => {}); // $ExpectError | |
+busboy.prependOnceListener('filesLimit', () => {}); | |
+busboy.prependOnceListener('filesLimit', foo => {}); // $ExpectError | |
+busboy.prependOnceListener('fieldsLimit', () => {}); | |
+busboy.prependOnceListener('fieldsLimit', foo => {}); // $ExpectError | |
+busboy.prependOnceListener('error', e => { | |
+ e; // $ExpectType unknown | |
+}); | |
+busboy.prependOnceListener('finish', () => {}); | |
+busboy.prependOnceListener('finish', foo => {}); // $ExpectError | |
+// test fallback | |
+busboy.prependOnceListener('foo', foo => { | |
+ foo; // $ExpectType any | |
+}); | |
+busboy.prependOnceListener(Symbol('foo'), foo => { | |
+ foo; // $ExpectType any | |
+}); | |
diff --git a/types/busboy/v0/index.d.ts b/types/busboy/v0/index.d.ts | |
new file mode 100644 | |
index 0000000000..eeddcb8229 | |
--- /dev/null | |
+++ b/types/busboy/v0/index.d.ts | |
@@ -0,0 +1,164 @@ | |
+// Type definitions for busboy 0.3 | |
+// Project: https://www.npmjs.com/package/busboy | |
+// Definitions by: Jacob Baskin <https://github.com/jacobbaskin> | |
+// BendingBender <https://github.com/BendingBender> | |
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | |
+ | |
+/// <reference types="node" /> | |
+ | |
+import * as http from 'http'; | |
+import { Readable, Writable } from 'stream'; | |
+ | |
+export = busboy; | |
+ | |
+declare const busboy: busboy.BusboyConstructor; | |
+ | |
+declare namespace busboy { | |
+ interface BusboyConfig { | |
+ /** | |
+ * These are the HTTP headers of the incoming request, which are used by individual parsers. | |
+ */ | |
+ headers: BusboyHeaders; | |
+ /** | |
+ * `highWaterMark` to use for this Busboy instance. | |
+ * @default WritableStream default. | |
+ */ | |
+ highWaterMark?: number | undefined; | |
+ /** | |
+ * highWaterMark to use for file streams. | |
+ * @default ReadableStream default. | |
+ */ | |
+ fileHwm?: number | undefined; | |
+ /** | |
+ * Default character set to use when one isn't defined. | |
+ * @default 'utf8' | |
+ */ | |
+ defCharset?: string | undefined; | |
+ /** | |
+ * If paths in the multipart 'filename' field shall be preserved. | |
+ * @default false | |
+ */ | |
+ preservePath?: boolean | undefined; | |
+ /** | |
+ * Various limits on incoming data. | |
+ */ | |
+ limits?: | |
+ | { | |
+ /** | |
+ * Max field name size (in bytes) | |
+ * @default 100 bytes | |
+ */ | |
+ fieldNameSize?: number | undefined; | |
+ /** | |
+ * Max field value size (in bytes) | |
+ * @default 1MB | |
+ */ | |
+ fieldSize?: number | undefined; | |
+ /** | |
+ * Max number of non-file fields | |
+ * @default Infinity | |
+ */ | |
+ fields?: number | undefined; | |
+ /** | |
+ * For multipart forms, the max file size (in bytes) | |
+ * @default Infinity | |
+ */ | |
+ fileSize?: number | undefined; | |
+ /** | |
+ * For multipart forms, the max number of file fields | |
+ * @default Infinity | |
+ */ | |
+ files?: number | undefined; | |
+ /** | |
+ * For multipart forms, the max number of parts (fields + files) | |
+ * @default Infinity | |
+ */ | |
+ parts?: number | undefined; | |
+ /** | |
+ * For multipart forms, the max number of header key=>value pairs to parse | |
+ * @default 2000 (same as node's http) | |
+ */ | |
+ headerPairs?: number | undefined; | |
+ } | |
+ | undefined; | |
+ } | |
+ | |
+ type BusboyHeaders = { 'content-type': string } & http.IncomingHttpHeaders; | |
+ | |
+ interface Busboy extends Writable { | |
+ addListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this; | |
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this; | |
+ | |
+ on<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this; | |
+ on(event: string | symbol, listener: (...args: any[]) => void): this; | |
+ | |
+ once<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this; | |
+ once(event: string | symbol, listener: (...args: any[]) => void): this; | |
+ | |
+ removeListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this; | |
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this; | |
+ | |
+ off<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this; | |
+ off(event: string | symbol, listener: (...args: any[]) => void): this; | |
+ | |
+ prependListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this; | |
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this; | |
+ | |
+ prependOnceListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this; | |
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; | |
+ } | |
+ | |
+ interface BusboyEvents { | |
+ /** | |
+ * Emitted for each new file form field found. | |
+ * | |
+ * * Note: if you listen for this event, you should always handle the `stream` no matter if you care about the | |
+ * file contents or not (e.g. you can simply just do `stream.resume();` if you want to discard the contents), | |
+ * otherwise the 'finish' event will never fire on the Busboy instance. However, if you don't care about **any** | |
+ * incoming files, you can simply not listen for the 'file' event at all and any/all files will be automatically | |
+ * and safely discarded (these discarded files do still count towards `files` and `parts` limits). | |
+ * * If a configured file size limit was reached, `stream` will both have a boolean property `truncated` | |
+ * (best checked at the end of the stream) and emit a 'limit' event to notify you when this happens. | |
+ * | |
+ * @param listener.transferEncoding Contains the 'Content-Transfer-Encoding' value for the file stream. | |
+ * @param listener.mimeType Contains the 'Content-Type' value for the file stream. | |
+ */ | |
+ file: ( | |
+ fieldname: string, | |
+ stream: Readable, | |
+ filename: string, | |
+ transferEncoding: string, | |
+ mimeType: string, | |
+ ) => void; | |
+ /** | |
+ * Emitted for each new non-file field found. | |
+ */ | |
+ field: ( | |
+ fieldname: string, | |
+ value: string, | |
+ fieldnameTruncated: boolean, | |
+ valueTruncated: boolean, | |
+ transferEncoding: string, | |
+ mimeType: string, | |
+ ) => void; | |
+ finish: () => void; | |
+ /** | |
+ * Emitted when specified `parts` limit has been reached. No more 'file' or 'field' events will be emitted. | |
+ */ | |
+ partsLimit: () => void; | |
+ /** | |
+ * Emitted when specified `files` limit has been reached. No more 'file' events will be emitted. | |
+ */ | |
+ filesLimit: () => void; | |
+ /** | |
+ * Emitted when specified `fields` limit has been reached. No more 'field' events will be emitted. | |
+ */ | |
+ fieldsLimit: () => void; | |
+ error: (error: unknown) => void; | |
+ } | |
+ | |
+ interface BusboyConstructor { | |
+ (options: BusboyConfig): Busboy; | |
+ new (options: BusboyConfig): Busboy; | |
+ } | |
+} | |
diff --git a/types/busboy/v0/tsconfig.json b/types/busboy/v0/tsconfig.json | |
new file mode 100644 | |
index 0000000000..6f88efe776 | |
--- /dev/null | |
+++ b/types/busboy/v0/tsconfig.json | |
@@ -0,0 +1,28 @@ | |
+{ | |
+ "compilerOptions": { | |
+ "module": "commonjs", | |
+ "lib": [ | |
+ "es6" | |
+ ], | |
+ "noImplicitAny": true, | |
+ "noImplicitThis": true, | |
+ "strictNullChecks": true, | |
+ "strictFunctionTypes": true, | |
+ "baseUrl": "../../", | |
+ "typeRoots": [ | |
+ "../../" | |
+ ], | |
+ "paths": { | |
+ "busboy": [ | |
+ "busboy/v0" | |
+ ] | |
+ }, | |
+ "types": [], | |
+ "noEmit": true, | |
+ "forceConsistentCasingInFileNames": true | |
+ }, | |
+ "files": [ | |
+ "index.d.ts", | |
+ "busboy-tests.ts" | |
+ ] | |
+} | |
diff --git a/types/busboy/v0/tslint.json b/types/busboy/v0/tslint.json | |
new file mode 100644 | |
index 0000000000..2efa283002 | |
--- /dev/null | |
+++ b/types/busboy/v0/tslint.json | |
@@ -0,0 +1,3 @@ | |
+{ | |
+ "extends": "@definitelytyped/dtslint/dt.json" | |
+} | |
diff --git a/types/connect-busboy/index.d.ts b/types/connect-busboy/index.d.ts | |
index fe4a61fd26..6a8d7022c3 100644 | |
--- a/types/connect-busboy/index.d.ts | |
+++ b/types/connect-busboy/index.d.ts | |
@@ -1,21 +1,19 @@ | |
-// Type definitions for connect-busboy 0.0 | |
+// Type definitions for connect-busboy 1.0 | |
// Project: https://github.com/mscdex/connect-busboy | |
// Definitions by: Pinguet62 <https://github.com/pinguet62> | |
// Chris Gedrim <https://github.com/chrisgedrim> | |
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | |
-// TypeScript Version: 2.3 | |
/// <reference types="node" /> | |
-import * as busboy from 'busboy'; | |
+import { BusboyConfig, Busboy } from 'busboy'; | |
import { RequestHandler } from 'express'; | |
import * as http from 'http'; | |
declare function connectBusboy(options?: connectBusboy.ConnectBusboyOptions): RequestHandler; | |
declare namespace connectBusboy { | |
- interface ConnectBusboyOptions extends Omit<busboy.BusboyConfig, 'headers'> { | |
- headers?: http.IncomingHttpHeaders; | |
+ interface ConnectBusboyOptions extends BusboyConfig { | |
immediate?: boolean | undefined; | |
} | |
} | |
@@ -23,7 +21,7 @@ declare namespace connectBusboy { | |
declare global { | |
namespace Express { | |
interface Request { | |
- busboy: busboy.Busboy; | |
+ busboy: Busboy; | |
} | |
} | |
} | |
diff --git a/types/express-fileupload/tsconfig.json b/types/express-fileupload/tsconfig.json | |
index 93ee9fd3cc..3a3ec5e126 100644 | |
--- a/types/express-fileupload/tsconfig.json | |
+++ b/types/express-fileupload/tsconfig.json | |
@@ -12,6 +12,11 @@ | |
"typeRoots": [ | |
"../" | |
], | |
+ "paths": { | |
+ "busboy": [ | |
+ "busboy/v0" | |
+ ] | |
+ }, | |
"types": [], | |
"noEmit": true, | |
"forceConsistentCasingInFileNames": true | |
diff --git a/types/koa-joi-router/index.d.ts b/types/koa-joi-router/index.d.ts | |
index f4516c5330..189e035b8b 100644 | |
--- a/types/koa-joi-router/index.d.ts | |
+++ b/types/koa-joi-router/index.d.ts | |
@@ -14,7 +14,7 @@ import * as Koa from 'koa'; | |
import * as Joi from 'joi'; | |
import * as KoaRouter from 'koa-router'; | |
import * as CoBody from 'co-body'; | |
-import * as busboy from 'busboy'; | |
+import { BusboyConfig } from 'busboy'; | |
import * as http from 'http'; | |
declare module 'koa' { | |
@@ -51,7 +51,7 @@ declare namespace createRouter { | |
type?: 'form' | 'json' | 'multipart' | undefined; | |
formOptions?: CoBody.Options | undefined; | |
jsonOptions?: CoBody.Options | undefined; | |
- multipartOptions?: MultipartOptions | undefined; | |
+ multipartOptions?: BusboyConfig | undefined; | |
output?: { [status: string]: OutputValidation } | undefined; | |
continueOnError?: boolean | undefined; | |
validateOptions?: Joi.ValidationOptions | undefined; | |
@@ -60,10 +60,6 @@ declare namespace createRouter { | |
meta?: any; | |
} | |
- interface MultipartOptions extends Omit<busboy.BusboyConfig, 'headers'> { | |
- headers?: http.IncomingHttpHeaders; | |
- } | |
- | |
interface Spec extends Config { | |
method: string | string[]; | |
path: string | RegExp; | |
diff --git a/types/multy/index.d.ts b/types/multy/index.d.ts | |
index ee9ee1079d..d8bfcebdcb 100644 | |
--- a/types/multy/index.d.ts | |
+++ b/types/multy/index.d.ts | |
@@ -2,21 +2,16 @@ | |
// Project: https://github.com/eduardorfs/multy | |
// Definitions by: Jan Dolezel <https://github.com/dolezel> | |
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | |
-// TypeScript Version: 2.4 | |
-import * as Koa from "koa"; | |
-import * as busboy from "busboy"; | |
+import * as Koa from 'koa'; | |
+import { BusboyConfig } from 'busboy'; | |
-declare module "koa" { | |
+declare module 'koa' { | |
interface Request { | |
body: any; | |
} | |
} | |
-declare namespace multy { | |
- type Options = busboy.BusboyConfig; | |
-} | |
- | |
-declare function multy(opts?: multy.Options): Koa.Middleware; | |
+declare function multy(opts?: BusboyConfig): Koa.Middleware; | |
export = multy; | |
diff --git a/types/multy/tsconfig.json b/types/multy/tsconfig.json | |
index 9b6ece72d9..90a7a93b6a 100644 | |
--- a/types/multy/tsconfig.json | |
+++ b/types/multy/tsconfig.json | |
@@ -13,6 +13,11 @@ | |
"typeRoots": [ | |
"../" | |
], | |
+ "paths": { | |
+ "busboy": [ | |
+ "busboy/v0" | |
+ ] | |
+ }, | |
"types": [], | |
"noEmit": true, | |
"forceConsistentCasingInFileNames": true | |
-- | |
2.31.0.windows.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment