Skip to content

Incorrect typing of idColumn #2693

@jackbonaguro

Description

@jackbonaguro

According to documentation, idColumn should be set to null in the event a table does not have an id column: https://vincit.github.io/objection.js/api/model/static-properties.html#static-idcolumn

But due to the typings, null is not a possible valid value for idColumn - only string | string[]:

static idColumn: string | string[];

This causes an issue in my code on version 3.1.4. Doing either:

static idColumn = null;

or

static get idColumn() {
    return null;
}

Results in a compiler error:

  Types of property 'idColumn' are incompatible.
    Type 'null' is not assignable to type 'string | string[]```

Only by casting like `static idColumn = null as unknown as string;` can I work around the issue. Not setting idColumn causes runtime errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions