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

Incorrectly loose types for strict object schema for non-string values #2995

Open
KristjanTammekivi opened this issue Oct 26, 2023 · 0 comments
Labels
support Questions, discussions, and general support

Comments

@KristjanTammekivi
Copy link

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: 20.0.5
  • module version with issue: 17.11.0, master branch
  • last module version without issue:
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information:

What are you trying to achieve or the steps to reproduce?

interface User2 {
  id?: number
}

Joi.object<User2, true>({
  id: Joi.string().optional()
});

What was the result you got?

No warning despite id being string

What result did you expect?

Typescript warning that string schema is not assignable to number schema

This seems to work as a fix, I would create a PR but I couldn't get the test to work correctly, it still said Expected an error even though after the change TypeScript warned about it
image

@KristjanTammekivi KristjanTammekivi added the support Questions, discussions, and general support label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

1 participant