jeudi 2 avril 2020

How to assign type to string input as object output

I have a forEach that takes in a string and outputs an object. How would I type this appropriately?

descriptionParts.forEach((text: string) => {
    let parts = {
       text,
       isLink: false
    }
    if (text.match('^#') || text.match('^@')) {
       parts = {
          text: `<span class=${this.boldClass}>${text}</span>`,
          isLink: true
       };
    }
    parsedDescriptionParts.pushObject(parts);
});



Aucun commentaire:

Enregistrer un commentaire