Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are no type descriptions for server properties #3942

Closed
2 tasks done
budarin opened this issue May 29, 2022 · 9 comments
Closed
2 tasks done

There are no type descriptions for server properties #3942

budarin opened this issue May 29, 2022 · 9 comments
Labels
good first issue Good for newcomers typescript TypeScript related

Comments

@budarin
Copy link
Contributor

budarin commented May 29, 2022

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.0.0-rc.3

Description

There are no type descriptions for server properties:

It is possible that other instance properties are not typed

Steps to Reproduce

image

Expected Behavior

Availability of type descriptions for the specified properties

@mcollina
Copy link
Member

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

@mcollina mcollina added documentation Improvements or additions to documentation good first issue Good for newcomers labels May 29, 2022
@budarin
Copy link
Contributor Author

budarin commented May 29, 2022

By the way, they are not present at all in the instance of fastify

const fastify = require('fastify')({
    logger: true,
});

// Declare a route
fastify.get('/', function (req, reply) {
    const { pluginName, validatorCompiler, serializerCompiler } = fastify;

    req.log.info(`${typeof pluginName}, ${typeof validatorCompiler}, ${typeof serializerCompiler}`);

    reply.send({ hello: 'world' });
});

here are the log entries

{"level":30,"time":1653837768101,"pid":25388,"hostname":"WIN-40K96OG4L3A","msg":"Server listening at http://127.0.0.1:3000"}
{"level":30,"time":1653837770753,"pid":25388,"hostname":"WIN-40K96OG4L3A","reqId":"req-1","req":{"method":"GET","url":"/","hostname":"127.0.0.1:3000","remoteAddress":"127.0.0.1","remotePort":55850},"msg":"incoming request"}
{"level":30,"time":1653837770755,"pid":25388,"hostname":"WIN-40K96OG4L3A","reqId":"req-1","msg":"undefined, undefined, undefined"}
{"level":30,"time":1653837770770,"pid":25388,"hostname":"WIN-40K96OG4L3A","reqId":"req-1","res":{"statusCode":200},"responseTime":15.357467889785767,"msg":"request completed"}

@mcollina
Copy link
Member

mcollina commented May 30, 2022

pluginName is expected to be undefined for the root object. I'm going to change it to 'fastify' so that's it's clearer.

As for validatorCompiler and serializerCompiler I'm unsure. I tried to play around and I got a few undefined too. Take a look at https://github.com/fastify/fastify/blob/main/test/schema-feature.test.js, it should provide some guidance. @Eomm wdyt?

mcollina added a commit that referenced this issue May 30, 2022
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Ref: #3942
mcollina added a commit that referenced this issue May 30, 2022
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Ref: #3942
@mcollina
Copy link
Member

@Eomm could you look into validatorCompiler and serializerCompiler?

@Eomm
Copy link
Member

Eomm commented May 31, 2022

Yes, those types are missing and only the input is mapped actually

@Eomm Eomm added typescript TypeScript related and removed documentation Improvements or additions to documentation labels May 31, 2022
@TommyDew42
Copy link
Contributor

Hi, is @budarin working on this issue? If we need someone to work on it, I’m happy to help!!

@mcollina
Copy link
Member

@TommyDew42 I think you can take it!

@budarin
Copy link
Contributor Author

budarin commented Jun 19, 2022

@TommyDew42

Unfortunately I don't know enough about the internal implementation of fastify to solve this problem (

@denes-fekeshazy
Copy link
Contributor

Looks like there is a merged PR for this. Should this issue be closed or is there more work to do on this?

@mcollina mcollina closed this as completed Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers typescript TypeScript related
Projects
None yet
Development

No branches or pull requests

5 participants