UNPKG

1.94 kBTypeScriptView Raw
1/**
2 * Safely invoke the member function with no arguments, if the object
3 * exists and the given key is indeed a function, and return its value.
4 * Otherwise, return `undefined`.
5 *
6 * @deprecated use TypeScript 3.7+ optional chaining and optional call operator obj?[key]?.()
7 */
8export declare function safeInvokeMember<T extends {
9 [k in K]?: () => R;
10}, K extends keyof T, R = void>(obj: T | undefined, key: K): R | undefined;
11/**
12 * Safely invoke the member function with one argument, if the object
13 * exists and the given key is indeed a function, and return its value.
14 * Otherwise, return `undefined`.
15 *
16 * ```js
17 * // example usage
18 * safeInvokeMember(this.props.inputProps, "onChange", evt);
19 * ```
20 *
21 * @deprecated use TypeScript 3.7+ optional chaining and optional call operator obj?[key]?.()
22 */
23export declare function safeInvokeMember<T extends {
24 [k in K]?: (a: A) => R;
25}, K extends keyof T, A, R = void>(obj: T | undefined, key: K, arg1: A): R | undefined;
26/**
27 * Safely invoke the member function with two arguments, if the object
28 * exists and the given key is indeed a function, and return its value.
29 * Otherwise, return `undefined`.
30 *
31 * @deprecated use TypeScript 3.7+ optional chaining and optional call operator obj?[key]?.()
32 */
33export declare function safeInvokeMember<T extends {
34 [k in K]?: (a: A, b: B) => R;
35}, K extends keyof T, A, B, R = void>(obj: T | undefined, key: K, arg1: A, arg2: B): R | undefined;
36/**
37 * Safely invoke the member function with three arguments, if the object
38 * exists and the given key is indeed a function, and return its value.
39 * Otherwise, return undefined.
40 *
41 * @deprecated use TypeScript 3.7+ optional chaining and optional call operator obj?[key]?.()
42 */
43export declare function safeInvokeMember<T extends {
44 [k in K]?: (a: A, b: B, c: C) => R;
45}, K extends keyof T, A, B, C, R = void>(obj: T | undefined, key: K, arg1: A, arg2: B, arg3: C): R | undefined;