testComputedKeysNameValues
A computed key names a value, inside a type too: readonly [evaluate]: … uses the unique symbol evaluate, not
the type of that name beside it (Effect's evaluate, TypeId).
import { analyzeProject } from "#codebase/tcmts/core/analyze"; import { dir } from "#codebase/tcmts/core/test/hash"; import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; export const testComputedKeysNameValues = () => { const sub = fs.mkdtempSync(path.join(dir, "keys-")); const file = path.join(sub, "keys.ts"); fs.writeFileSync( file, `export const evaluate: unique symbol = Symbol.for("evaluate"); export type evaluate = typeof evaluate; export interface Primitive { readonly [evaluate]: () => number; } `, ); const a = analyzeProject([file], { cacheDir: path.join(sub, ".tcm", "cache"), resolveName: () => "", }); assert.deepEqual([...a.diagnostics.map((d) => d.message), ...a.errors], []); const value = a.defs.find((d) => d.nameHint === "evaluate" && d.kind !== "type")!; const deps = a.defs.find((d) => d.nameHint === "Primitive")!.deps.map((d) => d.ref); assert.ok(deps.includes(`#${value.hash}`), `the key is the constant: ${deps.join(", ")}`); }