From c060ecec47bd31aa5980ed574aaca51cda973ec5 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Thu, 13 Dec 2018 21:55:59 +0100 Subject: [PATCH] Add types for linkify-issues --- types/linkify-issues/index.d.ts | 29 ++++++++++++++++ types/linkify-issues/linkify-issues-tests.ts | 36 ++++++++++++++++++++ types/linkify-issues/tsconfig.json | 24 +++++++++++++ types/linkify-issues/tslint.json | 1 + 4 files changed, 90 insertions(+) create mode 100644 types/linkify-issues/index.d.ts create mode 100644 types/linkify-issues/linkify-issues-tests.ts create mode 100644 types/linkify-issues/tsconfig.json create mode 100644 types/linkify-issues/tslint.json diff --git a/types/linkify-issues/index.d.ts b/types/linkify-issues/index.d.ts new file mode 100644 index 0000000000..4c37a8f87a --- /dev/null +++ b/types/linkify-issues/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for linkify-issues 1.3 +// Project: https://github.com/sindresorhus/linkify-issues#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = linkifyIssues; + +declare function linkifyIssues(input: string, options?: linkifyIssues.TypeStringOptions): string; +declare function linkifyIssues( + input: string, + options: linkifyIssues.TypeDomOptions +): DocumentFragment; + +declare namespace linkifyIssues { + interface BaseOptions { + user: string; + repo: string; + attributes?: { [attrName: string]: string | number | boolean | Array }; + baseUrl?: string; + } + + interface TypeStringOptions extends BaseOptions { + type?: 'string'; + } + + interface TypeDomOptions extends BaseOptions { + type: 'dom'; + } +} diff --git a/types/linkify-issues/linkify-issues-tests.ts b/types/linkify-issues/linkify-issues-tests.ts new file mode 100644 index 0000000000..cdf2dd8be1 --- /dev/null +++ b/types/linkify-issues/linkify-issues-tests.ts @@ -0,0 +1,36 @@ +import linkifyIssues = require('linkify-issues'); + +// $ExpectType string +linkifyIssues('Fixes #143 and avajs/ava#1023', { + user: 'sindresorhus', + repo: 'dofle', +}); +// $ExpectType string +linkifyIssues('Fixes #143 and avajs/ava#1023', { + user: 'sindresorhus', + repo: 'dofle', + attributes: { + class: 'unicorn', + multiple: ['a', 'b'], + number: 1, + exclude: false, + include: true, + }, +}); +// $ExpectType string +linkifyIssues('Fixes #143 and avajs/ava#1023', { + user: 'sindresorhus', + repo: 'dofle', + type: 'string', +}); + +const fragment = linkifyIssues('Fixes #143 and avajs/ava#1023', { + user: 'sindresorhus', + repo: 'dofle', + type: 'dom', +}); + +// $ExpectType DocumentFragment +fragment; + +document.body.appendChild(fragment); diff --git a/types/linkify-issues/tsconfig.json b/types/linkify-issues/tsconfig.json new file mode 100644 index 0000000000..459076c4c0 --- /dev/null +++ b/types/linkify-issues/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "linkify-issues-tests.ts" + ] +} diff --git a/types/linkify-issues/tslint.json b/types/linkify-issues/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/linkify-issues/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }