Repository navigation
Commit 2bbb4db
committed
ref(runtime): let CaptureAssessment carry the guarantee it already checks
`assessCaptureRule` confirms `candidate.id` is a string before returning
`ok: true`, but the return type said `CaptureRule`, whose `id` is optional —
so the caller had to cast it back with `as string`.
The point of one shared assessor is that its guarantee can be trusted by
both callers. A guarantee the type throws away is one the next reader has to
re-derive, and a cast is what they reach for. `CaptureRule & { id: string }`
states it instead, so reordering the checks such that `id` is no longer
validated becomes a compile error rather than an `undefined` id at runtime.
Found by the review on #216.1 parent 3198d52 commit 2bbb4db
1 file changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| |||
0 commit comments