diff --git a/types/terminal-link/index.d.ts b/types/terminal-link/index.d.ts new file mode 100644 index 0000000000..b7772ab581 --- /dev/null +++ b/types/terminal-link/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for terminal-link 1.1 +// Project: https://github.com/sindresorhus/terminal-link#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = terminalLink; + +declare function terminalLink(text: string, url: string, options?: terminalLink.Options): string; + +declare namespace terminalLink { + function isSupported(): boolean; + + interface Options { + fallback?: (text: string, url: string) => string; + } +} diff --git a/types/terminal-link/terminal-link-tests.ts b/types/terminal-link/terminal-link-tests.ts new file mode 100644 index 0000000000..25bf536d0e --- /dev/null +++ b/types/terminal-link/terminal-link-tests.ts @@ -0,0 +1,16 @@ +import terminalLink = require('terminal-link'); + +// $ExpectType string +terminalLink('My Website', 'https://sindresorhus.com'); +terminalLink('My Website', 'https://sindresorhus.com', { + fallback(text, url) { + // $ExpectType string + text; + // $ExpectType string + url; + return text; + }, +}); + +// $ExpectType boolean +terminalLink.isSupported(); diff --git a/types/terminal-link/tsconfig.json b/types/terminal-link/tsconfig.json new file mode 100644 index 0000000000..fd40995e6f --- /dev/null +++ b/types/terminal-link/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "terminal-link-tests.ts" + ] +} diff --git a/types/terminal-link/tslint.json b/types/terminal-link/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/terminal-link/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }