Added missing models key to SubscriberMap and made actions optional.

The `Subscriber` union type of which `SubscriberMap` is a component was missing the optional `models` parameter document here at [#declarative-and-programmatic-usage](https://docs.strapi.io/dev-docs/backend-customization/models#declarative-and-programmatic-usage).

I added the optional field by intersecting it with the original type formulation, and also made the `Action` keys optional, since not all of the 18 individual actions should necessarily be specified when making a `SubscriberMap`.
This commit is contained in:
S Knutsen 2023-08-29 12:00:00 +02:00 committed by GitHub
parent ba1b99b408
commit 96db3913df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,9 @@ import { Event, Action } from '../';
type SubscriberFn = (event: Event) => Promise<void> | void;
type SubscriberMap = {
[k in Action]: SubscriberFn;
models?: string[],
} & {
[k in Action]?: SubscriberFn;
};
export type Subscriber = SubscriberFn | SubscriberMap;