Added type definitions for voucher-code-generator

This commit is contained in:
João Moura
2019-03-07 15:49:35 +00:00
parent 480aadcbb3
commit ff7c8f8798
4 changed files with 61 additions and 0 deletions

19
types/voucher-code-generator/index.d.ts vendored Normal file
View File

@@ -0,0 +1,19 @@
// Type definitions for voucher-code-generator 1.1
// Project: http://www.voucherify.io/
// Definitions by: My Self <https://github.com/me>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/*~ If this module has methods, declare them as functions like so.
*/
export function charset(name: "numbers" | "alphabetic" | "alphanumeric"): string;
export function generate(config?: generatorConfig): string[];
/*~ You can declare types that are available via importing the module */
export interface generatorConfig {
length?: number;
count?: number;
charset?: string;
prefix?: string;
postfix?: string;
pattern?: string;
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"voucher-code-generator-tests.ts"
]
}

View File

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

View File

@@ -0,0 +1,18 @@
import voucherGenerator = require('voucher-code-generator');
import { generatorConfig } from 'voucher-code-generator';
const config: generatorConfig = {
length: 6,
count: 3,
charset: "0123456789",
prefix: "offer-",
postfix: "-2019",
pattern: "######"
};
voucherGenerator.charset('numbers');
voucherGenerator.charset('alphabetic');
voucherGenerator.charset('alphanumeric');
voucherGenerator.generate();
voucherGenerator.generate(config);