Closed alvis closed 4 years ago
@alvis can you propose a fix PR to the types? In addition i noticed the types actually suggest that the Client class is exported when it isn't.
ping @theogravity who contributed the types in the first place.
Register is defined here:
Did you try specifying the Client as the generic impl?
const issuer = new Issuer<Client>();
Might be possible to not have to do this by specifying a default for the generic def in the definitions:
export class Issuer<TClient extends Client = Client>
Try that out and issue a PR if it fixes it.
Okay, couple of issues i'd like to see a PR for
1) DeviceFlowHandle is not exported by the library but is in the types 2) Client is not exported by the library but is in the types 3) make sure the Client methods mentioned here are available by default
DeviceFlowHandle
even if it's not exported (eg. in tests, or it's returned by some other lib call).it is already in there as noted in my response above
until the following code passes type checks i wouldn't call it "there"
const issuer = new Issuer();
issuer.Client.register({});
You still need the typing info for it
type Client = InstanceType<Issuer['Client']>;
I'd expect the following to work to get your typing info. And DeviceFlowHandle
can easily be an exported interface that DeviceFlowHandle
implements.
Right, which is why I said this prob fixes it (it would use the Client interface as the default):
export class Issuer<TClient extends Client = Client>
It doesn't from what i was able to test.
I'll take a look
Thank you Theo
Closing this as stale
, feel free to come up with a PR to unblock this mess.
@theogravity poke
It only affects typescript users.
Currently, if you create an issuer, typescript would complain if you use the client register function. e.g.
It's due to the type definition on Issuer that the type definition of Client is not typeof Client. Therefore, all the static methods are missing. See below:
https://github.com/panva/node-openid-client/blob/dd2194e8680af9a9b996a1973618999e1d821f01/types/index.d.ts#L517-L523
https://github.com/panva/node-openid-client/blob/dd2194e8680af9a9b996a1973618999e1d821f01/types/index.d.ts#L507-L511