-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Context
- node version: 16.15.0
- module version: 17.6.0
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...): hapi, standalone
- any other relevant information:
What problem are you trying to solve?
Artifact is documented and implemented, but not supported in the typings.
All of these fail with Property 'artifact' does not exist on type 'AnySchema<any>'. (or derived).
const x = Joi.any().artifact('any');
const s = Joi.string().artifact('string');
const o = Joi.object().artifact('object');
const a = Joi.alternatives().artifact('alternative');Related: 'artifacts' option is also missing.
const o = Joi.objec({}).options({ artifacts: true });Do you have a new or modified API suggestion to solve the problem?
See related PR.
For anybody who needs a workaround without patching the Joi dependency itself, you can put this in a type declaring file, e.g. joi.d.ts next to your source code for it to be picked up and taken into account by the typescript compiler through declaration merging.
// need the module import to extend typings
import 'joi';
declare module 'joi' {
export interface AnySchema<TSchema = any> {
artifact(id: any): this;
}
export interface BaseValidationOptions {
artifacts?: boolean;
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
typesTypeScript type definitionsTypeScript type definitions