# \`cannot read property 'setDirtyAttribute' of null\` even if you use \`YourModel.create({...})\` in \`ember-typescript-cli\`

**URL:** <https://discuss.emberjs.com/t/cannot-read-property-setdirtyattribute-of-null-even-if-you-use-yourmodel-create-in-ember-typescript-cli/16860>\
**Category:** Ember Data\
**Created:** [July 23, 2019, 2:52am UTC](https://discuss.emberjs.com/t/cannot-read-property-setdirtyattribute-of-null-even-if-you-use-yourmodel-create-in-ember-typescript-cli/16860 "2019-07-23T02:52:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CasterKKK](https://avatars.discourse-cdn.com/v4/letter/c/dfb087/32.png) [@CasterKKK](https://discuss.emberjs.com/u/CasterKKK)\
**Post date:** [July 23, 2019, 2:52am UTC](https://discuss.emberjs.com/t/cannot-read-property-setdirtyattribute-of-null-even-if-you-use-yourmodel-create-in-ember-typescript-cli/16860/1 "2019-07-23T02:52:33Z")

</div>

Facing `cannot read property 'setDirtyAttribute' of null` even if you use `YourModel.create({...})` in `ember-typescript-cli`to create a EmberObject.

Model:

```nohighlight
import DS from 'ember-data';
import {computed} from "@ember/object";

export default class Person extends DS.Model {
  @DS.attr() firstName!: string;
  @DS.attr() lastName!: string;
  @DS.attr() age!: number;
  @DS.attr() desc?: string;

  @computed("firstName", "lastName")
  public get fullName() {
    return `${this.firstName} ${this.lastName}`;
  }
}

// DO NOT DELETE: this is how TypeScript knows how to look up your models.
declare module 'ember-data/types/registries/model' {
  export default interface ModelRegistry {
    'person': Person;
  }
}

```

Route:

```nohighlight
export default class Persons extends Route {
  @service() public store!: DS.Store;

  constructor() {
    super(...arguments);

    const persons: Person[] = [
      Person.create({firstName: "first1", lastName: "last1", age: 10}),
      Person.create({firstName: "first2", lastName: "last2", age: 320}),
      Person.create({firstName: "first3", lastName: "last3", age: 30}),
    ];
      persons.forEach(p => this.store.createRecord('person', p));
  }

  model() {
    return this.store.peekAll('person');
  }
}

```

Get error when enter the page:

```auto
Uncaught TypeError: Cannot read property 'setDirtyAttribute' of null
    at Person.set (-private.js:144)
    at ComputedProperty._set (metal.js:3543)
    at ComputedProperty.setWithSuspend (metal.js:3532)
    at ComputedProperty.set (metal.js:3503)
    at initialize (core_object.js:67)
    at Function.create (core_object.js:692)
    at new Persons (persons.js:23)
    at Function.create (core_object.js:684)
    at FactoryManager.create (container.js:549)
    at instantiateFactory (container.js:359)

```

So I have to use things like `this.store.createRecord('person', {firstName: "first1", lastName: "last1", age: 10})` rather than `this.store.createRecord('person', <a Person class instance>)`, which is not typescript-ish at all.

Any advice?
