/// /** * Regression test for array.length access inside computed(). * * This mimics the pattern from default-app.tsx where: * - allCharms comes from wish<{ allCharms: MentionableCharm[] }> * - computed(() => allCharms.length) accesses .length on an OpaqueRef * * The fix ensures the schema is { type: "array", items: { not: true, asOpaque: true } } * rather than { type: "object", properties: { length: { type: "number" } } } */ import { computed, NAME, pattern, UI, wish } from "commontools"; interface Charm { id: string; name: string; } export default pattern(() => { const { allCharms } = wish<{ allCharms: Charm[] }>("/"); return { [NAME]: computed(() => `Charms (${allCharms.length})`), [UI]: (
Count: {computed(() => allCharms.length)}
    {allCharms.map((charm) => (
  • {charm.name}
  • ))}
), }; });