Skip to content

Commit f315db0

Browse files
timphandevclaude
andcommitted
docs: test types as users use them, and fix a bug everywhere it lives
Bugs that reached users or outside reviewers came from types used in ways the tests did not try, such as a generic function of the user's or a recipe exported from another module, and from fixes that left the same pattern in another package or in the docs. AGENTS.md now lists the ways each public type is checked, and asks a fix to search every package and the docs for the pattern it fixes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 4738169 commit f315db0

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎AGENTS.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,31 @@ public type has a type test (`expectTypeOf`, or `@ts-expect-error` for
229229
input that must be rejected). A test that only exercises the types still
230230
asserts the runtime outcome.
231231

232+
**Test types the way users use them.** A type that works on one inline
233+
call can still fail in a user's project. Check each public type, in a
234+
test or in an app of `consumers`, in each way users reach it:
235+
236+
- inferred from an inline argument, and from a value declared before the
237+
call;
238+
- passed through a function of the user's that is generic over it, and
239+
returned from that function;
240+
- exported from one module and used in another, with declarations
241+
emitted, as an app that installs the packed package compiles it;
242+
- with `isolatedDeclarations`;
243+
- nested or composed several levels deep, where its declarations must
244+
grow linearly;
245+
- with the oldest and the newest TypeScript that the packages support.
246+
247+
When a feature adds a way to use a type, add that way to every type it
248+
applies to, and to this list.
249+
250+
**Fix a bug everywhere it lives.** The packages and the docs share
251+
patterns: the same type helper, the same check, the same example. When
252+
you fix a bug, find the pattern that caused it, then search every
253+
package, the docs, the skills, and the READMEs for that pattern. Fix
254+
each place in the same change, with a test for each, or say why a place
255+
is not affected. List in the commit body where you looked.
256+
232257
**Performance comes first.** A recipe and a slot recipe of any kind, a
233258
class name recipe and slot recipe, and a style recipe and slot style
234259
recipe must be faster with the cache than without it. The benchmarks

0 commit comments

Comments
 (0)