Skip to content

Incorrect default export for TypeScript #42

@mfpopa

Description

@mfpopa

🐛 Bug Report

The default export in index.s.ts is incorrect.

It works with require('fastify-oauth2'), but it is buggy when used with import * as fastifyOAuth2 from 'fastify-oauth2' because the it forces us to do fastifyOAuth2.default which is undefined.

It should be export = fastifyOauth2 like all other Fastify plugins so it works consistently for everyone, regardless if they use require, import * as ... or import fastifyOauth2 with esModuleInterop: true.

To Reproduce

Steps to reproduce the behavior:

import * as fastifyOAuth2 from 'fastify-oauth2';

console.log(fastifyOAuth2.LINKEDIN_CONFIGURATION); // Property 'LINKEDIN_CONFIGURATION' does not exist on type 'typeof import("<my project path>/node_modules/fastify-oauth2/index")'.ts(2339)

console.log(fastifyOAuth2.default); // undefined

Expected behavior

A clear and concise description of what you expected to happen.

import * as fastifyOAuth2 from 'fastify-oauth2';

console.log(fastifyOAuth2.LINKEDIN_CONFIGURATION); // See expected output below which works when using require().
// {
//   authorizeHost: 'https://www.linkedin.com',
//   authorizePath: '/oauth/v2/authorization',
//   tokenHost: 'https://www.linkedin.com',
//   tokenPath: '/oauth/v2/accessToken'
// }

Your Environment

  • node version: 12.16.3
  • fastify version: 2.13.1
  • os: Windows 10

Fix

I am happy to submit a PR if necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions