diff --git a/types/ember-data/index.d.ts b/types/ember-data/index.d.ts index b891bbe1d1..b071662326 100644 --- a/types/ember-data/index.d.ts +++ b/types/ember-data/index.d.ts @@ -526,7 +526,7 @@ declare module 'ember-data' { * invoking the callback with the name of each relationship and its relationship * descriptor. */ - eachRelationship(callback: Function, binding: any): any; + eachRelationship(callback: (name: string, details: RelationshipMeta) => void, binding?: any): any; /** * Represents the model's class name as a string. This can be used to look up the model's class name through * `DS.Store`'s modelFor method. @@ -577,7 +577,7 @@ declare module 'ember-data' { * invoking the callback with the name of each relationship and its relationship * descriptor. */ - static eachRelationship(callback: Function, binding: any): any; + static eachRelationship(callback: (name: string, details: RelationshipMeta) => void, binding?: any): any; /** * Given a callback, iterates over each of the types related to a model, * invoking the callback with the related type's class. Each type will be diff --git a/types/ember-data/test/relationships.ts b/types/ember-data/test/relationships.ts index df43387bb4..06795c0e26 100644 --- a/types/ember-data/test/relationships.ts +++ b/types/ember-data/test/relationships.ts @@ -12,6 +12,20 @@ const Polymorphic = DS.Model.extend({ paymentMethods: DS.hasMany('payment-method', { polymorphic: true }) }); +Polymorphic.eachRelationship(() => ''); +Polymorphic.eachRelationship(() => '', {}); +Polymorphic.eachRelationship((n, meta) => { + let s: string = n; + let m: 'belongsTo' | 'hasMany' = meta.kind; +}); +let p = Polymorphic.create(); +p.eachRelationship(() => ''); +p.eachRelationship(() => '', {}); +p.eachRelationship((n, meta) => { + let s: string = n; + let m: 'belongsTo' | 'hasMany' = meta.kind; +}); + class Comment extends DS.Model { author = DS.attr('string'); }