simple-oauth2
simple-oauth2 copied to clipboard
Cannot use CredentialsEncodingMode in typescript
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?
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.