LWCIntermediateapiproperties
Use @api getter setter for validated public properties
Real World Scenario
Parent passes invalid status value breaking child LWC internal state.
Expected Answer
• Validate in setter throwing or defaulting invalid values
• Document allowed enum values in JSDoc
• Emit event when parent corrects invalid input
• Avoid @api side effects causing render loops
• Test setter validation in Jest
• Coordinate with Flow input validation
Follow-Up Questions & Answers
Click to expand — each follow-up includes a direct, interview-ready answer
Direct answer: Validate in setter throwing or defaulting invalid values Also consider: Document allowed enum values in JSDoc In practice: Emit event when parent corrects invalid input Balance speed of delivery with maintainability.
Architect Perspective
Treat @api like public API—validate at boundary.