Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect typing of idColumn #2693

Open
jackbonaguro opened this issue Sep 4, 2024 · 1 comment
Open

Incorrect typing of idColumn #2693

jackbonaguro opened this issue Sep 4, 2024 · 1 comment

Comments

@jackbonaguro
Copy link

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.
@lehni
Copy link
Collaborator

lehni commented Sep 25, 2024

Thanks for pointing this out @jackbonaguro. I'm happy to accept a PR that fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants