Add types for protocols (#37806)

This commit is contained in:
Florian Keller 2019-08-21 20:58:41 +02:00 committed by Sheetal Nandi
parent 0e0bf529e2
commit 0dde9f096f
4 changed files with 44 additions and 0 deletions

14
types/protocols/index.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
// Type definitions for protocols 1.4
// Project: https://github.com/IonicaBizau/protocols
// Definitions by: Florian Keller <https://github.com/ffflorian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* @param input The input url.
* @param first If `true`, the first protocol will be returned. If number, it will represent the zero-based index of the protocols array.
* @returns The array of protocols or the specified protocol.
*/
declare function protocols(input: string, first: true | number): string;
declare function protocols(input: string, first?: false): string[];
export = protocols;

View File

@ -0,0 +1,6 @@
import protocols = require('protocols');
protocols('git+ssh://git@some-host.com/and-the-path/name'); // $ExpectType string[]
protocols('http://example.com', true); // $ExpectType string
protocols('ftp://example.com', 1); // $ExpectType string
protocols('https://example.com', false); // $ExpectType string[]

View File

@ -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",
"protocols-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }