Update types of uri-templates to be up to date to new version. (#27559)

* Update types of uri templates.

* Improve types.

* Improve types in test.
This commit is contained in:
bartek szczepański
2018-07-31 11:45:10 -07:00
committed by Sheetal Nandi
parent 67fea12e53
commit ac91f0945d
2 changed files with 22 additions and 11 deletions
+7 -4
View File
@@ -1,16 +1,19 @@
// Type definitions for uri-templates 0.1.2
// Type definitions for uri-templates 0.1.9
// Project: https://github.com/geraintluff/uri-templates
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Bartek Szczepański <https://github.com/barnski>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function utpl(template: string): utpl.URITemplate;
declare namespace utpl {
export interface URITemplate {
fillFromObject(vars: Object): string;
fillFromObject(vars: { [key: string]: string }): string;
fill(callback: (varName: string) => string): string;
fromUri(uri: string): Object;
fill(vars: { [key: string]: string }): string;
fromUri(uri: string): { [key: string]: string };
varNames: string[];
template: string;
}
}
+15 -7
View File
@@ -1,15 +1,23 @@
import utmpl = require('uri-templates');
import URITemplate = utmpl.URITemplate;
var str: string;
var u: URITemplate;
var obj: Object;
let str: string;
let u: URITemplate;
const obj = { test: 'test1' };
u = utmpl(str);
str = u.fillFromObject(obj);
str = u.fill((key) => {
return str;
str = u.fill(key => {
return str;
});
obj = u.fromUri(str);
str = u.fill(obj);
const newObj = u.fromUri(str);
let varNames: string[];
varNames = u.varNames;
let template: string;
template = u.template;