Skip to content

Joi.object<Type, Strict, Type>(....), the purpose of last Type and its presence prevents property autocomplete #3090

@skiv71

Description

@skiv71

Runtime

node.js

Runtime version

18.0.1

Module version

?

Used with

standalone

Any other relevant information

Hi, when using Joi.object with a generic TSchema, I only get autocomplete for my Types fields if I include it as follows: -

Joi.object<Type, false / true, Type>.

I checked the source...

// tslint:disable-next-line:no-unnecessary-generics
object<TSchema = any, isStrict = false, T = TSchema>(
schema?: SchemaMap<T, isStrict>
): ObjectSchema;

It appears as if T should revert to the passed TSchema and be used, but it doesn't seem to.

I hacked (sorry) the package (in situ) to <TSchema, isStrict> and removed / replaced references to T and all is well.

Am I missing something?

Kind regards,

Neil

How can we help?

const some = 'properly formatted code example';

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportQuestions, discussions, and general support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions