Property 'config' does not exist on type 'FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>'.
- Dominant language
- JavaScript
- Stars
- 243
- Forks
- 26
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
### Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the bug has not already been reported
### Fastify version
^4.24.2"
### Plugin version
^4.2.0
### Node.js version
v18.12.0
### Operating system
macOS
### Operating system version (i.e. 20.04, 11.3, 10)
14.0 (23A344)
### Description
The code structure is created with fastify-cli using typescript template.
```ts
// file: authorization.ts
import { FastifyInstance } from "fastify"
const authorization = async (fastify:FastifyInstance, opts) => {
const { httpErrors, config } = fastify // got error: Property 'config' does not exist on type 'FastifyInstance, FastifyBaseLogger, FastifyTypeProviderDefault>'.
}
```
### Steps to Reproduce
The code structure is created with fastify-cli using typescript template.
maybe the error is cause by `@fastify/env` not extending the fastify instance object like this
```ts
declare module 'fastify' {
export interface FastifyInstance {
someSupport(): string;
}
}
```
My code
```ts
// file: authorization.ts
import { FastifyInstance } from "fastify"
const authorization = async (fastify:FastifyInstance, opts) => {
const { httpErrors, config } = fastify // got error: Property 'config' does not exist on type 'FastifyInstance, FastifyBaseLogger, FastifyTypeProviderDefault>'.
}
```
I already registerred the "@fastify/env"
```ts
// file: app.ts
import Env from "@fastify/env"
const app: FastifyPluginAsync = async (
fastify,
opts
): Promise => {
// Place here your custom code!
// env
void fastify.register(Env, {
schema: S.object()
.prop("NODE_ENV", S.string().default("development"))
.valueOf(),
})
```
is it bec
### Expected Behavior
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.