Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#49305 feat(js-gravatar): new definition by @…
Browse files Browse the repository at this point in the history
  • Loading branch information
peterblazejewicz authored Nov 7, 2020
1 parent 5ed1775 commit cdcf3ff
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
39 changes: 39 additions & 0 deletions types/js-gravatar/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Type definitions for js-gravatar 1.1
// Project: https://github.com/chukwumaijem/js-gravatar#readme
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/**
* JS Gravatar
* {@link https://github.com/chukwumaijem/js-gravatar#js-gravatar}
*/
declare function jsGravatar(options?: jsGravatar.Options): string;

declare namespace jsGravatar {
interface Options {
/**
* The size of the image to be displayed. Should be from 1 to 2048
*/
size?: number;
/**
* What image should be used if email does not have a gravatar
*/
defaultImage?: '404' | 'mp' | 'identicon' | 'monsterid' | 'wavatar' | 'retro' | 'robohash' | 'blank';
/**
* Email address of the user to generate gravatar for
*/
email: string;
/**
* Optional: MD5 hash of the email above.
* If email is provided, md5hash will be ignored. If neither email nor md5hash is provided, the library will throw en error
*/
md5Hash?: string;
}

function buildQueryStringFromOptions(options: Options): string;
function validateOptions(options?: Options): void;
}

export as namespace jsGravatar;

export = jsGravatar;
9 changes: 9 additions & 0 deletions types/js-gravatar/js-gravatar-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import JsGravatar = require('js-gravatar');
import { buildQueryStringFromOptions, validateOptions } from 'js-gravatar';

// $ExpectType string
JsGravatar({ email: 'user@email.com', size: 10, defaultImage: 'identicon' });
// $ExpectType string
buildQueryStringFromOptions({ email: 'user@email.com', defaultImage: 'monsterid' });
// $ExpectType void
validateOptions({ email: 'user@email.com', size: 10, defaultImage: 'identicon' });
23 changes: 23 additions & 0 deletions types/js-gravatar/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"js-gravatar-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/js-gravatar/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

0 comments on commit cdcf3ff

Please sign in to comment.