Skip to content

TypeScript Error: Type 'P' does not satisfy the constraint 'Params'. Type 'P' is not assignable to type 'ParamsArray'. #203

Closed
@nathan815

Description

@nathan815
  • node version - 13.14.0
  • celebrate version - 13.0.4
  • joi version (via npm ls --depth=0 | grep joi) - 17.3.0
  • express version - 4.17.1
  • @types/express version - 4.17.6

My joi schema looks like this:

not applicable

The issue I am having with celebrate is:

I am getting this Typescript compilation error as soon as I import celebrate:

node_modules/celebrate/lib/index.d.ts(26,77): error TS2344: Type 'P' does not satisfy the constraint 'Params'.
  Type 'P' is not assignable to type 'ParamsArray'.
node_modules/celebrate/lib/index.d.ts(40,23): error TS2344: Type 'P' does not satisfy the constraint 'Params'.
  Type 'P' is not assignable to type 'ParamsArray'.
node_modules/celebrate/lib/index.d.ts(84,196): error TS2344: Type 'P' does not satisfy the constraint 'Params'.
  Type 'P' is not assignable to type 'ParamsArray'.
node_modules/celebrate/lib/index.d.ts(94,146): error TS2344: Type 'P' does not satisfy the constraint 'Params'.
  Type 'P' is not assignable to type 'ParamsArray'.

Not sure how exactly to fix this yet, but:

  1. Here is the TS declaration in celebrate/lib/index.d.ts:84:
export declare function celebrate<P=ParamsDictionary, ResBody=any, ReqBody=any, ReqQuery=Query>(
   requestRules: SchemaOptions, joiOpts?: ValidationOptions, opts?: CelebrateOptions
): RequestHandler<P, ResBody, ReqBody, ReqQuery>;
                  ^
  1. These generic declarations were introduced in PR Add generic celebrate function declaration #200 about a month ago.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions