diff --git a/types/badgen/badgen-tests.ts b/types/badgen/badgen-tests.ts new file mode 100644 index 0000000000..1b795b3d72 --- /dev/null +++ b/types/badgen/badgen-tests.ts @@ -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 +}); diff --git a/types/badgen/index.d.ts b/types/badgen/index.d.ts new file mode 100644 index 0000000000..cc6aa1fe54 --- /dev/null +++ b/types/badgen/index.d.ts @@ -0,0 +1,55 @@ +// Type definitions for badgen 2.6 +// Project: https://github.com/amio/badgen +// Definitions by: 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; diff --git a/types/badgen/tsconfig.json b/types/badgen/tsconfig.json new file mode 100644 index 0000000000..8e915b8aac --- /dev/null +++ b/types/badgen/tsconfig.json @@ -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" + ] +} diff --git a/types/badgen/tslint.json b/types/badgen/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/badgen/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}