fastify / fastify-auth

Run multiple auth functions in Fastify
Other
345 stars 56 forks source link

default imports do not work with TypeScript #107

Closed khol341 closed 2 years ago

khol341 commented 3 years ago

Prerequisites

Fastify version

3.x

Plugin version

1.1.0

Node.js version

14.x

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

10

Description

When trying to use this import in TS using the latest fastify-auth version:

import fastifyAuth from 'fastify-auth';
app
    .register(fastifyJwt, { secret: 'secret' })
    .register(fastifyAuth)

, it actually doesn't work anymore and throws an error: error TS2339: Property 'auth' does not exist on type 'FastifyInstance'. This is not a problem when using the older version.

I see a similar issue was posted for fastify-jwt here which still replicates.

Steps to Reproduce

Try to import plugin using named import in TypeScript.

Expected Behavior

Named import should work.

mcollina commented 3 years ago

cc @fastify/typescript

climba03003 commented 3 years ago

Please use esModuleInterop for tsconfig.json.

{
  "compilerOptions": {
    "esModuleInterop": true,
  }
}
mmarkell commented 2 years ago

@climba03003 that does not fix the issue. Still getting the same error.

climba03003 commented 2 years ago

@climba03003 that does not fix the issue. Still getting the same error.

Please provide a repro for your issue. TypeScript behave differently depends on version, how you use and configuration.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.