Merge pull request #16571 from wolfgang42/url-assembler

Add type definitions for url-assembler library.
This commit is contained in:
Arthur Ozga
2017-05-18 16:24:38 -07:00
committed by GitHub
4 changed files with 58 additions and 0 deletions

28
types/url-assembler/index.d.ts vendored Normal file
View File

@@ -0,0 +1,28 @@
// Type definitions for url-assembler 1.2
// Project: https://github.com/Floby/node-url-assembler
// Definitions by: Wolfgang Faust <https://github.com/wolfgang42>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface UrlAssembler {
template(template: string): UrlAssembler;
prefix(subPath: string): UrlAssembler;
segment(subPathTemplate: string): UrlAssembler;
param(key: string, value: string, strict: boolean): UrlAssembler;
param(params: {[s: string]: any}, strict: boolean): UrlAssembler;
query(key: string, value: any): UrlAssembler;
query(params: {[s: string]: any}): UrlAssembler;
toString(): string;
valueOf(): string;
toJSON(): string;
}
interface UrlAssemblerConstructor {
(baseUrl?: string): UrlAssembler;
(urlAssembler: UrlAssembler): UrlAssembler;
new (baseUrl?: string): UrlAssembler;
new (urlAssembler: UrlAssembler): UrlAssembler;
}
declare const UrlAssembler: UrlAssemblerConstructor;
export = UrlAssembler;

View File

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

View File

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

View File

@@ -0,0 +1,7 @@
import UrlAssembler = require('url-assembler');
UrlAssembler('http://goggle.com').segment('string');
const f = new UrlAssembler('https://foo/bar/');
function printUrl(u: UrlAssembler) {
return u.toJSON();
}