From 1c8d97fc7a07de46d4d4d2e91fcf5193ec66adda Mon Sep 17 00:00:00 2001 From: Aaron Osher Date: Tue, 26 Jun 2018 16:46:58 +0100 Subject: [PATCH] Add textversionjs Update textversionjs Add test Add tsconfig Add tslint Update textversionjs Fixed linting errors --- types/textversionjs/index.d.ts | 29 ++++++++++++++++++++++ types/textversionjs/textversionjs-tests.ts | 13 ++++++++++ types/textversionjs/tsconfig.json | 23 +++++++++++++++++ types/textversionjs/tslint.json | 8 ++++++ 4 files changed, 73 insertions(+) create mode 100644 types/textversionjs/index.d.ts create mode 100644 types/textversionjs/textversionjs-tests.ts create mode 100644 types/textversionjs/tsconfig.json create mode 100644 types/textversionjs/tslint.json diff --git a/types/textversionjs/index.d.ts b/types/textversionjs/index.d.ts new file mode 100644 index 0000000000..4ce8ab29dc --- /dev/null +++ b/types/textversionjs/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for textversionjs 1.1 +// Project: https://github.com/EDMdesigner/textversionjs +// Definitions by: Aaron Osher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* =================== USAGE =================== + import * as textVersion from "textversionjs"; + =============================================== */ + +declare function textversionjs(html: string, styleConfig?: textversionjs.styleConfig): string; + +declare namespace textversionjs { + type linkProcess = (href: string, linkText: string) => string; + + type imgProcess = (src: string, alt: string) => string; + + interface styleConfig { + linkProcess?: linkProcess; + imgProcess?: imgProcess; + headingStyle?: 'underline' | 'linebreak' | 'hashify'; + listStyle?: 'indentation' | 'linebreak'; + uIndentionChar?: string; + oIndentionChar?: string; + listIndentionTabs?: number; + keepNbsps?: boolean; + } +} + +export = textversionjs; diff --git a/types/textversionjs/textversionjs-tests.ts b/types/textversionjs/textversionjs-tests.ts new file mode 100644 index 0000000000..942a180cf0 --- /dev/null +++ b/types/textversionjs/textversionjs-tests.ts @@ -0,0 +1,13 @@ +import textVersion = require('textversionjs'); + +// $ExpectType string +textVersion("

Hello World

Hello World

"); +/* +=> + Hello World + =========== + Hello World +*/ + +// $ExpectError +textVersion(1); diff --git a/types/textversionjs/tsconfig.json b/types/textversionjs/tsconfig.json new file mode 100644 index 0000000000..b87121d3ed --- /dev/null +++ b/types/textversionjs/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", + "textversionjs-tests.ts" + ] +} diff --git a/types/textversionjs/tslint.json b/types/textversionjs/tslint.json new file mode 100644 index 0000000000..e0508241c7 --- /dev/null +++ b/types/textversionjs/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "indent": [true, "spaces", 4], + "max-line-length": [true, 100], + "no-any": true + } +}