I would like to use JSOM for things like creating Caml queries as I have to migrate AngularJS to Angular 4. The app is running in a WebPart.

Unfortunately there is no npm package for this. How can I use JSOM from my typescript? How do I write the import?

Always get the message:

Cannot find name 'SP'


After some more research, I found out, that it is possible to add external JS libraries to my Angular 4 App via the WebPack externals.

How can I import those files as external libraries to my app and which files do I need to get a working JSOM?

  • Here are the typings: npmjs.com/package/@types/sharepoint The physical JS-files you will need to reference yourself from SharePoint Commented Jul 26, 2017 at 10:18
  • I am still getting the same error after installing that package and how do I reference the physical files? And which files do I actually need? Could you please formulate an answer, because that comment doenst help that much. Commented Jul 26, 2017 at 10:23
  • If the comment does not help, then you seem to not be fluent in neither ng4 or SharePoint? Or your question is not very well formed. Where will your ng4 code run? On a SharePoint page or externally? How is the current ng-code looking? Commented Jul 26, 2017 at 10:36
  • If I would know all those things, I wouldnt ask... What do you mean with "How is the current ng-code looking?" Commented Jul 26, 2017 at 10:42
  • Did you get the solution? I am also struggling with the same issue. Commented Nov 12, 2017 at 19:06

2 Answers 2


I know it is an old post. But I was using the JSOM in Angular4 here is the way to add @types/SharePoint

  1. npm install --save @types/sharepoint
  2. In the Typings.d.ts file (this file is placed in the src folder) add the line given below " /// "

TypeScript Templates is a set of Client-Side Rendering (CSR) templates and helper functions to change behaviour of standard forms. Install using NuGet

PM> Install-Package typescripttemplates

or using bower

bower install typescripttemplates --save

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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