mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
Better typings for mime module; Fix mime tests
This commit is contained in:
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import { TypeMap } from "./index";
|
||||
|
||||
export default class Mime {
|
||||
constructor(mimes: TypeMap);
|
||||
|
||||
getType(path: string): string | null;
|
||||
getExtension(mime: string): string | null;
|
||||
define(mimes: TypeMap, force?: boolean): void;
|
||||
}
|
||||
Vendored
+4
-9
@@ -7,15 +7,10 @@
|
||||
|
||||
export as namespace mime;
|
||||
|
||||
export function getType(path: string): string;
|
||||
export function getExtension(mime: string): string;
|
||||
export function define(mimes: { [key: string]: string[] }, force?: boolean): void;
|
||||
export interface TypeMap { [key: string]: string[]; }
|
||||
|
||||
export interface Charsets {
|
||||
getType(path: string): string;
|
||||
getExtension(mime: string): string;
|
||||
define(mimes: { [key: string]: string[] }, force?: boolean): void;
|
||||
}
|
||||
export function getType(path: string): string | null;
|
||||
export function getExtension(mime: string): string | null;
|
||||
export function define(mimes: TypeMap, force?: boolean): void;
|
||||
|
||||
export const charsets: Charsets;
|
||||
export const default_type: string;
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
import * as mime from "mime";
|
||||
import Mime from "mime/Mime";
|
||||
|
||||
let str: string;
|
||||
const obj: {} = {};
|
||||
const fallback = '';
|
||||
let strOrNul: string | null;
|
||||
|
||||
const obj = {
|
||||
mime: ["ext", "ext2"]
|
||||
};
|
||||
|
||||
const obj2 = {
|
||||
"text/plain": ["txt"]
|
||||
};
|
||||
|
||||
str = mime.lookup(str, fallback);
|
||||
str = mime.extension(str);
|
||||
mime.load(str);
|
||||
mime.define(obj);
|
||||
mime.define(obj2, true);
|
||||
strOrNul = mime.getType("ext");
|
||||
strOrNul = mime.getType("foo");
|
||||
strOrNul = mime.getExtension("mime");
|
||||
strOrNul = mime.getExtension("bar");
|
||||
|
||||
str = mime.charsets.lookup(str);
|
||||
const myMime = new Mime(obj);
|
||||
strOrNul = myMime.getType("foo");
|
||||
strOrNul = myMime.getExtension('text/plan');
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -17,6 +17,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"Mime.d.ts",
|
||||
"mime-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user