Skip to content

Commit 5305a5d

Browse files
committed
type definition for url-template
1 parent 4def09d commit 5305a5d

File tree

5 files changed

+7
-22
lines changed

5 files changed

+7
-22
lines changed

package-lock.json

Lines changed: 2 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@
4242
},
4343
"homepage": "https://github.com/ecamp/hal-json-vuex#readme",
4444
"dependencies": {
45-
"hal-json-normalizer": "^4.1.1",
46-
"url-template": "^2.0.8"
45+
"hal-json-normalizer": "4.1.1",
46+
"url-template": "2.0.8"
4747
},
4848
"devDependencies": {
4949
"@babel/plugin-transform-regenerator": "7.16.7",
5050
"@babel/plugin-transform-runtime": "7.16.10",
5151
"@babel/preset-env": "7.16.11",
5252
"@babel/preset-typescript": "7.16.7",
5353
"@nuxt/types": "2.15.8",
54-
"@types/url-template": "2.0.28",
5554
"@typescript-eslint/eslint-plugin": "5.10.1",
5655
"@typescript-eslint/parser": "5.10.1",
5756
"@vue/eslint-config-standard": "6.1.0",

src/Resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Resource implements ResourceInterface {
9797
return this.apiActions.del(this._meta.self)
9898
}
9999

100-
$href (relation: string, templateParams = {}): Promise<string | undefined> {
100+
$href (relation: string, templateParams: Record<string, string | number | boolean> = {}): Promise<string | undefined> {
101101
return this.apiActions.href(this, relation, templateParams)
102102
}
103103

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ function HalJsonVuex (store: Store<Record<string, State>>, axios: AxiosInstance,
243243
* @param templateParams in case the relation is a templated link, the template parameters that should be filled in
244244
* @returns Promise resolves to the URI of the related entity.
245245
*/
246-
async function href (uriOrEntity: string | ResourceInterface, relation: string, templateParams = {}): Promise<string | undefined> {
246+
async function href (uriOrEntity: string | ResourceInterface, relation: string, templateParams:Record<string, string | number | boolean> = {}): Promise<string | undefined> {
247247
const selfUri = normalizeEntityUri(await get(uriOrEntity)._meta.load, axios.defaults.baseURL)
248248
const rel = selfUri != null ? store.state[opts.apiName][selfUri][relation] : null
249249
if (!rel || !rel.href) return undefined

src/interfaces/ResourceInterface.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ interface ResourceInterface {
1818
$post: (data: unknown) => Promise<ResourceInterface | null>
1919
$patch: (data: unknown) => Promise<ResourceInterface>
2020
$del: () => Promise<string | void>
21-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
22-
$href: (relation: string, templateParams: any) => Promise<string | undefined>
21+
$href: (relation: string, templateParams: Record<string, string | number | boolean>) => Promise<string | undefined>
2322
}
2423

2524
export { ResourceInterface }

0 commit comments

Comments
 (0)