diff --git a/src/Model/fn.ts b/src/Model/fn.ts index 6d15b9ff..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 | + ((...inputs: Ins) => Out) | { - get(...inputs: Ins): Out, - set(output: Out, ...inputs: Ins): void, + 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; /**