This commit is contained in:
2026-06-23 01:13:03 +02:00
parent a3c85a7983
commit 3dc22e3f62
13 changed files with 1210 additions and 10 deletions
+47
View File
@@ -0,0 +1,47 @@
import { makeFluent } from "../base";
import type { HKT } from "../base/hkt";
import {
Mixin,
type Input,
type Props,
type Return,
} from "../base/mixin";
import type { Empty } from "../internal";
import type { Methods } from "../registry";
import { Base } from "./base";
class Awaited<T extends Promise<unknown>> {
public value: T;
public constructor(value: T) {
this.value = value;
}
}
export interface AwaitedMixin extends Mixin.HKT {
new: (t: HKT.T<this>) => Input<typeof t> extends infer T
? T extends Promise<unknown>
? {
readonly awaited: Return<Awaited<T>, typeof t>;
}
: 0
: never;
}
export const AwaitedMixin = Mixin<AwaitedMixin>(
(value, $, fluent) => {},
);
if (import.meta.vitest) {
const { test, expect } = import.meta.vitest;
const registry = [Base, AwaitedMixin] as const;
const $ = makeFluent(registry);
test(".awaited", () => {
const promise = new Promise<number>((r) => {
r(10);
});
const m = $(promise).V;
});
}