Svelte uses syntax like export let propName to import a prop from a parent component. There was some discussion about changing this syntax to make it more clear about the direction of the data flow (https://github.com/sveltejs/svelte/issues/3454), but ultimately the core team decided to keep it because:
They require valid JS syntax for their parser
The export keyword means "exposing a contract to the outside world"
I'm curious if there is another approach that makes the direction of the prop being passed more clear, while not adding unnecessary boilerplate or introducing too much magic. Potentially could just use let propName without the export keyword and match the prop name being passed from the parent to the variable that's declared in the child component. The child component could override by just setting a value like let propName = "new value".
Svelte uses syntax like
export let propName
to import a prop from a parent component. There was some discussion about changing this syntax to make it more clear about the direction of the data flow (https://github.com/sveltejs/svelte/issues/3454), but ultimately the core team decided to keep it because:export
keyword means "exposing a contract to the outside world"I'm curious if there is another approach that makes the direction of the prop being passed more clear, while not adding unnecessary boilerplate or introducing too much magic. Potentially could just use
let propName
without theexport
keyword and match the prop name being passed from the parent to the variable that's declared in the child component. The child component could override by just setting a value likelet propName = "new value"
.