-
Notifications
You must be signed in to change notification settings - Fork 31
Add TypeScript types to element-hiding feature #2016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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.
✅ Deploy Preview for content-scope-scripts ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
[Beta] Generated file diffTime updated: Mon, 27 Oct 2025 08:38:12 GMT AndroidFile has changed AppleFile has changed Chrome-mv3File has changed FirefoxFile has changed IntegrationFile has changed WindowsFile has changed |
Temporary Branch UpdateThe temporary branch has been updated with the latest changes. Below are the details:
Please use the above install command to update to the latest version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive TypeScript type definitions to the element-hiding feature through JSDoc annotations, improving type safety and preventing runtime errors. The changes introduce a structured type system for element hiding rules and configurations, along with runtime guards to handle optional properties safely.
Key changes:
- Introduces JSDoc typedefs for element hiding rules, values, domains, and configuration
- Adds runtime type guards to prevent accessing properties on rules without selectors
- Provides explicit type casts and fallback defaults for configuration settings
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
laghee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok -- made a few comments, but I don't see anything genuinely risky.
- 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
Bug: Null Checks Mask Configuration ErrorsThe added null checks for |
- 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
…rors - 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Asana Task/Github Issue: https://app.asana.com/1/137249556945/project/72649045549333/task/1211479926220519?focus=true
Description
This integrates the refactored schema types from privacy-configuration into the content-scope-scripts element-hiding feature for better type safety and maintainability.
Testing Steps
Checklist
Please tick all that apply:
Note
Add JSDoc typings across element-hiding and make feature settings access type-safe with sensible defaults, updating rule handling and selector usage accordingly.
ElementHidingValue,ElementHidingRuleHide,ElementHidingRuleModify,ElementHidingRuleWithoutSelector,ElementHidingRule,ElementHidingDomain,StyleTagException,ElementHidingConfiguration.ElementHidingRule/ElementHidingValue; add targeted casts ininjectStyleTagandhideAdNodes.getFeatureSettingresults with defaults foradLabelStrings,useStrictHideStyleTag,hideTimeouts,unhideTimeouts, andmediaAndFormSelectors(explicit fallback string when falsy).styleTagExceptions.extractTimeoutRules,injectStyleTag,applyRules) operate on typedElementHidingRule[].Written by Cursor Bugbot for commit 294e01b. This will update automatically on new commits. Configure here.