Add types for linkify-issues

This commit is contained in:
Dimitri Benin
2018-12-13 21:55:59 +01:00
parent ad5afdf536
commit c060ecec47
4 changed files with 90 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
// Type definitions for linkify-issues 1.3
// Project: https://github.com/sindresorhus/linkify-issues#readme
// Definitions by: BendingBender <https://github.com/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<string | number> };
baseUrl?: string;
}
interface TypeStringOptions extends BaseOptions {
type?: 'string';
}
interface TypeDomOptions extends BaseOptions {
type: 'dom';
}
}
@@ -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);
+24
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }