/** * Type-level tests for factory input acceptance. * * If any type assertion is wrong, this file fails to compile. */ import { describe, it } from "@std/testing/bdd"; import { expect } from "@std/expect"; import type { FactoryInput, HandlerFactory, PatternFactory, StripCell, } from "../src/builder/types.ts"; import type { Default, Writable } from "@commonfabric/api"; type MustBeTrue = T; type AssertAssignable = [T] extends [U] ? true : never; type AssertNotAssignable = [T] extends [U] ? never : true; interface Ship { name: string; } interface PlayerData { name: string; ships: Ship[]; } type PlayerCell = Writable>; type ReactivePlayerData = { name: FactoryInput; ships: Array>; }; interface HandlerState { name: string; player1: PlayerCell; } interface RoomInput { player1: PlayerCell; } type HandlerBinding = { name: FactoryInput; player1: Writable; }; type RoomBinding = { player1: Writable; }; type WrongRoomBinding = { player1: Writable< { name: FactoryInput; ships: Array>; } | null >; }; const _handlerBinding: MustBeTrue< AssertAssignable>> > = true; const _roomBinding: MustBeTrue< AssertAssignable>> > = true; const _handlerFactory: MustBeTrue< AssertAssignable< HandlerFactory, (inputs: HandlerBinding) => unknown > > = true; const _patternFactory: MustBeTrue< AssertAssignable< PatternFactory, unknown>, (inputs: RoomBinding) => unknown > > = true; const _wrongRoomBinding: MustBeTrue< AssertNotAssignable>> > = true; describe("factory input types", () => { it("accepts reactive cell handles without casts", () => { expect(true).toBe(true); }); });