@@ -27,6 +27,7 @@ import type { CollectionRelationship } from '@warp-drive/core-types/cache/relati
27
27
import type { LocalRelationshipOperation } from '@warp-drive/core-types/graph' ;
28
28
import type { CollectionResourceRelationship , SingleResourceRelationship } from '@warp-drive/core-types/spec/raw' ;
29
29
30
+ import type { ManyArray } from '../-private' ;
30
31
import RelatedCollection from './many-array' ;
31
32
import type { MinimalLegacyRecord } from './model-methods' ;
32
33
import type { BelongsToProxyCreateArgs , BelongsToProxyMeta } from './promise-belongs-to' ;
@@ -298,11 +299,11 @@ export class LegacySupport {
298
299
assert ( 'hasMany only works with the @ember-data/json-api package' ) ;
299
300
}
300
301
301
- reloadHasMany ( key : string , options ?: BaseFinderOptions ) {
302
+ reloadHasMany < T > ( key : string , options ?: BaseFinderOptions ) : Promise < ManyArray < T > > | PromiseManyArray < T > {
302
303
if ( HAS_JSON_API_PACKAGE ) {
303
304
const loadingPromise = this . _relationshipPromisesCache [ key ] ;
304
305
if ( loadingPromise ) {
305
- return loadingPromise ;
306
+ return loadingPromise as Promise < ManyArray < T > > ;
306
307
}
307
308
const relationship = this . graph . get ( this . identifier , key ) as CollectionEdge ;
308
309
const { definition, state } = relationship ;
@@ -313,10 +314,10 @@ export class LegacySupport {
313
314
const promise = this . fetchAsyncHasMany ( key , relationship , manyArray , options ) ;
314
315
315
316
if ( this . _relationshipProxyCache [ key ] ) {
316
- return this . _updatePromiseProxyFor ( 'hasMany' , key , { promise } ) ;
317
+ return this . _updatePromiseProxyFor ( 'hasMany' , key , { promise } ) as PromiseManyArray < T > ;
317
318
}
318
319
319
- return promise ;
320
+ return promise as Promise < ManyArray < T > > ;
320
321
}
321
322
assert ( `hasMany only works with the @ember-data/json-api package` ) ;
322
323
}
@@ -388,7 +389,9 @@ export class LegacySupport {
388
389
return promiseProxy ;
389
390
}
390
391
391
- referenceFor ( kind : string | null , name : string ) {
392
+ referenceFor ( kind : 'belongsTo' , name : string ) : BelongsToReference ;
393
+ referenceFor ( kind : 'hasMany' , name : string ) : HasManyReference ;
394
+ referenceFor ( kind : 'belongsTo' | 'hasMany' , name : string ) {
392
395
let reference = this . references [ name ] ;
393
396
394
397
if ( ! reference ) {
0 commit comments