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

Typescript models do not have relationship functions #2112

Open
thirionlogan opened this issue Aug 16, 2021 · 1 comment
Open

Typescript models do not have relationship functions #2112

thirionlogan opened this issue Aug 16, 2021 · 1 comment

Comments

@thirionlogan
Copy link

Introduction

When I make a simple belongsTo relationship on a model, I get an error that states Property 'belongsTo' does not exist on type 'Object | typeof Model'.

Steps to reproduce issue

Example:

export const Page = bookshelf.model('Page', {
  tableName: 'page',
  book() {
    return this.belongsTo(Book);
  },
});

Expected behaviour

I expect to be able to use belongsTo without typescript errors

Actual behaviour

When defining a model in a typescript file, belongsTo gets a ts(2339) error: Property 'belongsTo' does not exist on type 'Object | typeof Model'.

@SirPhemmiey
Copy link

Hey, did you fix this? I'm having the same issue also

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