Skip to content

Commit

Permalink
Merge pull request #1653 from o1-labs/fix/method-returns-type
Browse files Browse the repository at this point in the history
Fix method.returns() inference
  • Loading branch information
Trivo25 committed May 15, 2024
2 parents 76db7d1 + 32955a8 commit 3b1b225
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions src/lib/mina/zkapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import {
cloneCircuitValue,
FlexibleProvablePure,
InferProvable,
} from '../provable/types/struct.js';
import {
Provable,
Expand Down Expand Up @@ -170,12 +171,14 @@ function method<K extends string, T extends SmartContract>(
* }
* ```
*/
method.returns = function <K extends string, T extends SmartContract, R>(
returnType: Provable<R>
) {
method.returns = function <
K extends string,
T extends SmartContract,
R extends Provable<any>
>(returnType: R) {
return function decorateMethod(
target: T & {
[k in K]: (...args: any) => Promise<R>;
[k in K]: (...args: any) => Promise<InferProvable<R>>;
},
methodName: K & string & keyof T,
descriptor: PropertyDescriptor
Expand Down

0 comments on commit 3b1b225

Please sign in to comment.