# Ember Data @attr options and Typescript

**URL:** <https://discuss.emberjs.com/t/ember-data-attr-options-and-typescript/19759>\
**Category:** General\
**Created:** [October 21, 2022, 9:37am UTC](https://discuss.emberjs.com/t/ember-data-attr-options-and-typescript/19759 "2022-10-21T09:37:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![roomman](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/roomman/32/17451_2.png) [@roomman](https://discuss.emberjs.com/u/roomman)\
**Post date:** [October 21, 2022, 9:37am UTC](https://discuss.emberjs.com/t/ember-data-attr-options-and-typescript/19759/1 "2022-10-21T09:37:43Z")

</div>

Hi all, have a quick question about TypeScript if anyone had the bandwidth!

I’m at the start of the journey with `ember-cli-typescript` and refactoring some Ember Data Models.

I have an enum `@attr` and I am passing some custom options down like so:

```auto
import Model, { attr } from '@ember-data/model';
import { someArrayOfStrings } from 'my-app/enumOptions';

export default class BookingModel extends Model {
  @attr('enum', {
    enumOptions: salesChannels,
    defaultValue: '',
  })
  declare salesChannel?: string;
}

declare module 'ember-data/types/registries/model' {
  export default interface ModelRegistry {
    booking: BookingModel;
  }
}

```

My Transform isn’t doing much:

```auto
import Transform from '@ember-data/serializer/transform';

declare module 'ember-data/types/registries/transform' {
  export default interface TransformRegistry {
    enum: EnumTransform;
  }
}

export default class EnumTransform extends Transform {
  deserialize(serialized: string): string {
    return serialized;
  }

  serialize(deserialized: string): string {
    return deserialized;
  }
}

```

TypeScript is complaining about the `@attr` and the error is as follows;

```auto
No overload matches this call.
  Overload 1 of 3, '(type: "enum", options?: AttrOptions<string> | undefined): ComputedProperty<string, string>', gave the following error.
    Argument of type '{ enumOptions: salesChannels[]; defaultValue: string; }' is not assignable to parameter of type 'AttrOptions<string>'.
      Object literal may only specify known properties, and 'enumOptions' does not exist in type 'AttrOptions<string>'.
  Overload 2 of 3, '(target: any, propertyKey: string): void', gave the following error.
    Argument of type '{ enumOptions: salesChannels[]; defaultValue: string; }' is not assignable to parameter of type 'string'. 
ts(2769)

```

I take it I need to update/extend `AttrOptions` are but I am unsure how to do it - any ideas?

---

<div class="post-metadata">

**Author:** ![toh995](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/toh995/32/17910_2.png) [@toh995](https://discuss.emberjs.com/u/toh995)\
**Post date:** [October 26, 2022, 5:54pm UTC](https://discuss.emberjs.com/t/ember-data-attr-options-and-typescript/19759/2 "2022-10-26T17:54:26Z")

</div>

Hey @roomman I was running into a similar situation. Added a PR that will hopefully help with this [[ember-data] additional typing for transforms by toh995 · Pull Request #62874 · DefinitelyTyped/DefinitelyTyped · GitHub](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/62874)

The PR has been merged, and after upgrading my `@types/ember-data`, the type error has gone away for me.
