diff --git a/CHANGELOG.md b/CHANGELOG.md index 29d1dcc956..de4d0dd104 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased](https://github.com/o1-labs/o1js/compare/6a1012162...HEAD) +### Fixes + +- Fix type inference for `method.returns(Type)`, to require a matching return signature https://github.com/o1-labs/o1js/pull/1653 + ## [1.2.0](https://github.com/o1-labs/o1js/compare/4a17de857...6a1012162) - 2024-05-14 ### Added diff --git a/src/lib/mina/zkapp.ts b/src/lib/mina/zkapp.ts index c4ecefb141..84e73cc286 100644 --- a/src/lib/mina/zkapp.ts +++ b/src/lib/mina/zkapp.ts @@ -19,6 +19,7 @@ import { import { cloneCircuitValue, FlexibleProvablePure, + InferProvable, } from '../provable/types/struct.js'; import { Provable, @@ -170,12 +171,14 @@ function method( * } * ``` */ -method.returns = function ( - returnType: Provable -) { +method.returns = function < + K extends string, + T extends SmartContract, + R extends Provable +>(returnType: R) { return function decorateMethod( target: T & { - [k in K]: (...args: any) => Promise; + [k in K]: (...args: any) => Promise>; }, methodName: K & string & keyof T, descriptor: PropertyDescriptor