From edfee9d9ee967be4f9d69d8293431e2d8a556ac2 Mon Sep 17 00:00:00 2001 From: Stefan Reichel Date: Thu, 8 Dec 2016 23:15:16 +0100 Subject: [PATCH] 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 --- .../content-disposition-tests.ts | 10 ++++++++ content-disposition/index.d.ts | 24 +++++++++++++++++++ content-disposition/tsconfig.json | 19 +++++++++++++++ content-disposition/tslint.json | 1 + 4 files changed, 54 insertions(+) create mode 100644 content-disposition/content-disposition-tests.ts create mode 100644 content-disposition/index.d.ts create mode 100644 content-disposition/tsconfig.json create mode 100644 content-disposition/tslint.json diff --git a/content-disposition/content-disposition-tests.ts b/content-disposition/content-disposition-tests.ts new file mode 100644 index 0000000000..4c4125fa2a --- /dev/null +++ b/content-disposition/content-disposition-tests.ts @@ -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; diff --git a/content-disposition/index.d.ts b/content-disposition/index.d.ts new file mode 100644 index 0000000000..56ea66f8ca --- /dev/null +++ b/content-disposition/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for content-disposition 0.5 +// Project: https://github.com/jshttp/content-disposition +// Definitions by: Stefan Reichel +// 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; diff --git a/content-disposition/tsconfig.json b/content-disposition/tsconfig.json new file mode 100644 index 0000000000..179228e4d6 --- /dev/null +++ b/content-disposition/tsconfig.json @@ -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" + ] +} diff --git a/content-disposition/tslint.json b/content-disposition/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/content-disposition/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }