mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for parse-path (#37805)
This commit is contained in:
parent
b08558b7c5
commit
fdfe1e8721
34
types/parse-path/index.d.ts
vendored
Normal file
34
types/parse-path/index.d.ts
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
// Type definitions for parse-path 4.0
|
||||
// Project: https://github.com/IonicaBizau/parse-path
|
||||
// Definitions by: Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace parsePath {
|
||||
type Protocol = 'http' | 'https' | 'ssh' | 'file' | 'git';
|
||||
|
||||
interface ParsedPath {
|
||||
/** The url hash. */
|
||||
hash: string;
|
||||
/** The input url. */
|
||||
href: string;
|
||||
/** The url pathname. */
|
||||
pathname: string;
|
||||
/** The domain port. */
|
||||
port: null | number;
|
||||
/** The first protocol, `"ssh"` (if the url is a ssh url) or `"file"`. */
|
||||
protocol: Protocol;
|
||||
/** An array with the url protocols (usually it has one element). */
|
||||
protocols: Protocol[];
|
||||
/** The url querystring, parsed as object. */
|
||||
query: any;
|
||||
/** The url domain (including subdomains). */
|
||||
resource: string;
|
||||
/** The url querystring value. */
|
||||
search: string;
|
||||
/** The authentication user (usually for ssh urls). */
|
||||
user: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare function parsePath(url: string): parsePath.ParsedPath;
|
||||
export = parsePath;
|
||||
13
types/parse-path/parse-path-tests.ts
Normal file
13
types/parse-path/parse-path-tests.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import parsePath = require('parse-path');
|
||||
|
||||
const parsed = parsePath('http://www.example.com');
|
||||
|
||||
parsed.hash; // $ExpectType string
|
||||
parsed.href; // $ExpectType string
|
||||
parsed.pathname; // $ExpectType string
|
||||
parsed.port; // $ExpectType number | null
|
||||
parsed.protocol; // $ExpectType Protocol
|
||||
parsed.protocols; // $ExpectType Protocol[]
|
||||
parsed.resource; // $ExpectType string
|
||||
parsed.search; // $ExpectType string
|
||||
parsed.user; // $ExpectType string
|
||||
23
types/parse-path/tsconfig.json
Normal file
23
types/parse-path/tsconfig.json
Normal 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",
|
||||
"parse-path-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/parse-path/tslint.json
Normal file
1
types/parse-path/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user