mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #24217 from mfeckie/update-changed-attributes
Add typing for .changedAttributes()
This commit is contained in:
Vendored
+4
-1
@@ -23,6 +23,9 @@ declare module 'ember-data' {
|
||||
type AttributesFor<Model> = keyof Model; // TODO: filter to attr properties only (TS 2.8)
|
||||
type RelationshipsFor<Model> = keyof Model; // TODO: filter to hasMany/belongsTo properties only (TS 2.8)
|
||||
|
||||
export interface ChangedAttributes {
|
||||
[key: string]: [any, any] | undefined;
|
||||
}
|
||||
interface AttributeMeta<Model extends DS.Model> {
|
||||
type: keyof TransformRegistry;
|
||||
options: object;
|
||||
@@ -500,7 +503,7 @@ declare module 'ember-data' {
|
||||
* Returns an object, whose keys are changed properties, and value is
|
||||
* an [oldProp, newProp] array.
|
||||
*/
|
||||
changedAttributes(): {};
|
||||
changedAttributes(): ChangedAttributes;
|
||||
/**
|
||||
* If the model `hasDirtyAttributes` this function will discard any unsaved
|
||||
* changes. If the model `isNew` it will be removed from the store.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Ember from 'ember';
|
||||
import DS from 'ember-data';
|
||||
import DS, { ChangedAttributes } from 'ember-data';
|
||||
import { assertType } from "./lib/assert";
|
||||
|
||||
const Person = DS.Model.extend({
|
||||
@@ -30,3 +30,7 @@ assertType<Date>(user.get('createdAt'));
|
||||
|
||||
user.serialize();
|
||||
user.serialize({ includeId: true });
|
||||
user.serialize({ includeId: true });
|
||||
|
||||
const attributes = user.changedAttributes();
|
||||
assertType<ChangedAttributes>(attributes);
|
||||
|
||||
Reference in New Issue
Block a user