[media-typer] add typings (#18945)

This commit is contained in:
Dimitri Benin
2017-08-14 23:07:28 +02:00
committed by Mohamed Hegazy
parent 262d2d6024
commit 0095d2111c
4 changed files with 51 additions and 0 deletions

13
types/media-typer/index.d.ts vendored Normal file
View 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;
}

View 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'});

View 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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }