You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add TypeScript types to element-hiding feature (#2016)
* Add TypeScript types to element-hiding feature
- Add JSDoc type definitions matching element-hiding.ts schema
- Cast getFeatureSetting return values to proper types with fallbacks
- Update function parameter types to use new JSDoc types
- Add type guards for union types (ElementHidingRule)
- Preserve all original comments from codebase
- Fix TypeScript compilation errors with proper null checks
This integrates the refactored schema types from privacy-configuration
into the content-scope-scripts element-hiding feature for better
type safety and maintainability.
* Restore missing comment
* Update element-hiding types and remove unnecessary selector guards
- Update TypeScript definitions to match new privacy configuration schema
- Split ElementHidingRuleWithSelector into ElementHidingRuleHide and ElementHidingRuleModify
- Make values required for modify rules, remove from hide rules
- Remove unnecessary 'selector' in rule guards from injectStyleTag() and hideAdNodes()
- Add type assertions to clarify that these functions only receive rules with selectors
- Improve code consistency and efficiency
* resolve fallback inconsistency over typedef on line 367
* Clarify mediaAndFormSelectors fallback logic
- Replace confusing self-referential fallback with explicit conditional
- Add comment explaining fallback to default value when setting is missing
- Make intent clear: fallback to hardcoded default, not preserve existing value
- Addresses feedback about unclear fallback pattern
* Remove null checks for modify rule values to surface configuration errors
- Remove if (rule.values) checks from modify-attr and modify-style cases
- Values property is required according to ElementHidingRuleModify typedef
- Null checks were masking configuration errors by silently ignoring malformed rules
- Now fails fast when values is missing, helping developers catch config issues early
- Fixes JSDoc type mismatch between required values property and null checks
* Fix mediaAndFormSelectors fallback to handle all falsy values
---------
Co-authored-by: euw-arasolofotsara1 <arasolofotsara@duckduckgo.com>
0 commit comments