Skip to content

Static methods are not being passed to return type of scope #873

Open
@shwao

Description

@shwao

Versions

  • sequelize: 6.3.5
  • sequelize-typescript: 2.0.0-beta.1
  • typescript: 4.1.3

I'm submitting a ...

[x] bug report
[ ] feature request

Actual behavior:

I'm adding a static method to a model and want to use it together with the scope method. Eg. ModelName.scope("scopeName").staticMethod() but TypeScript is showing an error Property 'staticMethod' does not exist on type 'ModelCtor<ModelName>'.

This is a regression from sequelize-typescript version 2.0.0-beta.0 where this worked fine.

Expected behavior:

The expected behaviour would be that the return type of the scope method contains the static method.

Steps to reproduce:

Add a static method to a model and try to use it together with scope.

Related code:

import { Column, Model, Scopes, Table } from "sequelize-typescript";

@Table
@Scopes(() => ({
	scopeName: {},
}))
export class ModelName extends Model
{
	@Column
	columnName: string;

	static staticMethod(): string
	{
		return "do something";
	}
}

// This works
ModelName.staticMethod();

// This does not work. `Property 'staticMethod' does not exist on type 'ModelCtor<ModelName>'.ts(2339)`
ModelName.scope("scopeName").staticMethod();

I think this code should be enough but im willing to create a SSCCE if thats necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions