Skip to content

Commit

Permalink
remove void from resolved and unresolved
Browse files Browse the repository at this point in the history
  • Loading branch information
nitsky committed Nov 25, 2024
1 parent 7866e59 commit 1d5c45a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
8 changes: 3 additions & 5 deletions packages/runtime/src/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as im from "immutable";
import im from "immutable";
import * as tg from "./index.ts";
import type { MaybePromise } from "./util.ts";

export type Unresolved<T extends void | tg.Value> = MaybePromise<
export type Unresolved<T extends tg.Value> = MaybePromise<
T extends
| void
| undefined
| boolean
| number
Expand All @@ -21,8 +20,7 @@ export type Unresolved<T extends void | tg.Value> = MaybePromise<
: never
>;

export type Resolved<T extends Unresolved<void | tg.Value>> = T extends
| void
export type Resolved<T extends Unresolved<tg.Value>> = T extends
| undefined
| boolean
| number
Expand Down
6 changes: 5 additions & 1 deletion packages/runtime/src/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ type FunctionArg<
A extends Array<tg.Value> = Array<tg.Value>,
R extends void | tg.Value = void | tg.Value,
> = {
function: (...args: A) => tg.Unresolved<R>;
function: (
...args: A
) => R extends void
? MaybePromise<void>
: tg.Unresolved<Extract<R, tg.Value>>;
module: tg.Module;
name: string;
};
Expand Down
14 changes: 9 additions & 5 deletions packages/runtime/tangram.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,13 @@ declare namespace tg {
export function target<
A extends Array<tg.Value> = Array<tg.Value>,
R extends void | tg.Value = void | tg.Value,
>(function_: (...args: A) => tg.Unresolved<R>): tg.Target<A, R>;
>(
function_: (
...args: A
) => R extends void
? MaybePromise<void>
: tg.Unresolved<Extract<R, tg.Value>>,
): tg.Target<A, R>;
export function target<
A extends Array<tg.Value> = Array<tg.Value>,
R extends void | tg.Value = void | tg.Value,
Expand Down Expand Up @@ -932,9 +938,8 @@ declare namespace tg {
* Unresolved<Array<{ key: string }>> = MaybePromise<Array<MaybePromise<{ key: MaybePromise<string> }>>>
* ```
*/
export type Unresolved<T extends void | tg.Value> = tg.MaybePromise<
export type Unresolved<T extends tg.Value> = tg.MaybePromise<
T extends
| void
| undefined
| boolean
| number
Expand Down Expand Up @@ -963,8 +968,7 @@ declare namespace tg {
* Resolved<Promise<Array<Promise<string>>>> = Array<string>
* ```
*/
export type Resolved<T extends tg.Unresolved<void | tg.Value>> = T extends
| void
export type Resolved<T extends tg.Unresolved<tg.Value>> = T extends
| undefined
| boolean
| number
Expand Down

0 comments on commit 1d5c45a

Please sign in to comment.