Skip to content

Commit

Permalink
feat(mime-db): minor updates and version bump (DefinitelyTyped#44029)
Browse files Browse the repository at this point in the history
- enumerate mime type source as per used sources, which are closed list
- extend tests
- version bump

https://www.npmjs.com/package/mime-db

Thanks!
  • Loading branch information
peterblazejewicz authored Apr 24, 2020
1 parent e82a2fb commit c292974
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
19 changes: 15 additions & 4 deletions types/mime-db/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
// Type definitions for mime-db 1.27
// Type definitions for mime-db 1.43
// Project: https://github.com/jshttp/mime-db
// Definitions by: AJP <https://github.com/AJamesPhillips>
// Linus Unnebäck <https://github.com/LinusU>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2

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;
/**
* Where the mime type is defined.
* If not set, it's probably a custom media type.
*/
readonly source?: MimeSource;
/** Known extensions associated with this mime type. */
readonly extensions?: ReadonlyArray<string>;
/** Whether a file of this type can be gzipped. */
Expand All @@ -26,6 +29,14 @@ declare namespace database {
interface MimeDatabase {
readonly [type: string]: MimeEntry;
}

/**
* Sources:
* http://www.iana.org/assignments/media-types/media-types.xhtml
* http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
* http://hg.nginx.org/nginx/raw-file/default/conf/mime.types
*/
type MimeSource = 'iana' | 'apache' | 'nginx';
}

declare const database: database.MimeDatabase;
Expand Down
9 changes: 9 additions & 0 deletions types/mime-db/mime-db-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ database['text/markdown'].extensions;

// $ExpectType string
database['text/markdown'].extensions![0];

// $ExpectType "iana" | "apache" | "nginx" | undefined
database['text/markdown'].source;

// $ExpectType string | undefined
database['text/markdown'].charset;

// $ExpectType boolean | undefined
database['text/markdown'].compressible;

0 comments on commit c292974

Please sign in to comment.