diff --git a/types/coverup/coverup-tests.ts b/types/coverup/coverup-tests.ts new file mode 100644 index 0000000000..ed83332f6c --- /dev/null +++ b/types/coverup/coverup-tests.ts @@ -0,0 +1,32 @@ +import coverup = require("coverup"); + +coverup("4242-4242-4242-4242"); // $ExpectType string +//=> ******************* + +coverup("4242-4242-4242-4242", { char: "%" }); // $ExpectType string +//=> %%%%%%%%%%%%%%%%%%% + +coverup("4242-4242-4242-4242", { keepSymbols: true }); // $ExpectType string +//=> ****-****-****-**** + +coverup("4242-4242-4242-4242", { keepLeft: 1, keepRight: 1, compactTo: 4 }); // $ExpectType string +//=> 4****2 + +coverup("4242-4242-4242-4242", { keepLeft: 4 }); // $ExpectType string +//=> 4242*************** + +coverup("4242-4242-4242-4242", { keepRight: 4 }); // $ExpectType string +//=> ***************4242 + +let options: coverup.Options = { + char: "x", + keepLeft: 3, + keepRight: 3, +}; + +coverup("4242-4242-4242-4242", options); // $ExpectType string +// => 424xxxxxxxxxxxxx242 + +coverup("4242-4242-4242-4242", { keepLeft: 1, keepRight: 1, compactTo: 4, keepSymbols: true }); // $ExpectError +//=> Error: you cannot define both compactTo and keepSymbols + diff --git a/types/coverup/index.d.ts b/types/coverup/index.d.ts new file mode 100644 index 0000000000..baf69971f7 --- /dev/null +++ b/types/coverup/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for coverup v0.1 +// Project: https://github.com/jsonmaur/coverup +// Definitions by: Vadim Belorussov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace Coverup; + +export = coverup; + +declare function coverup(value: string, options?: coverup.Options): string; + +declare namespace coverup { + export interface Options { + char?: string; + keepLeft?: number; + keepRight?: number; + compactTo?: number; + keepSymbols?: boolean; + } +} diff --git a/types/coverup/tsconfig.json b/types/coverup/tsconfig.json new file mode 100644 index 0000000000..8de465caa0 --- /dev/null +++ b/types/coverup/tsconfig.json @@ -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", + "coverup-tests.ts" + ] +} diff --git a/types/coverup/tslint.json b/types/coverup/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/coverup/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }