Status: done (2026-11-15)
Priority: 3
Size: S
Arch: yardstick
Phase: implement
Design ref: none (code structure). docs/typescript-plan.md (P1); the survey in backlog/VB-055.md.
Goal: Eight tools and tests parse or scan the source of src/ as JavaScript text: tools/writes.js (acorn; also used by tests/dependencies.js, tools/stocks.js, tools/write-scopes.js), tests/lint.js and tests/lintrules.js (by line), tests/ownershiprules.js, tests/record.js, tests/commands.js, tests/registry.js and tools/wrap.js. After the move to .ts they would meet type annotations, which acorn rejects. Give them one function, readSource(file) in tools/lib/source.js, that returns the text as JavaScript: the file as it is for .js, and for .ts the text with its types blanked by node:module’s stripTypeScriptTypes (experimental in Node 22.23; it keeps every line and column, which was checked in a scratch directory on 12 November). No behaviour change today, since no file is .ts yet.
Acceptance criteria:
tools/lib/source.js exports readSource(file); a test (tests/source.js, in npm test) feeds it a .ts text with annotations, generics, type imports and an as cast, parses the result with acorn, and checks that the positions of the tokens are those of the original.src/ only through it (a grep in the test fails for a direct readFileSync of a src/ file in them).stripTypeScriptTypes is gone or warns on the Node of the Checks workflow, the task says so and uses typescript’s transpileModule (dev dependency, pinned) behind the same function; the choice and the Node versions tried are in the task file.AGENTS.md, “Finding things”: one line saying source is read through readSource.docs/typescript-plan.md, where this task is P1): waits for Kim’s answers to QUESTIONS.md, “VB-055: the move to TypeScript” (the formatter, the bundler, the hook, the width measures, when, the page and the tests, strict), which may change its criteria; the three rules common to these tasks are at the top of the plan.tools/, tests/ and AGENTS.md only.
Notes:QUESTION_ARCHIVE.md, VB-055, 15 Nov). This task runs beside other work; the tooling choices are as proposed there (Deciding without Kim, 12).tools/lib/source.js exports readSource(file) (absolute or root-relative) and stripTypes(text); .ts goes through stripTypeScriptTypes, .js as read. tests/source.js (in npm test) checks length, lines, columns and token positions on annotations, generics, type imports and as, and greps the files for direct source reads.stripTypeScriptTypes exists and prints one ExperimentalWarning. Decision: the warning is filtered inside stripTypes rather than adding typescript; if a later Node drops the function, put transpileModule in its body.