diff --git a/types/slice-ansi/index.d.ts b/types/slice-ansi/index.d.ts new file mode 100644 index 0000000000..03e49fdad3 --- /dev/null +++ b/types/slice-ansi/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for slice-ansi 2.0 +// Project: https://github.com/chalk/slice-ansi#readme +// Definitions by: Dan Imhoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function sliceAnsi(input: string, beginSlice: number, endSlice?: number): string; + +export = sliceAnsi; diff --git a/types/slice-ansi/slice-ansi-tests.ts b/types/slice-ansi/slice-ansi-tests.ts new file mode 100644 index 0000000000..1488d38daa --- /dev/null +++ b/types/slice-ansi/slice-ansi-tests.ts @@ -0,0 +1,13 @@ +import sliceAnsi = require('slice-ansi'); + +// $ExpectType string +sliceAnsi('The quick brown \u001b[31mfox jumped over \u001b[39mthe lazy \u001b[32mdog and then ran away with the unicorn.\u001b[39m', 20, 30); + +// $ExpectType string +sliceAnsi('test', 1); + +// $ExpectError +sliceAnsi(); + +// $ExpectError +sliceAnsi(5); diff --git a/types/slice-ansi/tsconfig.json b/types/slice-ansi/tsconfig.json new file mode 100644 index 0000000000..86eadc2fc8 --- /dev/null +++ b/types/slice-ansi/tsconfig.json @@ -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", + "slice-ansi-tests.ts" + ] +} diff --git a/types/slice-ansi/tslint.json b/types/slice-ansi/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/slice-ansi/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }