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" }