Skip to content

Commit 0fb2f57

Browse files
authored
Merge pull request #428 from form-data/feat/add-typings
feat(typings): migrate TS typings #427
2 parents 87751e0 + a3c0142 commit 0fb2f57

5 files changed

Lines changed: 49 additions & 2 deletions

File tree

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules/*
2+
index.d.ts

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"semi-spacing": 0,
3636
"no-multi-spaces": 0,
3737
"eqeqeq": 0,
38-
"no-mixed-requires": 0,
38+
"no-mixed-requires": 0
3939
},
4040
"env": {
4141
"node": true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
sftp-config.json
1111
yarn.lock
12+
package-lock.json
1213

1314
coverage/
1415
node_modules/

index.d.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
2+
// Leon Yu <https://github.com/leonyu>
3+
// BendingBender <https://github.com/BendingBender>
4+
// Maple Miao <https://github.com/mapleeit>
5+
6+
/// <reference types="node" />
7+
import * as stream from 'stream';
8+
import * as http from 'http';
9+
10+
export = FormData;
11+
12+
declare class FormData extends stream.Readable {
13+
append(key: string, value: any, options?: FormData.AppendOptions | string): void;
14+
getHeaders(): FormData.Headers;
15+
submit(
16+
params: string | FormData.SubmitOptions,
17+
callback?: (error: Error | undefined, response: http.IncomingMessage) => void
18+
): http.ClientRequest;
19+
getBuffer(): Buffer;
20+
getBoundary(): string;
21+
getLength(callback: (err: Error | undefined, length: number) => void): void;
22+
getLengthSync(): number;
23+
hasKnownLength(): boolean;
24+
}
25+
26+
declare namespace FormData {
27+
interface Headers {
28+
[key: string]: any;
29+
}
30+
31+
interface AppendOptions {
32+
header?: string | Headers;
33+
knownLength?: number;
34+
filename?: string;
35+
filepath?: string;
36+
contentType?: string;
37+
}
38+
39+
interface SubmitOptions extends http.RequestOptions {
40+
protocol?: 'https:' | 'http:';
41+
}
42+
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"main": "./lib/form_data",
1111
"browser": "./lib/browser",
12+
"typings": "./index.d.ts",
1213
"scripts": {
1314
"pretest": "rimraf coverage test/tmp",
1415
"test": "istanbul cover test/run.js",
@@ -37,6 +38,7 @@
3738
"node": ">= 0.12"
3839
},
3940
"dependencies": {
41+
"@types/node": "^12.0.8",
4042
"asynckit": "^0.4.0",
4143
"combined-stream": "^1.0.6",
4244
"mime-types": "^2.1.12"
@@ -59,7 +61,8 @@
5961
"pre-commit": "^1.1.3",
6062
"request": "2.76.0",
6163
"rimraf": "^2.5.4",
62-
"tape": "^4.6.2"
64+
"tape": "^4.6.2",
65+
"typescript": "^3.5.2"
6366
},
6467
"license": "MIT"
6568
}

0 commit comments

Comments
 (0)