testTableWithoutRowType

tcmts.cli.test.e2e.data.testTableWithoutRowType · #g524u3yy · term

a table without a row type explains how to declare one

import { okIn, tempDir } from "#codebase/tcmts/cli/test/e2e/harness";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";

export const testTableWithoutRowType = () => {
  const dir = tempDir("data");
  const tcm = (...args: string[]) => okIn(dir, ...args);
  tcm("init");
  tcm("lib", "add", "tcm", "server", "--at", "lib.server");
  fs.writeFileSync(
    path.join(dir, "scratch.ts"),
    `// tcm: namespace loose
import assert from "node:assert/strict";
import { table } from "#codebase/lib/server";
export const testUntyped = async () => {
  const t = table("anything");
  await assert.rejects(t.insert({}), /declare it at the top level with one, e\\.g\\. export const anything = table<Row>\\("anything"\\)/);
};
`,
  );
  tcm("add");
  assert.match(tcm("test", "loose"), /1 passed, 0 failed/);
}

uses