Skip to content

Commit 71859b6

Browse files
committed
fix TS compiler errors
1 parent f77c0ac commit 71859b6

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/LoadingStoreValue.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ class LoadingStoreValue implements Resource {
6868
}
6969

7070
get items (): Array<Resource> {
71-
return LoadingStoreCollection.create(this.loadResource.then(entity => entity.items))
71+
return LoadingStoreCollection.create(this.loadResource.then(resource => (resource as Collection).items))
7272
}
7373

7474
get allItems (): Array<Resource> {
75-
return LoadingStoreCollection.create(this.loadResource.then(entity => entity.allItems))
75+
return LoadingStoreCollection.create(this.loadResource.then(resource => (resource as Collection).allItems))
7676
}
7777

7878
public $reload (): Promise<Resource> {
7979
// Skip reloading entities that are already loading
8080
return this._meta.load
8181
}
8282

83-
public $loadItems (): Promise<Array<Resource>> {
83+
public $loadItems (): Promise<Collection> {
8484
return this._meta.load.then(resource => (resource as Collection).$loadItems())
8585
}
8686

src/index.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Resource, { EmbeddedCollectionType } from './interfaces/Resource'
1313
import StoreData, { Link } from './interfaces/StoreData'
1414
import ApiActions from './interfaces/ApiActions'
1515
import EmbeddedCollection from './EmbeddedCollection'
16+
import EmbeddedCollectionInterface from './interfaces/EmbeddedCollection'
1617

1718
/**
1819
* Defines the API store methods available in all Vue components. The methods can be called as follows:
@@ -84,13 +85,10 @@ function HalJsonVuex (store: Store<Record<string, State>>, axios: AxiosInstance,
8485
* @returns Promise Resolves when the GET request has completed and the updated entity is available
8586
* in the Vuex store.
8687
*/
87-
async function reload (uriOrEntity: EmbeddedCollectionType): Promise<EmbeddedCollection>;
88-
async function reload (uriOrEntity: string | Resource | StoreData): Promise<Resource>;
89-
90-
async function reload (uriOrEntity: string | Resource | StoreData | EmbeddedCollectionType): Promise<Resource | EmbeddedCollection> {
88+
async function reload (uriOrEntity: string | Resource | StoreData | EmbeddedCollectionType): Promise<Resource | EmbeddedCollectionInterface> {
9189
if (isEmbeddedCollectionType(uriOrEntity)) { // = type guard for Embedded Collection
9290
return get(uriOrEntity._meta.reload.uri, true)._meta.load // load parent resource
93-
.then(parent => parent[uriOrEntity._meta.reload.property]() as EmbeddedCollection) // ... and unwrap reload property after loading has finished
91+
.then(parent => parent[uriOrEntity._meta.reload.property]() as EmbeddedCollectionInterface) // ... and unwrap reload property after loading has finished
9492
} else {
9593
return get(uriOrEntity, true)._meta.load
9694
}

0 commit comments

Comments
 (0)