Issue
I am using vuejs.
this.$slots.eventsContent?.[0]?.data = {};
I got error from IDE.
TS2779: The left-hand side of an assignment expression may not be an optional property access.
Do you know how to get rid of error?
Solution
Do not use optional property.
this.$slots.eventsContent[0].data = {};
If you get "property maybe undefined error" you can do like this:
if (this.$slots.eventsContent && $slots.eventsContent.length > 0) {
this.$slots.eventsContent[0].data = {};
}
Just check if the property is not undefined before doing anything. This way typescript will be sure that your variable is defined.
Answered By - Bruno Polo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.