From 7221daab3516a4b7a9ebe2bdc83c5d71be847fd8 Mon Sep 17 00:00:00 2001 From: Junxiao Shi Date: Thu, 7 Nov 2019 13:25:58 -0500 Subject: [PATCH] fast-chunk-string: initial definition (#40207) --- .../fast-chunk-string-tests.ts | 19 +++++++++++++++ types/fast-chunk-string/index.d.ts | 13 +++++++++++ types/fast-chunk-string/tsconfig.json | 23 +++++++++++++++++++ types/fast-chunk-string/tslint.json | 1 + 4 files changed, 56 insertions(+) create mode 100644 types/fast-chunk-string/fast-chunk-string-tests.ts create mode 100644 types/fast-chunk-string/index.d.ts create mode 100644 types/fast-chunk-string/tsconfig.json create mode 100644 types/fast-chunk-string/tslint.json 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" }