Merge pull request #32369 from m5d215/badgen

[badgen] Add types
This commit is contained in:
Benjamin Lichtman
2019-01-22 19:07:53 -08:00
committed by GitHub
4 changed files with 106 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import badgen from 'badgen';
// $ExpectType string
badgen({
subject: 'SUBJECT',
status: 'STATUS'
});
// $ExpectType string
badgen({
subject: 'SUBJECT',
status: 'STATUS',
color: 'green'
});
// $ExpectType string
badgen({
subject: 'SUBJECT',
status: 'STATUS',
color: '#FF0000',
style: 'flat',
icon: 'data:image/svg+xml;base64,...',
iconWidth: 20
});
+55
View File
@@ -0,0 +1,55 @@
// Type definitions for badgen 2.6
// Project: https://github.com/amio/badgen
// Definitions by: m5d215 <https://github.com/m5d215>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
type ColorPresets =
| 'green'
| 'blue'
| 'red'
| 'yellow'
| 'orange'
| 'purple'
| 'pink'
| 'grey'
| 'gray'
| 'cyan'
| 'black';
interface BadgeCreationParams {
/**
* Text representing the subject.
*/
subject: string;
/**
* Text representing the status.
*/
status: string;
/**
* Color RGB or Color Name, optional.
*/
color?: ColorPresets | string;
/**
* 'flat' or undefined, optional.
*/
style?: 'flat';
/**
* Use icon, optional.
*/
icon?: string;
/**
* Use this if icon is not square.
* @default 13
*/
iconWidth?: number;
}
declare function badgen(params: BadgeCreationParams): string;
export = badgen;
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"badgen-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}