diff --git a/src/Model/fn.ts b/src/Model/fn.ts index 68a72a32..c66ba73d 100644 --- a/src/Model/fn.ts +++ b/src/Model/fn.ts @@ -9,11 +9,20 @@ class NamedFns { } type StartFnParam = unknown; +// From type-fest: https://github.com/sindresorhus/type-fest +type ArrayIndices = + Exclude['length'], Element['length']>; + +type TwoWayReactiveFnSetReturnType = + Partial | + Partial<{ [K in Extract, number>]: Ins[K] }> | + null; + type ModelFn = ((...inputs: Ins) => Out) | { - get(...inputs: Ins): Out, - set(output: Out, ...inputs: Ins): {[key: number] : Ins[number]} | Ins[] | null, + get(...inputs: Ins): Out; + set(output: Out, ...inputs: Ins): TwoWayReactiveFnSetReturnType; }; interface ModelStartOptions { @@ -99,11 +108,7 @@ declare module './Model' { */ fn( name: string, - fn: (...inputs: Ins) => Out | - { - get(...inputs: Ins): Out; - set(output: Out, ...inputs: Ins): void - } + fn: ModelFn ): void; /**