docs: drop a redundant eslint directive and note a Bun test quirk
no-explicit-any is off repo-wide in eslint.config.js, so the disable comment the plan mandated is itself an unused-directive warning. The test's schema binding also needs the _ prefix the lint config requires for a value read only via typeof. Separately: bun test strips type-only imports before resolution, so the red-first step does not reproduce for type-only tests. Recorded so later implementers do not chase it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
- Only procedures explicitly marked `.idempotent()` may be retried.
|
||||
- Errors crossing an app boundary are opaque by default: code and message only, no stack, no internal detail.
|
||||
- Test files live in `packages/<pkg>/test/*.test.ts` and use `import { describe, expect, test } from "bun:test"`.
|
||||
- `bun test` strips type-only imports before resolution, so a "verify it fails" step does NOT reproduce for a test whose only import from the new module is `import type`. Expect it to pass; that is a Bun behaviour, not a missing failure.
|
||||
- Test fixtures must NOT be scaffolded under `os.tmpdir()`. A scaffolded file importing `@wrnexus/*` by bare specifier cannot resolve outside the repo tree. Use a repo-local `.tmp-*` directory (`**/test/.tmp-*/` is gitignored).
|
||||
- Do NOT use `git stash`. This repo has `core.autocrlf=true`; a stash round-trip rewrites files to CRLF and fails `format:check`.
|
||||
- Write control-character checks as codepoint loops, never regex literals — escapes get mangled on the round-trip through tooling in this repo.
|
||||
@@ -83,9 +84,11 @@ import type { InferInput, ProcedureDef, ServiceContract } from "../src/types.ts"
|
||||
|
||||
describe("rpc types", () => {
|
||||
test("InferInput extracts the validated shape from a schema", () => {
|
||||
const schema = v.object({ userId: v.string(), amountCents: v.number() });
|
||||
// Prefixed with _ : used only via `typeof`, and the lint config requires
|
||||
// that prefix for a binding that is never read at runtime.
|
||||
const _schema = v.object({ userId: v.string(), amountCents: v.number() });
|
||||
// Compile-time assertion: assigning a correctly-shaped value must typecheck.
|
||||
const value: InferInput<typeof schema> = { userId: "u1", amountCents: 10 };
|
||||
const value: InferInput<typeof _schema> = { userId: "u1", amountCents: 10 };
|
||||
expect(value.userId).toBe("u1");
|
||||
});
|
||||
|
||||
@@ -178,8 +181,9 @@ export interface ProcedureDef<Input = unknown, Output = unknown> {
|
||||
* A procedure map with its element types erased. The `any` is deliberate and
|
||||
* confined to this alias: the phantom `__input`/`__output` markers make
|
||||
* ProcedureDef invariant, so no narrower erasure accepts a real contract.
|
||||
* (No eslint-disable needed — `no-explicit-any` is off repo-wide, and a
|
||||
* redundant directive is itself a lint warning.)
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type AnyProcedures = Record<string, ProcedureDef<any, any>>;
|
||||
|
||||
export interface ServiceContract<Procedures extends AnyProcedures = AnyProcedures> {
|
||||
|
||||
Reference in New Issue
Block a user