From 51474e1b4f90b28ce32401714523f5fd2d005ed8 Mon Sep 17 00:00:00 2001 From: Omer Yalhi Date: Mon, 31 Dec 2018 08:36:18 -0800 Subject: [PATCH] Added type definitions for smart-truncate (#31743) --- types/smart-truncate/index.d.ts | 6 +++++ types/smart-truncate/smart-truncate-tests.ts | 7 ++++++ types/smart-truncate/tsconfig.json | 23 ++++++++++++++++++++ types/smart-truncate/tslint.json | 1 + 4 files changed, 37 insertions(+) create mode 100644 types/smart-truncate/index.d.ts create mode 100644 types/smart-truncate/smart-truncate-tests.ts create mode 100644 types/smart-truncate/tsconfig.json create mode 100644 types/smart-truncate/tslint.json diff --git a/types/smart-truncate/index.d.ts b/types/smart-truncate/index.d.ts new file mode 100644 index 0000000000..a1250c9f54 --- /dev/null +++ b/types/smart-truncate/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for smart-truncate 1.0 +// Project: https://github.com/millerized/smart-truncate +// Definitions by: Omer Yalhi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function smartTruncate(text: string, length: number, options?: { position?: number; mark?: string }): string; diff --git a/types/smart-truncate/smart-truncate-tests.ts b/types/smart-truncate/smart-truncate-tests.ts new file mode 100644 index 0000000000..0e0caefc50 --- /dev/null +++ b/types/smart-truncate/smart-truncate-tests.ts @@ -0,0 +1,7 @@ +import { smartTruncate } from 'smart-truncate'; + +const length = 9; +let result = ''; +result = smartTruncate('Steve Miller', length); +result = smartTruncate('Steve Miller', length, {position: 4}); +result = smartTruncate('abcdefghijklmnopqrstuvwxyz', 7, {position: 3, mark: '—'}); diff --git a/types/smart-truncate/tsconfig.json b/types/smart-truncate/tsconfig.json new file mode 100644 index 0000000000..708868434f --- /dev/null +++ b/types/smart-truncate/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "smart-truncate-tests.ts" + ] +} \ No newline at end of file diff --git a/types/smart-truncate/tslint.json b/types/smart-truncate/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/smart-truncate/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }