@@ -27,6 +27,7 @@ import type { CollectionRelationship } from '@warp-drive/core-types/cache/relati
2727import type { LocalRelationshipOperation } from '@warp-drive/core-types/graph' ;
2828import type { CollectionResourceRelationship , SingleResourceRelationship } from '@warp-drive/core-types/spec/raw' ;
2929
30+ import type { ManyArray } from '../-private' ;
3031import RelatedCollection from './many-array' ;
3132import type { MinimalLegacyRecord } from './model-methods' ;
3233import type { BelongsToProxyCreateArgs , BelongsToProxyMeta } from './promise-belongs-to' ;
@@ -298,11 +299,11 @@ export class LegacySupport {
298299 assert ( 'hasMany only works with the @ember-data/json-api package' ) ;
299300 }
300301
301- reloadHasMany ( key : string , options ?: BaseFinderOptions ) {
302+ reloadHasMany < T > ( key : string , options ?: BaseFinderOptions ) : Promise < ManyArray < T > > | PromiseManyArray < T > {
302303 if ( HAS_JSON_API_PACKAGE ) {
303304 const loadingPromise = this . _relationshipPromisesCache [ key ] ;
304305 if ( loadingPromise ) {
305- return loadingPromise ;
306+ return loadingPromise as Promise < ManyArray < T > > ;
306307 }
307308 const relationship = this . graph . get ( this . identifier , key ) as CollectionEdge ;
308309 const { definition, state } = relationship ;
@@ -313,10 +314,10 @@ export class LegacySupport {
313314 const promise = this . fetchAsyncHasMany ( key , relationship , manyArray , options ) ;
314315
315316 if ( this . _relationshipProxyCache [ key ] ) {
316- return this . _updatePromiseProxyFor ( 'hasMany' , key , { promise } ) ;
317+ return this . _updatePromiseProxyFor ( 'hasMany' , key , { promise } ) as PromiseManyArray < T > ;
317318 }
318319
319- return promise ;
320+ return promise as Promise < ManyArray < T > > ;
320321 }
321322 assert ( `hasMany only works with the @ember-data/json-api package` ) ;
322323 }
@@ -388,7 +389,9 @@ export class LegacySupport {
388389 return promiseProxy ;
389390 }
390391
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 ) {
392395 let reference = this . references [ name ] ;
393396
394397 if ( ! reference ) {
0 commit comments