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

Cannot use CredentialsEncodingMode in typescript #429

Open
TimFroidcoeur opened this issue Mar 3, 2023 · 1 comment
Open

Cannot use CredentialsEncodingMode in typescript #429

TimFroidcoeur opened this issue Mar 3, 2023 · 1 comment

Comments

@TimFroidcoeur
Copy link

I'm trying to use CredentialsEncodingMode.LOOSE, as follows:

import {ClientCredentials, AccessToken, CredentialsEncodingMode} from "simple-oauth2";
...
    this.oauth2 = new ClientCredentials(
        {
          client: {
            id: username,
            secret: password,
          },
          auth: {
            tokenHost: this.HOST,
            tokenPath: "/authentication/api/token",
          },
          options: {
            credentialsEncodingMode: CredentialsEncodingMode.LOOSE,
          },
        }
    );

and I get a runtime error

TypeError: Cannot read properties of undefined (reading 'LOOSE')

I'm not an expert in how typescript works, but according to https://ncjamieson.com/dont-export-const-enums/ this is an inherent limitation of exporting a const enum.

I am using the following as a workaround:

            // @ts-ignore
            credentialsEncodingMode: "loose",

maybe the exported enums should be non-const?

@jonathansamines
Copy link
Collaborator

Hey @TimFroidcoeur. We don't provide type definitions for this library, that means you are probably getting them from DefinitelyTyped. I'd open an issue/PR there instead.

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

2 participants