Skip to content

Commit

Permalink
Merge pull request #428 from form-data/feat/add-typings
Browse files Browse the repository at this point in the history
feat(typings): migrate TS typings #427
  • Loading branch information
mapleeit committed Jun 24, 2019
2 parents 87751e0 + a3c0142 commit 0fb2f57
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintignore
@@ -1 +1,2 @@
node_modules/*
index.d.ts
2 changes: 1 addition & 1 deletion .eslintrc
Expand Up @@ -35,7 +35,7 @@
"semi-spacing": 0,
"no-multi-spaces": 0,
"eqeqeq": 0,
"no-mixed-requires": 0,
"no-mixed-requires": 0
},
"env": {
"node": true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,6 +9,7 @@

sftp-config.json
yarn.lock
package-lock.json

coverage/
node_modules/
Expand Down
42 changes: 42 additions & 0 deletions index.d.ts
@@ -0,0 +1,42 @@
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
// Leon Yu <https://github.com/leonyu>
// BendingBender <https://github.com/BendingBender>
// Maple Miao <https://github.com/mapleeit>

/// <reference types="node" />
import * as stream from 'stream';
import * as http from 'http';

export = FormData;

declare class FormData extends stream.Readable {
append(key: string, value: any, options?: FormData.AppendOptions | string): void;
getHeaders(): FormData.Headers;
submit(
params: string | FormData.SubmitOptions,
callback?: (error: Error | undefined, response: http.IncomingMessage) => void
): http.ClientRequest;
getBuffer(): Buffer;
getBoundary(): string;
getLength(callback: (err: Error | undefined, length: number) => void): void;
getLengthSync(): number;
hasKnownLength(): boolean;
}

declare namespace FormData {
interface Headers {
[key: string]: any;
}

interface AppendOptions {
header?: string | Headers;
knownLength?: number;
filename?: string;
filepath?: string;
contentType?: string;
}

interface SubmitOptions extends http.RequestOptions {
protocol?: 'https:' | 'http:';
}
}
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -9,6 +9,7 @@
},
"main": "./lib/form_data",
"browser": "./lib/browser",
"typings": "./index.d.ts",
"scripts": {
"pretest": "rimraf coverage test/tmp",
"test": "istanbul cover test/run.js",
Expand Down Expand Up @@ -37,6 +38,7 @@
"node": ">= 0.12"
},
"dependencies": {
"@types/node": "^12.0.8",
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
Expand All @@ -59,7 +61,8 @@
"pre-commit": "^1.1.3",
"request": "2.76.0",
"rimraf": "^2.5.4",
"tape": "^4.6.2"
"tape": "^4.6.2",
"typescript": "^3.5.2"
},
"license": "MIT"
}

0 comments on commit 0fb2f57

Please sign in to comment.