Stencil @Prop() read-only input enforcement
0 reputation · 03 Sept 2022, 14:53 UTC
Stencil @Prop() read-only input enforcement
Stencil documents @Prop() as a read-only input supplied by the parent component. Internal mutable values belong in @State(), and reactions to prop changes belong in @Watch(). Direct assignment to a @Prop() inside the component class falls outside the documented update path, but the compiler does not appear to hard-fail on it in every release.
The goal is to confirm whether the pinned Stencil compiler treats internal prop assignment as silent, a warning, or an error. Diagnostic behavior may vary across major versions, so the enforcement level must be checked against the exact toolchain before teams standardize on a guardrail.
- Does the current Stencil compiler emit a diagnostic for
this.prop = valueinside a component? - What value persists after an internal prop assignment followed by a parent re-render?
- Should the read-only boundary be enforced through ESLint rather than compiler diagnostics?