Create types for gravatar-url

This commit is contained in:
Ivan Gabriele
2017-09-12 12:32:06 +02:00
parent 7b26943522
commit 1a637f77e1
4 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import gravatarUrl = require('gravatar-url');
gravatarUrl('sindresorhus@gmail.com'); // $ExpectType string
gravatarUrl('sindresorhus@gmail.com', { default: 'monsterid' }); // $ExpectType string
gravatarUrl('sindresorhus@gmail.com', { default: 'monsterid', size: 200 }); // $ExpectType string
gravatarUrl('sindresorhus@gmail.com', { default: 'monsterid', rating: 'g', size: 200 }); // $ExpectType string
gravatarUrl('sindresorhus@gmail.com', { rating: 'g' }); // $ExpectType string
gravatarUrl('sindresorhus@gmail.com', { rating: 'pg' }); // $ExpectType string
gravatarUrl('sindresorhus@gmail.com', { rating: 'r' }); // $ExpectType string
gravatarUrl('sindresorhus@gmail.com', { rating: 'x' }); // $ExpectType string
gravatarUrl('sindresorhus@gmail.com', { rating: 'g', size: 200 }); // $ExpectType string
gravatarUrl('sindresorhus@gmail.com', { size: 200 }); // $ExpectType string

16
types/gravatar-url/index.d.ts vendored Normal file
View File

@@ -0,0 +1,16 @@
// Type definitions for gravatar-url 2.0
// Project: https://github.com/sindresorhus/gravatar-url
// Definitions by: Ivan Gabriele <https://github.com/ivangabriele>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = GravatarUrl;
declare function GravatarUrl(email: string, options?: GravatarUrl.Options): string;
declare namespace GravatarUrl {
interface Options {
default?: string;
rating?: 'g' | 'pg' | 'r' | 'x';
size?: number;
}
}

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",
"gravatar-url-tests.ts"
]
}

View File

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