Commit baf91ee
fix(core): replace unsound AggregateError cast with runtime narrowing in flatErrors
The previous cast to (RulesetValidationError | AggregateError)[] was
unsound — AggregateError.errors is untyped by spec and can hold arbitrary
values. Rewrite flatErrors to accept unknown, narrow with instanceof/
isAggregateError at runtime, and always return RulesetValidationError[].
This eliminates the cast, drops the Array.isArray branch in the caller,
and silently discards unexpected entries rather than propagating them
typed as RulesetValidationError.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent c90f1cb commit baf91ee
1 file changed
Lines changed: 8 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
99 | | - | |
| 97 | + | |
100 | 98 | | |
101 | 99 | | |
102 | 100 | | |
| |||
109 | 107 | | |
110 | 108 | | |
111 | 109 | | |
112 | | - | |
| 110 | + | |
113 | 111 | | |
114 | | - | |
| 112 | + | |
115 | 113 | | |
116 | 114 | | |
117 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
| |||
0 commit comments