Stencil won't compile my components since the latest updates. The problem is the following:
@Element() el: HTMLSpxEditElement
@Listen('keydown', { target: this.el })
onClickEnter (evt) {
if (evt.keyCode === 13) {
evt.preventDefault()
}
}
Getting this error:
Object is possibly 'undefined'.
L49: @Listen('keydown', { target: this.el })
L50: onClickEnter (evt) {
I read through this thread here: How to suppress "error TS2533: Object is possibly 'null' or 'undefined'"? but changing "this.el" to "this!.el" is not helping either.
I don't want to change settings of the compiler.
I realised that the event listener didn't need to be specified, as it already applied to the host element.
This fixed my issue.