Skip to content

JsonApiModel mapped typing #265

Description

@piotrpalek

Hey I think the JsonApiModel type isn't entirely correct, or very possibly I'm just not understanding it.

It has this in it's type / class declaration: [key: string]: any;, but this causes the models to accept any properties, even ones not listed on the model, for eg:

export class User extends JsonApiModel{
  @Attribute()
  name: string;
}

const user = datastore.createRecord(User);
user.name = 'someName'; // this is correct and should work
user.anything = true; // this IMO should throw an error in TS but doesn't because of [key: string]: any;

So my question is, should this be changed? Or does it serve a purpose I'm just not understanding?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions