Skip to content

Commit

Permalink
Correct return type on call_step()
Browse files Browse the repository at this point in the history
  • Loading branch information
aajanki committed Sep 25, 2024
1 parent 32ff312 commit 0ea06a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion language_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,10 @@ import {
### call_step()

```typescript
function call_step(func: Function, args: Record<string, unknown>): unknown
function call_step<T, A extends any[]>(
func: (...args: A) => T,
arguments: Record<string, unknown>,
): T
```

The `call_step` function outputs a [call step](https://cloud.google.com/workflows/docs/reference/syntax/calls).
Expand Down
6 changes: 4 additions & 2 deletions samples/sample2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Change the path to 'ts2workflows/types/workflowslib'
// in projects that use ts2workflows module as a dependency.
import { sys, time } from '../types/workflowslib'
import { call_step, sys, time } from '../types/workflowslib'
import { get_url } from './http_helpers'

function main() {
Expand All @@ -12,5 +12,7 @@ function main() {
// Calling a subworkflow defined in another source file
const response = get_url('https://visit.dreamland.test/')

sys.log(response.body as object)
// Invoking a function with a call step and named arguments
// instead of an ${} expression
call_step(sys.log, { severity: 'DEBUG', json: response.body })
}
6 changes: 3 additions & 3 deletions types/workflowslib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ export declare function retry_policy(
},
): void

export declare function call_step(
func: Function,
export declare function call_step<T, A extends any[]>(
func: (...args: A) => T,
arguments: Record<string, unknown>,
): unknown
): T

0 comments on commit 0ea06a1

Please sign in to comment.