Snippet · Writing & changing code
Add types to untyped code
Incrementally, without a wall of errors.
This code has no types: <paste> Add them incrementally: - Start with the boundaries — function inputs and outputs, and the shape of anything coming from an API or a database. - Types that describe reality, including nullable fields and the shape of an error response. Don't pretend everything is always present. - Where the real type is genuinely dynamic, say so explicitly rather than using a permissive escape hatch quietly. List every place you had to widen a type or use an escape hatch, and why. Those are the places my code is doing something I should look at.
The escape-hatch list is the valuable output. Each one is either a genuine dynamic case or a piece of code whose behaviour you can't actually describe.