diff --git a/types/urijs/index.d.ts b/types/urijs/index.d.ts index 4e046ec27f..08c0611414 100644 --- a/types/urijs/index.d.ts +++ b/types/urijs/index.d.ts @@ -239,8 +239,30 @@ declare namespace uri { type URITemplateCallback = (keyName: string) => URITemplateValue; type URITemplateInput = { [key: string]: URITemplateValue | URITemplateCallback } | URITemplateCallback; + type URITemplateLiteral = string; + interface URITemplateVariable { + name: string; + explode: boolean; + maxLength?: number; + } + + interface URITemplateExpression { + expression: string; + operator: string; + variables: ReadonlyArray; + } + + type URITemplatePart = URITemplateLiteral | URITemplateExpression; + interface URITemplate { expand(data: URITemplateInput, opts?: Object) : URI; + parse(): this; + + /** + * @description The parsed parts of the URI Template. Only present after calling + * `parse()` first. + */ + parts?: ReadonlyArray; } interface URITemplateStatic { diff --git a/types/urijs/urijs-tests.ts b/types/urijs/urijs-tests.ts index f14ba140d3..fc9911d274 100644 --- a/types/urijs/urijs-tests.ts +++ b/types/urijs/urijs-tests.ts @@ -109,6 +109,9 @@ URI('http://user:pass@example.org:80/foo/bar.html').equals( }) ); +const template = URITemplate('/items/{?page,count}'); +template.parse() === template; + /* Tests for hasSearch(), hasQuery() From: http://medialize.github.io/URI.js/docs.html#search-has