Skip to content

TypeScript does not flag type mismatch in Sequelize findOne method #1734

Open
@Co-7

Description

@Co-7

Hello 👋, first of all, please excuse me if my issue has already been reported, but I don't know what to search for to find it, hence my issue.

I am using the following package versions :

{
  "sequelize": "^6.37.3",
  "sequelize-typescript": "^2.1.6",
  "ts-node": "^10.9.2",
  "typescript": "^5.5.4",
  "typescript-eslint": "^8.0.0",
  "@eslint/js": "^9.8.0",
  "@stylistic/eslint-plugin-ts": "^2.6.1",
  "@types/eslint": "^9.6.0",
  "@types/node": "^22.1.0",
  "@types/validator": "^13.12.0",
  "@typescript-eslint/eslint-plugin": "^8.0.0",
  "@typescript-eslint/parser": "^8.0.0",
  "eslint": "^9.8.0"
}

The problem I'm encountering is that in my findOne method, I set a where clause on the username field and during a refactor, I changed the username to the id but forgot to change the key and only changed the value like this :

const user: User = await User.findOne({
  where: {
    username: claims.id,
  },
});

As you can see in the screenshots, my IDE correctly indicates that username expects a string and claims.id is a number. However, I don't understand why it doesn't flag this as an issue like it usually does, for example, with upsert methods.

  • Type username :

Image

  • Type claims.id :

Image

Once again, I'm not sure if this is the right place to report this, but since it concerns a Sequelize method and TypeScript, I thought you might be able to help. Thank you 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions