Before we begin
What Is the Human Responsible for After AI Writes the Code?
No red underline does not mean safe code. Learn a simple review order for real input and failures.
Why can a program crash when the editor shows no errors?
TypeScript checks information visible in source code. Network responses, environment variables, database rows, and AI output only arrive while the program runs. A type name cannot repair bad data.
as ReviewInput only asks the editor to trust you. If code is actually a number, the next line still crashes. Predict the failure, then validate the input in the Playground.
const payload = JSON.parse(body) as ReviewInput;
return payload.code.toUpperCase();Can a type assertion protect the runtime?
Run the failure, remove the unsafe assertion, and validate the JSON shape.
运行后显示诊断。
等待执行。
Need a hint?
Start JSON.parse output as unknown; check the object and its code field.
Code passes five gates before a user relies on it
The editor gives quick hints, tsc checks the project, a build tool produces JavaScript, the runtime handles real input, and tests try to break the behavior. Passing one gate does not replace the others.
- Editor: fast feedback, not the final judge
- Type checker: rules out some mistakes without running code
- Build: creates output and may not type-check
- Runtime: decides what really happens
- Tests and logs: provide evidence about behavior
Use five questions instead of “looks fine”
TRUST is a checklist: Are inputs and outputs clear? Is external data checked? What happens on failure? Could files or secrets be harmed? Would a test catch the bug?
- Types & contracts: can an invalid state still be created?
- Runtime boundaries: was external data actually parsed?
- Unhappy paths: what happens on timeout or cancellation?
- Side effects & security: are secrets and resources safe?
- Tests & telemetry: would the evidence fail when the code is broken?
Finish with evidence, not a feeling
After the Playground, run this check from the project root. It never contacts a model.
npm run verify:lesson -- M00