Added declarations for content-disposition (#13191)

* Added declarations for content-disposition

* Fixed missing semicolon

* Added empty function

* Made ContentDisposition an interface instead of a class

* Filename may be undefined but not void
This commit is contained in:
Stefan Reichel 2016-12-08 23:15:16 +01:00 committed by Andy
parent f599b18306
commit edfee9d9ee
4 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,10 @@
import contentDisposition = require("content-disposition");
const noParams = contentDisposition();
const withFilenameNoOptions = contentDisposition("EURO rates.txt");
const withFilenameAndOptions = contentDisposition("€ rates.txt", { type: "attachment", fallback: "EURO rates.txt" });
const noFilename = contentDisposition(undefined, { type: "attachment", fallback: true });
const res = contentDisposition.parse('attachment; filename="EURO rates.txt"');
const type = res.type;
const parameters = res.parameters;

24
content-disposition/index.d.ts vendored Normal file
View File

@ -0,0 +1,24 @@
// Type definitions for content-disposition 0.5
// Project: https://github.com/jshttp/content-disposition
// Definitions by: Stefan Reichel <https://github.com/bomret>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace contentDisposition {
export interface ContentDisposition {
type: string;
parameters: any;
}
export interface Options {
type?: string;
fallback?: string | boolean;
}
export function parse(contentDispositionHeader: string): ContentDisposition;
}
declare function contentDisposition(): string;
declare function contentDisposition(filename: undefined, options: contentDisposition.Options): string;
declare function contentDisposition(filename: string, options?: contentDisposition.Options): string;
export = contentDisposition;

View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"content-disposition-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "../tslint.json" }