mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
[ember-data] Model#eachRelationship fixes (#27278)
This commit is contained in:
committed by
Ryan Cavanaugh
parent
57ab455b32
commit
2beceb200e
Vendored
+2
-2
@@ -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<this>) => 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<M extends Model = Model>(callback: (name: string, details: RelationshipMeta<M>) => 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
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user