Add comments about TS keyof and overloads
[MAILPOET-2676]
This commit is contained in:
committed by
amine-mp
parent
187c8f5ac7
commit
1026b07495
@@ -1,6 +1,13 @@
|
||||
import { Settings } from '../types';
|
||||
import useSelector from './useSelector';
|
||||
|
||||
/**
|
||||
* Takes the path of a setting (ie. key1, key2, key3,...) and returns its value.
|
||||
* Here we are declaring the signatures in case it takes 1, 2, and 3 keys.
|
||||
* Additional overloaded signatures can be added to go as deep as we want.
|
||||
* See:
|
||||
* keyof: http://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html#keyof-and-lookup-types
|
||||
* overloading functions: http://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#function-overloads
|
||||
*/
|
||||
export function useSetting<Key1 extends keyof Settings>
|
||||
(key1: Key1): Settings[Key1];
|
||||
export function useSetting<Key1 extends keyof Settings, Key2 extends keyof Settings[Key1]>
|
||||
|
@@ -1,6 +1,14 @@
|
||||
import { Settings, Action } from '../types';
|
||||
import { useAction } from './useActions';
|
||||
|
||||
/**
|
||||
* Takes the path of a setting (ie. key1, key2, key3,...) and returns its setter.
|
||||
* Here we are declaring the signatures in case it takes 1, 2, and 3 keys.
|
||||
* Additional overloaded signatures can be added to go as deep as we want.
|
||||
* See:
|
||||
* keyof: http://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html#keyof-and-lookup-types
|
||||
* overloading functions: http://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#function-overloads
|
||||
*/
|
||||
export function useSettingSetter<Key1 extends keyof Settings, Value extends Settings[Key1]>
|
||||
(key1: Key1): ((value: Value) => Promise<Action>);
|
||||
export function useSettingSetter<
|
||||
|
Reference in New Issue
Block a user