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 issue with where function #10724

Closed
samalexander opened this issue Apr 8, 2019 · 6 comments
Closed

Typescript issue with where function #10724

samalexander opened this issue Apr 8, 2019 · 6 comments
Labels
released type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.

Comments

@samalexander
Copy link
Contributor

samalexander commented Apr 8, 2019

What are you doing?

When calling sequelize.where and passing a condition that contains an operator symbol, a typescript error occurs. For example:

where('createdAt', {
    [Op.lt]: new Date()
})

This code was previously working when using @types/sequelize for typescript definitions. The move to built-in type LogicType for the logic parameter has caused the issue.

I have created a minimal reproduction here.

What do you expect to happen?

To accept the use of an operator symbol when building a where condition.

What is actually happening?

A typescript error:

Argument of type '{ [Op.lt]: Date; }' is not assignable to parameter of type 'LogicType'.
  Object literal may only specify known properties, and '[Op.lt]' does not exist in type 'AndOperator | OrOperator | Fn | Col | Literal'.

Dialect: any
Dialect version: n/a
Database version: n/a
Sequelize version: 5.2.12
Tested with latest release: Yes - as above

@SimonSchick SimonSchick added the type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense. label Apr 8, 2019
@SimonSchick
Copy link
Contributor

@sushantdhiman can you clarify on the nature of where and/or Utils.Where? Documentation for it is a little vague and partially misleading (refering to Symbols as default values while actually using = etc.).

@sushantdhiman
Copy link
Contributor

🎉 This issue has been resolved in version 5.2.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

@IMalaniak
Copy link

The same error is in 6.x now

@tanmayaBiswalOdiware
Copy link

tanmayaBiswalOdiware commented Sep 6, 2023

Dude this error still exists in v6.3 and typescript is crying about it. 😖

@ephys
Copy link
Member

ephys commented Dec 13, 2023

The typings surrounding that utility were completely rewritten since 6.3. The issue may be fixed in v6.35.2+ and/or v7.0.0-alpha.34+

@tanmayaBiswalOdiware
Copy link

It seems to have fixed itself for now. Was on 6.32.1 version. Still on same version but works now. So shrug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.
Projects
None yet
Development

No branches or pull requests

6 participants