Commit 679d686
authored
fix: TypeScript error when trying to access HTMLRules[key] (#1635)
The original code had a TypeScript error when trying to access HTMLRules[key] using dynamic key access:
)
Solution
I replaced the problematic code with a cleaner, more type-safe approach using Object.values():
)
Why this works better:
Type Safety: Object.values() properly preserves the type information, so TypeScript knows that each rule is of type Rule
Cleaner Code: No need for type assertions or @ts-expect-error comments
More Direct: We directly iterate over the rule objects instead of getting keys and then accessing values
ESLint Compliant: No linting errors about using any type
Verification:
✅ TypeScript compilation passes (npm run build succeeded)
✅ All tests pass (324 tests passed)
✅ Linting passes (no warnings or errors)
✅ Code formatting is correct
The issue has been completely resolved with a clean, type-safe solution that maintains all existing functionality while eliminating the TypeScript error.1 parent 0da2c23 commit 679d686
2 files changed
+5
-7
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 159 | + | |
| 160 | + | |
163 | 161 | | |
164 | 162 | | |
165 | 163 | | |
0 commit comments