-
Notifications
You must be signed in to change notification settings - Fork 204
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
fix(credentials): typing if no modules provided #1188
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,3 +193,8 @@ export type FlatArray<Arr> = Arr extends ReadonlyArray<infer InnerArr> ? FlatArr | |
* Get the awaited (resolved promise) type of Promise type. | ||
*/ | ||
export type Awaited<T> = T extends Promise<infer U> ? U : never | ||
|
||
/** | ||
* Type util that returns `true` or `false` based on whether the input type `T` is of type `any` | ||
*/ | ||
export type IsAny<T> = unknown extends T ? ([keyof T] extends [never] ? false : true) : false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at this makes me think that this should not work, but it does haha. Quite interesting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this comes straight from Stack overflow. No idea why it works. I can add a link to th so post though |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This confuses me a bit.
It seems like we are checking if the CustomModuleType is supplied and if so, we use the
DefaultModuleType['api']
. Should that not beCustomModuleType['api']
and if not, maybe we should rename that type if we also use it for custom modules.Small note, I am not very familiar with the generic module type setup so I might have missed something ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is a bit weird. If the custom module type is of type
any
(which is the case when you provide nomodules
key) it will pick type any for the credentials module. So what we do here is check if the CustomModuleType is any, and if that is the case we don't want to use it, because it will type theagent.credentials
object as any, and we pick the default one. Hope that makes sense?