diff --git a/types/parse-path/index.d.ts b/types/parse-path/index.d.ts new file mode 100644 index 0000000000..578fe134b9 --- /dev/null +++ b/types/parse-path/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for parse-path 4.0 +// Project: https://github.com/IonicaBizau/parse-path +// Definitions by: Florian Keller +// 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; diff --git a/types/parse-path/parse-path-tests.ts b/types/parse-path/parse-path-tests.ts new file mode 100644 index 0000000000..4f997c5ad7 --- /dev/null +++ b/types/parse-path/parse-path-tests.ts @@ -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 diff --git a/types/parse-path/tsconfig.json b/types/parse-path/tsconfig.json new file mode 100644 index 0000000000..e826633888 --- /dev/null +++ b/types/parse-path/tsconfig.json @@ -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" + ] +} diff --git a/types/parse-path/tslint.json b/types/parse-path/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/parse-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }