You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.12.0
Plugin version
5.7.1
Node.js version
18.12.1
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
11
Description
I have a fastify TS project and I use autoload to load both plugins and routes automatically.
This is my app.ts:
conststart=async()=>{constapp=fastify(fastifyOptions);// This autoload function has the problem of not able to load the typescript namespace declaration, so when compiling error is risen.awaitapp.register(autoLoad,{dir: path.join(__dirname,'plugins'),});app.register(autoLoad,{dir: path.join(__dirname,'routes'),});app.get('/',async()=>{return{hello: 'world'};});awaitapp.listen({port: app.conf.PORT});app.blipp();};start();
I run the app in dev mode with the next command:
ts-node-dev ./src/index.ts
The problem is that upon start typescript complains of the following error:
server:dev: src/index.ts(22,32): error TS2339: Property 'conf' does not exist on type'FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<...>'.
server:dev: src/index.ts(23,7): error TS2339: Property 'blipp' does not exist on type'FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<...>'
This errors only happen when having "--transpile-only" ts-node option disabled.
Also, removing autoload plugin and importing the plugins individually works as well (without the transpile-only option).
An example of how fastify module is extended can be seen in the following snippet:
Prerequisites
Fastify version
4.12.0
Plugin version
5.7.1
Node.js version
18.12.1
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
11
Description
I have a fastify TS project and I use autoload to load both plugins and routes automatically.
This is my app.ts:
I run the app in dev mode with the next command:
ts-node-dev ./src/index.ts
The problem is that upon start typescript complains of the following error:
This errors only happen when having "--transpile-only" ts-node option disabled.
Also, removing autoload plugin and importing the plugins individually works as well (without the transpile-only option).
An example of how fastify module is extended can be seen in the following snippet:
Important to note than plugin downloaded from packages with types declaration DO NOT work either.
Steps to Reproduce
(It works without transpiling or by importing plugins "by-hand")
Expected Behavior
FastifyInstance interface should be extended with new declared properties upon loading the plugins.
The text was updated successfully, but these errors were encountered: