I want to get a sharepoint list and assign it to my list 'items' which of type is IExampleItem, but I don't really know how to do it; I tried the following code but it gives me an error, my list 'items' is not compatible with what my


_getFacItems return Promise《T》 so it not same as IExampleItem[].

I did sample test demo in my github project below, I bind data in component not in webpart directly, while it might be helpful for you.



Check the type of 'items' in the FAQ component.

It must match with the return type of _getFacItems().

  • the problem i don't know which type return sp.web.lists.getByTitle("FAQ_List").items .select("Question", "Reponse","Categorie", "Langue") .orderBy("Created", true) .get() – khadi Aug 20 '19 at 7:44
  • i change my code for this, but it doesn't work public _getFacItems() : IExampleItem[] { var ListFaq : IExampleItem[] ; debugger; sp.web.lists.getByTitle("FAQ_List").items .select("Question", "Reponse","Categorie/Title", "Langue") .expand("Categorie") .get() .then( response => { response.forEach( item => { ListFaq.push(item) }) }); ListFaq.forEach(item => { alert("khkjhkjhkhkhkjhkhj"+item.Question) }) debugger; return ListFaq; } – khadi Aug 20 '19 at 9:25


While there is nothing technically wrong with loading the items in the FaqWebPart, I prefer to load it in the component for performance reasons. That way, it appears that the web part is faster (even if it isn't, really) by first rendering an empty list, and rendering a filled list once the items are loaded. You can even be fancy and add a 'loading' message, a spinner, or a shimmer to your list.

The trick to solve the error you get is to map the returned list items (which are of type any when they get returned) to a IFAQItem (or IExampleItem in your original code). In this example, assigned the returned items to a const variable to make it easier to read the code.

Here is how I would change the code to do this:

Full disclaimer: I did not build or run this code. There may be errors, but I should demonstrate the concept.

I hope this helps?

Not the answer you're looking for? Browse other questions tagged or ask your own question.