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

Using typescript and import gives type error: No overload matches this call. #171

Open
sveisvei opened this issue Jul 17, 2022 · 3 comments

Comments

@sveisvei
Copy link

  import pinoHapiPlugin from "hapi-pino";

  server.register({
    plugin: pinoHapiPlugin,
    options: {
     // ...options
    },
  });

Will give type error

No overload matches this call.
  The last overload gave the following error.
    Argument of type '{ plugin: Hapi.Plugin<pinoHapiPlugin.Options>; options: { level: pino.Level; logRequestComplete: boolean; prettyPrint: boolean; redact: string[]; ignorePaths: string[]; instance: pino.Logger<...> | undefined; }; }' is not assignable to parameter of type 'Plugin<any> | Plugin<any>[]'.
      Object literal may only specify known properties, and 'plugin' does not exist in type 'Plugin<any> | Plugin<any>[]'.ts(2769)
index.d.ts(3886, 5): The last overload is declared here.

While getting no typescript error if using require:

  server.register({
    plugin: require("hapi-pino"),
    options: {
     // ...options
    },
  });
@mcollina
Copy link
Collaborator

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

@jonathansamines
Copy link
Contributor

@sveisvei I think you can use the import * syntax instead:

import * as HapiPino from 'hapi-pino';

@mcollina I looked it up and seems like this is solvable by changing the export syntax, though from typescript docs seems like the change would not be backwards compatible (See docs). Not really sure we can simply change this without breaking existing consumers.

@mcollina
Copy link
Collaborator

I'm not actively using this module nor typescript, so I'd defer to your best recommendation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants