2

I am trying to build a SharePoint Add-In and I am struggling because all documentation seems to be in TypeScript. I am sure TS is great but I don't have time to learn it right now. Does MSFT not have docs in javascript?

https://pnp.github.io/pnpjs/sp/docs/items/

2

All of the PnP JavaScript libraries are written in TypeScript. As such, there are no exemplar JavaScript files.

All of the tooling to implement customizations in SharePoint has changed. e.g.: SP Designer —> Gulp, Yeoman, Node, etc. This is a major hurdle that I and other DevOps have had to overcome (in my case, I still am).

  • I looked into Yeoman and there is no choice for Add-In's and I need to make an Add-In. What am I supposed to use to generate the project files? There is no documentation on how I should use Node and Gulp for a SharePoint Add-In. – tnk479 Jan 22 at 21:55
  • Also, I have never used SP Designer. I am accustomed to using Visual Studio 2017 as an IDE. – tnk479 Jan 22 at 21:58
0

You will be surprised, but below is a valid javascript:

// get all the items from a list
sp.web.lists.getByTitle("My List").items.get().then(items => {
    console.log(items);
});

It works in all modern browsers. You see, it doesn't differ significantly from the samples for PnPjs. In most cases, it requires an additional tool, which transforms this code into a module (tools like Babel or Typescript compiler). Today you simply can't create a big scalable solution in Javascript without modularity.
I recommend you to spend some time and dig into modern JavaScript (or Typescript it even better)

  • What is the shortest route to getting a dev environment for a SharePoint Add-In that allows me to leverage this new PnP JS set of libraries. – tnk479 Jan 22 at 21:57
  • You can create a project using Visual Studio (SharePoint Add-in template), add pnpjs library file using the same approach as App.js inside generated project and basically you're good to go. – Sergei Sergeev Jan 23 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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