From ac91f0945dad3a3464bcdf2745fb695c1bd532c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?bartek=20szczepa=C5=84ski?= Date: Tue, 31 Jul 2018 20:45:10 +0200 Subject: [PATCH] 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. --- types/uri-templates/index.d.ts | 11 +++++++---- types/uri-templates/uri-templates-tests.ts | 22 +++++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/types/uri-templates/index.d.ts b/types/uri-templates/index.d.ts index ad8cead946..d378de8a4f 100644 --- a/types/uri-templates/index.d.ts +++ b/types/uri-templates/index.d.ts @@ -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 +// Bartek SzczepaƄski // 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; } } diff --git a/types/uri-templates/uri-templates-tests.ts b/types/uri-templates/uri-templates-tests.ts index 0aeb5e0bfe..d29b801de1 100644 --- a/types/uri-templates/uri-templates-tests.ts +++ b/types/uri-templates/uri-templates-tests.ts @@ -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;