fastify / fastify/env-schema

Use with fluent-json-schema now requires to call valueOf in ObjectSchema when using Typescript

Open
#138 7 comments 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
JavaScript
Stars
266
Forks
30
PR merge metrics
No merged PRs in 30d

Description

### Prerequisites

- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the regression has not already been reported

### Last working version

5.1.0

### Stopped working in version

5.1.1

### Node.js version

18.x

### Operating system

macOS

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

12.3

### 💥 Regression Report

Typings in Typescript now throw an error when using a `fluent-json-schema` generated schema as input for `envSchema`

### Steps to Reproduce

In a Typescript file the next block of code reproduces the issue

```ts
import envSchema from 'env-schema'
import S from 'fluent-json-schema'

envSchema({
schema: S.object()
})
```

```
Type 'ObjectSchema' is not assignable to type 'AnySchema | UncheckedJSONSchemaType | undefined'.
Type 'ObjectSchema' is not assignable to type '{ type: "object"; additionalProperties?: boolean | UncheckedJSONSchemaType | undefined; unevaluatedProperties?: boolean | UncheckedJSONSchemaType | undefined; ... 7 more ...; maxProperties?: number | undefined; } & { ...; } & { ...; } & { ...; }'.
Property 'type' is missing in type 'ObjectSchema' but required in type '{ type: "object"; additionalProperties?: boolean | UncheckedJSONSchemaType | undefined; unevaluatedProperties?: boolean | UncheckedJSONSchemaType | undefined; ... 7 more ...; maxProperties?: number | undefined; }'.ts(2322)
```

Nevertheless the following block of code does not throw an error

```ts
import envSchema from 'env-schema'
import S from 'fluent-json-schema'

envSchema({
schema: S.object().valueOf
})
```

### Expected Behavior

As `ObjectSchema` from `fluent-json-schema` was removed from typings in #137 it might be solved otherwise or maybe be documented to avoid future confusion

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.