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..f93cf8562a --- /dev/null +++ b/types/textversionjs/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}