SharePoint/PnP-JS-Core

return type for getAll

Closed this issue · 2 comments

Thank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your needs please complete the below template to ensure we have the details to help. Thanks!

Please check out the Developer Guide to see if your question is already addressed there. This will help us ensure our documentation covers the most frequent questions.

Category

[x ] Enhancement

[ ] Bug

[ ] Question

Version

Hi, I am using this code to return an array of typed objects
public getRoleToTransaction(role: string): Promise {
return sp.web.lists.getByTitle(this.properties.roleToTransactionListName)
.items.filter(Composite_x0020_role eq '${role}').get();
}

I returned results list may be huge in some rare cases so I want to use GetAll():
public getRoleToTransaction(role: string): Promise {
return sp.web.lists.getByTitle(this.properties.roleToTransactionListName)
.items.filter(Composite_x0020_role eq '${role}').getAll();
}

But getAll doesn't take a type parameter.

Can we make getAll take a type parameter?

You can type the return to anything you like. It is any so something like:

const h = <something>sp...getAll();

// or

const y: something = sp...getAll();

Not sure what advantage adding a type parameter would have here?

Thank you for your interest in the sp-pnp-js library. We wanted to mention that this library is being deprecated in July, 2018 in favor of the new scoped pnpjs libraries. You should begin transitioning your existing projects when possible, or start new projects with the new libraries. Please see the transition guide for more details on migrating and be sure to let us know if you have any questions. Thanks!

Thanks Patrick! I did not know that.