diff --git a/types/fast-chunk-string/fast-chunk-string-tests.ts b/types/fast-chunk-string/fast-chunk-string-tests.ts new file mode 100644 index 0000000000..b210730351 --- /dev/null +++ b/types/fast-chunk-string/fast-chunk-string-tests.ts @@ -0,0 +1,19 @@ +import fastChunkString = require("fast-chunk-string"); + +// $ExpectType string[] +fastChunkString("AABBCC", { size: 2 }); + +// $ExpectType string[] +fastChunkString("😀😃😄😁", { size: 2, unicodeAware: false }); + +// $ExpectType string[] +fastChunkString("😀😃😄😁", { size: 2, unicodeAware: true }); + +// $ExpectError +fastChunkString("missing options"); + +// $ExpectError +fastChunkString("missing size", { unicodeAware: false }); + +// $ExpectError +fastChunkString(null, { size: 2 }); diff --git a/types/fast-chunk-string/index.d.ts b/types/fast-chunk-string/index.d.ts new file mode 100644 index 0000000000..a6f7cf016f --- /dev/null +++ b/types/fast-chunk-string/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for fast-chunk-string 1.0 +// Project: https://github.com/vladgolubev/fast-chunk-string#readme +// Definitions by: Junxiao Shi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Options { + size: number; + unicodeAware?: boolean; +} + +declare function fastChunkString(str: string, options: Options): string[]; + +export = fastChunkString; diff --git a/types/fast-chunk-string/tsconfig.json b/types/fast-chunk-string/tsconfig.json new file mode 100644 index 0000000000..db15ec5cbe --- /dev/null +++ b/types/fast-chunk-string/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fast-chunk-string-tests.ts" + ] +} diff --git a/types/fast-chunk-string/tslint.json b/types/fast-chunk-string/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/fast-chunk-string/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }