Skip to content

Typing issues with attempt() #2857

@schw4rzlicht

Description

@schw4rzlicht

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: 14.19.3
  • module version with issue: 17.6.1 / 17.6.2
  • last module version without issue: 17.6.0
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): ?
  • any other relevant information: n/a

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

let apiKey: string | undefined = "someString";
apiKey = Joi.attempt(apiKey, Joi.string().optional().label("apiKey"));

What was the result you got?

TS2322: Type 'unknown' is not assignable to type 'string | undefined'.

What result did you expect?

No TS errors.

I suspect the changes from #2797 to be the root cause.

Metadata

Metadata

Assignees

Labels

supportQuestions, discussions, and general supporttypesTypeScript type definitions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions