fastify / env-schema

Validate your env variable using Ajv and dotenv
MIT License
212 stars 25 forks source link

`customOptions` is not typed, so TypeScript is giving errors #97

Closed dietergeerts closed 2 years ago

dietergeerts commented 2 years ago

Prerequisites

Fastify version

N/A

Plugin version

"env-schema": "^3.5",

Node.js version

14

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

N/A

Description

Following error when using customOptions:

TS2322: Type '{ customOptions(ajvInstance: any): any; }' is not assignable to type 'Ajv'.   Object literal may only specify known properties, and 'customOptions' does not exist in type 'Ajv'

Because it's not in the types.

Steps to Reproduce

Just use customOptions in a TS file

Expected Behavior

Typings know about this extra feature, so there are no TS errors

Eomm commented 2 years ago

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

dietergeerts commented 2 years ago

@Eomm , I can take a look yes, but I never have written unit tests that specifically are testing types, but I assume I will find some in here to compare how to do that.