🤖 Merge PR #62935 [git-up] Add types by @BendingBender

This commit is contained in:
Dimitri B
2022-10-28 19:33:13 +02:00
committed by GitHub
parent c76a45bd88
commit 41c92638f4
4 changed files with 113 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import gitUp = require('git-up');
// test type exports
type PU = gitUp.ParsedUrl;
const parsedUrl = gitUp('git@github.com:IonicaBizau/node-parse-url.git'); // $ExpectType ParsedUrl
parsedUrl.protocols; // $ExpectType string[]
parsedUrl.port; // $ExpectType string
parsedUrl.resource; // $ExpectType string
parsedUrl.user; // $ExpectType string | undefined
parsedUrl.pathname; // $ExpectType string
parsedUrl.hash; // $ExpectType string
parsedUrl.search; // $ExpectType string
parsedUrl.href; // $ExpectType string
parsedUrl.protocol; // $ExpectType string
parsedUrl.token; // $ExpectType string
parsedUrl.query; // $ExpectType Record<string, string>
parsedUrl.parse_failed; // $ExpectType false

70
types/git-up/index.d.ts vendored Normal file
View File

@@ -0,0 +1,70 @@
// Type definitions for git-up 7.0
// Project: https://github.com/IonicaBizau/git-up
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = gitUp;
/**
* A low level git url parser. Parses the `input` url.
*
* @param input The url as string.
* @returns The parsed url.
*
* @example
* import gitUp = require("git-up");
*
* console.log(gitUp("git@github.com:IonicaBizau/node-parse-url.git"));
* // => {
* // protocols: []
* // , port: null
* // , resource: "github.com"
* // , user: "git"
* // , pathname: "/IonicaBizau/node-parse-url.git"
* // , hash: ""
* // , search: ""
* // , href: "git@github.com:IonicaBizau/node-parse-url.git"
* // , protocol: "ssh"
* // }
*
* console.log(gitUp("https://github.com/IonicaBizau/node-parse-url.git"));
* // => {
* // protocols: [ "https" ]
* // , port: null
* // , resource: "github.com"
* // , user: ""
* // , pathname: "/IonicaBizau/node-parse-url.git"
* // , hash: ""
* // , search: ""
* // , href: "https://github.com/IonicaBizau/node-parse-url.git"
* // , protocol: "https"
* // }
*/
declare function gitUp(input: string): gitUp.ParsedUrl;
declare namespace gitUp {
interface ParsedUrl {
/** An array with the url protocols (usually it has one element). */
protocols: string[];
/** The domain port. */
port: string;
/** The url domain (including subdomains). */
resource: string;
/** The authentication user (usually for ssh urls). */
user: string | undefined;
/** The url pathname. */
pathname: string;
/** The url hash. */
hash: string;
/** The url querystring value. */
search: string;
/** The input url. */
href: string;
/** The git url protocol. */
protocol: string;
/** The oauth token (could appear in the https urls). */
token: string;
query: Record<string, string>;
parse_failed: false;
}
}

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",
"git-up-tests.ts"
]
}

1
types/git-up/tslint.json Normal file
View File

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