Add type definitions for ale-url-parser package

This commit is contained in:
Michał Jezierski 2018-10-28 19:01:42 +01:00
parent 974c120127
commit fd7d98e19d
4 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,22 @@
import { parse, stringify } from 'ale-url-parser';
let url;
let urlObject;
url = stringify({});
console.log(url);
url = stringify({
protocol: 'protocol',
host: 'host',
path: ['foo', 'bar', 'baz'],
hash: 'hash',
query: {
foo: 1,
bar: [2, '3']
}
});
console.log(url);
urlObject = parse('//any.dom.ain.co.m/foo/bar?test=1&test=2#hash');
console.log(urlObject);

29
types/ale-url-parser/index.d.ts vendored Normal file
View File

@ -0,0 +1,29 @@
// Type definitions for ale-url-parser 0.10
// Project: https://github.com/msn0/ale-url-parser#readme
// Definitions by: Michał Jezierski <https://github.com/msn0>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export interface QueryParams {
[key: string]: any;
}
export interface UrlObject {
protocol?: string;
host?: string;
path?: string[];
query?: QueryParams;
hash?: string;
}
/**
* Parse url string into url object.
* @return UrlObject
*/
export function parse(url: string): UrlObject;
/**
* Stringify url object into url string.
* @return string
*/
export function stringify(urlObject: UrlObject): string;

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"ale-url-parser-tests.ts"
]
}

View File

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