The props of a Vue component are destructured in setup, so the variables stop following the props
What it finds
props in setup is reactive: reading props.title always gives the current value. Destructuring copies the values once, so the variables keep the first values when the parent passes new ones. toRefs(props) destructures and keeps them reactive.
Reported are setup functions whose first parameter is an object pattern, and declarations that destructure the first parameter of setup directly in its body.
From the rule's source, props_destructured_in_setup.rs.
import { defineComponent } from "vue";export default defineComponent({ props: { title: String }, setup(props) { const { title } = props;tx0 reports: destructuring props here loses their reactivity return { title }; },}); Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:props-destructured-in-setup" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:props-destructured-in-setup] reason="..."tx0 explain tx0/ts:props-destructured-in-setup shows the same in the terminal. Found a false positive? Report it.