Skip to content

Enhancing typescript safety in model class by removing generic property declaration #1759

@joris-gallot

Description

@joris-gallot

Environment

No response

Reproduction

I don't think we need a reproduction link for this

Describe the bug

The Model class has this line [s: keyof ModelFields]: any;, which I think is problematic because it allows us to use any property of the model without typescript errors. I think we should remove this line. Is there a specific reason for keeping it?

For example for this Foo model, we should get this ts error: Property 'bar' does not exist on type 'Foo'..., while in the example, bar is typed as any

export class Foo extends Model {
  @Uid() id!: number;
}

const foo = new Foo();
foo.bar; //  typed as any

Current behavior
Capture d’écran 2024-01-10 à 10 13 36

Expected behavior
Capture d’écran 2024-01-10 à 10 13 54

Additional context

I'm putting this issue here for discussion, but I can tackle this task if needed 😁

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions