Typescript and SharePoint - Using the PnP Library

Interacting with SharePoint through custom JavaScript code can be simplified by using the PnP Core JavaScript library - this library wraps the asynchronous calls to SharePoint's REST API in a series of namespaces and functions, resulting in a clean object-style model. And Typescript is seen as a more efficient way to write JavaScript.

But bringing the two technologies together within Visual Studio Code can prove challenging. Unlike the ready-packaged world of creating solutions and projects within the Visual Studio IDE, VS Code offers masses of flexibility by prescribing very little. You can choose several ways of structuring the development workflow in VS Code, including use of Gulp, Grunt, Webpack or other build and task handlers.

Why bother with the upheaval? Because the SharePoint development model is changing rapidly. SharePoint framework will be bring these new concepts into the platform development lifecycle before long. And these approaches all have huge communities online that can help along the way.

I have just started experimenting with writing SharePoint customisations in Typescript in Visual Studio Code. Gulp handling the build and deployment tasks within my projects. I have also integrated the PnP Core library into this process, to check the benefits it brings. It has taken lots of work to get a very simple JavaScript call to bring back data from SharePoint using these techniques as they are all new to me. To record the challenges and my workarounds, I have been writing a few posts on my blog at https://sharethelearning.blogspot.co.nz/. Perhaps if you are contemplating these approaches, some of the tips in those posts might help. The techniques I have been adopting may not be the best, and there may well be many better ways of achieving the outcomes - the posts are more of a journal recording my steps and mis-steps along the way, and in no way purport to suggest the right way of doing things. All suggestions for how to improve things gratefully accepted!

Along the way, I have found that it is steep learning curve for a developer very familiar with the Microsoft-centric way of doing things. So many choices to make! In addition to the technologies discussed in the posts, I have also started adding React into the mix, so will write about that at some time, too.

If the combination of technologies seems of interest to anyone, I will see about publishing the source to GitHub. And if you are making these same steps, I wish you patience and a curious mind!

To view or add a comment, sign in

More articles by Gary Payne

Explore content categories