mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-04 19:42:46 +08:00
[media-typer] add typings (#18945)
This commit is contained in:
committed by
Mohamed Hegazy
parent
262d2d6024
commit
0095d2111c
13
types/media-typer/index.d.ts
vendored
Normal file
13
types/media-typer/index.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Type definitions for media-typer 0.3
|
||||
// Project: https://github.com/jshttp/media-typer
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function parse(mediaType: string): MediaType;
|
||||
export function format(mediaTypeDescriptor: MediaType): string;
|
||||
|
||||
export interface MediaType {
|
||||
type: string;
|
||||
subtype: string;
|
||||
suffix?: string;
|
||||
}
|
||||
15
types/media-typer/media-typer-tests.ts
Normal file
15
types/media-typer/media-typer-tests.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as typer from 'media-typer';
|
||||
|
||||
const obj = typer.parse('image/svg+xml');
|
||||
// $ExpectType MediaType
|
||||
obj;
|
||||
// $ExpectType string
|
||||
obj.type;
|
||||
// $ExpectType string
|
||||
obj.subtype;
|
||||
// $ExpectType string | undefined
|
||||
obj.suffix;
|
||||
|
||||
// $ExpectType string
|
||||
typer.format({type: 'image', subtype: 'svg', suffix: 'xml'});
|
||||
typer.format({type: 'image', subtype: 'svg'});
|
||||
22
types/media-typer/tsconfig.json
Normal file
22
types/media-typer/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"media-typer-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/media-typer/tslint.json
Normal file
1
types/media-typer/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user