Es6 object assignment error

const reserved = item => {
      let res = { label: item.action_name, value: item.action_id, checked: false };
      if (item.son && item.son.length > 0) {
        res.son = item.son.map(s => reserved(s));
      }
      return res;
    };

    const result = this.moduleData.showModule.reduce((res, item) => {
      res.push(reserved(item));
      return res;
    }, []);

clipboard.png

what should I do

Es6
Dec.20,2021

this tells you how to change it. This is a type detection error belonging to typescript.
Type supplement
adding a type any to each value is the most rude way
here you need Interfaces object type interface to define the search keyword


ts syntax does not allow you to add new attributes to the object casually, you need to define it in interface.

Menu