Skip to content

Commit 7a5d6bc

Browse files
AndreasLoukakisLOUKAKIS Andreas Kaisar
andauthored
🤖 Merge PR DefinitelyTyped#74175 [uri-template-lite] Fix type definitions to match CommonJS exports by @AndreasLoukakis
Co-authored-by: LOUKAKIS Andreas Kaisar <[email protected]>
1 parent 2b3f815 commit 7a5d6bc

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
export namespace URI {
2-
function expand(template: string, data: { [key: string]: unknown }): string;
1+
declare class Template {
2+
constructor(template: string);
3+
expand(data: { [key: string]: unknown }): string;
4+
match(uri: string): { [key: string]: string };
5+
}
6+
7+
declare function expand(template: string, data: { [key: string]: unknown }): string;
38

4-
class Template {
5-
constructor(template: string);
6-
expand: (data: { [key: string]: unknown }) => string;
7-
match: (template: string) => { [key: string]: string };
8-
}
9+
declare namespace Template {
10+
export { expand };
911
}
12+
13+
export = Template;
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { URI } from "uri-template-lite";
1+
import Template from "uri-template-lite";
22

3-
// Call `expand` directly
3+
// Call `expand` directly via the static method
44
const dataSet = { domain: "example.com", user: "fred", query: "mycelium" };
5-
URI.expand("http://{domain}/~{user}/foo{?query,number}", dataSet);
5+
Template.expand("http://{domain}/~{user}/foo{?query,number}", dataSet);
66

7-
const template = new URI.Template("http://{domain}/~{user}/foo{?query,number}");
7+
// Create a template instance
8+
const template = new Template("http://{domain}/~{user}/foo{?query,number}");
89
template.expand(dataSet);
910
template.match("http://example.com/~fred/foo?query=mycelium&number=3");
1011
template.match("http://other.com/?query=mycelium");

0 commit comments

Comments
 (0)