A customer brought up an issue with a public property that never rehydrates.
Issue: ability to decorate a special 'key' property with @api.
playground link: https://playground.lwcjs.org/projects/mY3ddUxFH/4/edit
ex:
// parent.html
<c-child key={childKey}></c-child>
// parent.js
export default class Child extends LightningElement {
get childKey() {
return 'key value from parent';
}
}
// child.js
export default class Child extends LightningElement {
@api key = 'my key';
}
// child.html
<template>
<h2>key value from parent: {key}</h2>
</template>
This should be a compilation error for now. Can we add this to patch?
@pmdartus and I had few discussions on how to go about this work item since this is a breaking change. I would like to discuss the approach here so we can all agree on the path forward. Here are some options:
I personally prefer staring with a warning to minimize number of complaints. However, i can also see the benefit of not waiting until more customers make this mistake and just make a breaking change with a two week notice/announcement.
@Gr8Gatsby @caridy @diervo @ekashida what are your thoughts?
What do you mean that this is a breaking change? do you mean that if you have @api key it works? It doesn't work today, it doesn't throw either, but the code is faulty from day 0. Did we investigate if anyone is using @api key or @api get key` in core? I think this is sufficiently constrained that we can probably pull the trigger if we don't find any decorated field or accessor called key in 218.
@caridy that is correct, you can have @api key; property in your class without an error ( see playground link in the description ). I have not ran transmogrify against core, but off core teams can be using this syntax as well, which will be a breaking change.
The main issue here is not Core components but database components. If a customer was able to save a component in the DB we should be able to recompile it, otherwise, their application will be broken until the code saved in the DB is fixed.
Most helpful comment
The main issue here is not Core components but database components. If a customer was able to save a component in the DB we should be able to recompile it, otherwise, their application will be broken until the code saved in the DB is fixed.