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 - Cannot access static members of model with .schema() call #12322

Open
2 of 7 tasks
kvcpr opened this issue May 28, 2020 · 1 comment
Open
2 of 7 tasks

TypeScript - Cannot access static members of model with .schema() call #12322

kvcpr opened this issue May 28, 2020 · 1 comment
Labels
type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.

Comments

@kvcpr
Copy link

kvcpr commented May 28, 2020

Issue Description

When you call .schema() method of model then call static member typescript says that member doesn't exist.

What are you doing?

class TestModelWithStaticMethod extends Model {
  static someStaticFn() {
    return 'hello!';
  }
};
TestModelWithStaticMethod.init({ hello: { type: DataTypes.BOOLEAN, allowNull: false } }, { sequelize });
const testModelWithStaticMethod = TestModelWithStaticMethod.schema('some_schema');
testModelWithStaticMethod.someStaticFn();

What do you expect to happen?

Ability to use static members of model without warnings.

What is actually happening?

> tsc -b types/tsconfig.json && tsc -b types/test/tsconfig.json

types/test/model.ts:86:27 - error TS2339: Property 'someStaticFn' does not exist on type '(new () => TestModelWithStaticMethod) & typeof Model'.

86 testModelWithStaticMethod.someStaticFn();

Environment

  • Sequelize version: 5.x and 6.x
  • Node.js version: v13.2.0
  • Operating System: macOS 10.15.3
  • If TypeScript related: TypeScript version: 3.7.2

Issue Template Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.
  • I think this problem happens only for the following dialect(s):
  • I don't know, I was using PUT-YOUR-DIALECT-HERE, with connector library version XXX and database version XXX

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
@sushantdhiman sushantdhiman added the type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense. label May 30, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2021

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

@github-actions github-actions bot added the stale label Nov 2, 2021
@WikiRik WikiRik removed the stale label Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.
Projects
None yet
Development

No branches or pull requests

3 participants