[mime-db] Add exported object (#43066)

* [mime-db] Add exported object

* Use module import style
This commit is contained in:
Linus Unnebäck
2020-03-30 15:40:00 -07:00
committed by GitHub
parent 8779cbaf8b
commit b4c23f0e86
6 changed files with 49 additions and 98 deletions
+3 -2
View File
@@ -2,10 +2,11 @@
// Project: https://github.com/hapijs/mimos
// Definitions by: AJP <https://github.com/AJamesPhillips>
// Silas Rech <https://github.com/lenovouser>
// Linus Unnebäck <https://github.com/LinusU>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { DataStructure as MimeDbDataStructure } from 'mime-db';
import { MimeEntry } from 'mime-db';
/**
*
@@ -20,7 +21,7 @@ export interface MimosOptions {
override: {[index: string]: MimosOptionsValue};
}
export interface MimosOptionsValue extends MimeDbDataStructure {
export interface MimosOptionsValue extends MimeEntry {
/** specify the type value of result objects, defaults to key. See the example below for more clarification. */
type?: string;
/** method with signature function(mime) when this mime type is found in the database, this function will run. This allows you make customizations to mime based on developer criteria. */
+26 -14
View File
@@ -1,21 +1,33 @@
// Type definitions for mime-db 1.27
// Project: https://github.com/jshttp/mime-db
// Definitions by: AJP <https://github.com/AJamesPhillips>
// Linus Unnebäck <https://github.com/LinusU>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/**
* Data Structure
* If unknown, every property could be undefined.
* @see {@link https://github.com/jshttp/mime-db#data-structure}
*/
export interface DataStructure {
/** where the mime type is defined. If not set, it's probably a custom media type. */
source?: string;
/** known extensions associated with this mime type. */
extensions?: string[];
/** whether a file of this type can be gzipped. */
compressible?: boolean;
/** the default charset associated with this type, if any. */
charset?: string;
declare namespace database {
/**
* @see {@link https://github.com/jshttp/mime-db#data-structure}
*/
interface MimeEntry {
/** Where the mime type is defined. If not set, it's probably a custom media type. */
readonly source?: string;
/** Known extensions associated with this mime type. */
readonly extensions?: ReadonlyArray<string>;
/** Whether a file of this type can be gzipped. */
readonly compressible?: boolean;
/** The default charset associated with this type, if any. */
readonly charset?: string;
}
/**
* @see {@link https://github.com/jshttp/mime-db#data-structure}
*/
interface MimeDatabase {
readonly [type: string]: MimeEntry;
}
}
declare const database: database.MimeDatabase;
export = database;
+13
View File
@@ -0,0 +1,13 @@
import database = require('mime-db');
// $ExpectType MimeDatabase
database;
// $ExpectType MimeEntry
database['text/markdown'];
// $ExpectType ReadonlyArray<string> | undefined
database['text/markdown'].extensions;
// $ExpectType string
database['text/markdown'].extensions![0];
+3 -2
View File
@@ -17,6 +17,7 @@
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
"index.d.ts",
"mime-db-tests.ts"
]
}
}
+1 -78
View File
@@ -1,80 +1,3 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"npm-naming": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
}
"extends": "dtslint/dt.json"
}
+3 -2
View File
@@ -1,10 +1,11 @@
// Type definitions for mimos 3.0
// Project: https://github.com/hapijs/mimos
// Definitions by: AJP <https://github.com/AJamesPhillips>
// Linus Unnebäck <https://github.com/LinusU>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { DataStructure as MimeDbDataStructure } from 'mime-db';
import { MimeEntry } from 'mime-db';
/**
*
@@ -19,7 +20,7 @@ export interface MimosOptions {
override: {[index: string]: MimosOptionsValue};
}
export interface MimosOptionsValue extends MimeDbDataStructure {
export interface MimosOptionsValue extends MimeEntry {
/** specify the type value of result objects, defaults to key. See the example below for more clarification. */
type?: string;
/** method with signature function(mime) when this mime type is found in the database, this function will run. This allows you make customizations to mime based on developer criteria. */