Skip to content

Commit

Permalink
fix: allow assigning provider-enabled instances to FastifyInstance (#…
Browse files Browse the repository at this point in the history
…21)

* test(types): assign to default `FastifyInstance`

* fix(types): assign to `FastifyTypeProviderDefault`
  • Loading branch information
driimus authored Jan 8, 2023
1 parent a90a5fd commit 4e60b5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { JSONSchema7, FromSchema, FromSchemaOptions, FromSchemaDefaultOptions } from 'json-schema-to-ts'

export interface JsonSchemaToTsProvider<Options extends FromSchemaOptions = FromSchemaDefaultOptions> extends FastifyTypeProvider {
output: this['input'] extends JSONSchema7 ? FromSchema<this['input'], Options> : never;
output: this['input'] extends JSONSchema7 ? FromSchema<this['input'], Options> : unknown;
}

/**
Expand Down
1 change: 1 addition & 0 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Fastify, { FastifyInstance, FastifyLoggerInstance, RawReplyDefaultExpress

const fastify = Fastify().withTypeProvider<JsonSchemaToTsProvider>()
expectAssignable<FastifyInstance<RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, FastifyLoggerInstance, JsonSchemaToTsProvider>>(fastify)
expectAssignable<FastifyInstance>(fastify)

fastify.get('/', {
schema: {
Expand Down

0 comments on commit 4e60b5b

Please sign in to comment.