Open ymao1 opened 2 years ago
Pinging @elastic/response-ops (Team:ResponseOps)
It seems like more APIs should accept some sort of T extends ActionType<any, any, any, any>
rather than having four generic parameters everywhere with defaults assigned... That being said there are tons of APIs and my knowledge about why this direction was chosen is basically zero. Normally when I design APIs like this I do something like this:
type AnyActionType = ActionType<any, any, any, any>
type ActionTypeSecrets<T extends AnyActionType> = T extends ActionType<any, infer X, any, any> ? X : never
and then extract the Secrets
type as necessary from the single generic, in a method like:
async getSecrets<A extends AnyActionType>(type: A): Promise<ActionTypeSecrets<A>> {
...
}
With the latest Typescript version bump PR,
in
x-pack/plugins/actions/server/action_type_registry.ts
caused this Typescript error:
Temporary workaround was to do this:
but we should fix it for real