add case for optional parameter

pull/7442/head
Simon H 4 years ago committed by GitHub
parent 3cb9dcf186
commit 1a2119715d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -32,7 +32,7 @@ export type ActionReturn<Parameter = any> = void extends Parameter
* The following example defines an action that only works on `<div>` elements
* and optionally accepts a parameter which it has a default value for:
* ```ts
* export const myAction: Action<HTMLDivElement, { someProperty: boolean }> = (node, param = { someProperty: true }) => {
* export const myAction: Action<HTMLDivElement, undefined | { someProperty: boolean }> = (node, param = { someProperty: true }) => {
* // ...
* }
* ```
@ -44,4 +44,6 @@ export type ActionReturn<Parameter = any> = void extends Parameter
export type Action<Element = HTMLElement, Parameter = any> =
void extends Parameter
? <Node extends Element>(node: Node) => void | ActionReturn<Parameter>
: undefined extends Parameter
? <Node extends Element>(node: Node, parameter?: Parameter) => void | ActionReturn<Parameter>
: <Node extends Element>(node: Node, parameter: Parameter) => void | ActionReturn<Parameter>;

Loading…
Cancel
Save