TypeScript
Use: TypeScript impl tasks. Load with hyperwork-tdd skill: skills: [hyperwork-tdd, hyperwork-typescript].
Toolchain
- Test runner:
vitestpreferred;ts-jestif repo uses Jest. Checkpackage.jsonscripts first. - Type check:
tsc --noEmit(never skip — catches type errors tests miss). - Lint:
eslint+prettierper repo config. Run before commit. tsconfig.json: read it. Matchtarget,moduleResolution,strictin new code.
Patterns
- Test file name:
<what>.<condition>.test.tsor<what>.spec.ts. describe/itblocks. Name behaviour:it('returns null when input is empty').- Typed mocks:
vi.fn<Args, Return>()(vitest) orjest.fn()typed via generics. expect.assertions(N)in async tests — prevents silent pass on missed await.- Fixtures: typed constants in
__fixtures__/or co-located*.fixtures.ts.
Do / Don't
- DO: run
tsc --noEmitbefore declaring green — type errors are bugs. - DO: check
tsconfig.jsonpaths/aliases before adding imports — broken at emit. - DON'T: use
anyto silence type errors — fix the type. - DON'T: commit with
@ts-ignorewithout explaining why. - DON'T: mock modules not at system boundary.