Agreed — index.ts here is a pure re-export barrel (export { parse } from "./parse.ts"; export type * from "./types.ts";), so these tests were stranded at the entrypoint. Moved them (real tests + roadmap todos) into a co-located parse_test.ts importing parse from ./parse.ts, and deleted index_test.ts — commit e32b71e. A broken re-export is still caught by typecheck and by the bin package importing parse through the public entrypoint in its E2E test. (Note the same doesn't apply to bin/index.ts, which is the actual CLI with logic, so its index_test.ts stays.)
Frontmatter is a mapping type (Record<string, unknown>), but YAML can also parse to a bare scalar (e.g. 42), a top-level sequence, or null/~. The three conditions narrow to exactly a plain mapping — both null and arrays report a typeof of object, which is why the explicit !== null and !Array.isArray are there. Everything else normalises to {}, matching the spec: empty when the block is present but invalid. If we later want 'present but not a mapping' to be visible rather than silently {}, that is a natural fit for an invalid-frontmatter-style diagnostic in task 0007.
It is the map-or-drop idiom: translateBlock returns [] to skip an unmodelled node or [block] to keep one, and flatMap flattens that in one step, with no nulls or holes. It also generalises unchanged to task 0004, where a single mdast node can translate to several core blocks (and containers recurse into their children). Not about empty files — an empty input is just tree.children === [], handled the same way regardless. translateInline uses it for the same reason. Happy to switch to an explicit push-loop if you find that reads clearer.
Correct — nothing constructs one yet; diagnostics is always [] in this slice. Trimmed in 8687b75: dropped Point, Position, and the source?/position? fields, leaving Diagnostic as { severity, code, message } — just the element type of the returned (empty) array. Task 0007 emits the first real invalid-frontmatter diagnostic and re-adds the locator fields additively, with its own tests.
Why use flatMap if the array returned is always of size 0 or 1?
Why are we being so restrictive with what types of yaml parsed?
Is this ever created anywhere? The only diagnostics I see is always an empty array.