diff --git a/src/cell.ts b/src/cell.ts index e44bb6f..8f4266c 100644 --- a/src/cell.ts +++ b/src/cell.ts @@ -796,14 +796,14 @@ export class ValueCell extends Cell { * @todo throw an error if fn fails? * @todo make it concurrency-friendly */ - update = ( - fn: (v: V) => V | Promise | AnyCell | Promise> - ) => { + update = | AnyCell | Promise>>( + fn: (v: V) => Ret + ): Ret => { if (this.isPointer) { // The following implementation updates the pointed cell, but // we might want to detach the pointed cell and update that cell // directly. - const cell = this._sheet.get(this.pointed); + const cell = this._sheet.get(this.pointed) as ValueCell; if (cell instanceof ValueCell) return cell.update(fn); // @todo We could implement a cancellation of the pointed cell (supposedly pending) // to force setting a new value. @@ -822,6 +822,7 @@ export class ValueCell extends Cell { const nv = fn(v); // We ignore undefined values (but not cell nor promises). if (nv !== undefined) this.set(nv); + return nv; }; /**