I'm using Angular 2 in SharePoint
I'm building a service that needs to call Sharepoint via csom and rest and I have run into trouble with the typing for Sharepoint 2013
I have run npm install @types/sharepoint --save-dev and am now trying to reference the sharepoint types in my TypeScript code
when I import import * as sharepoint from 'sharepoint'; I get the error @types/sharepoint/index.d.ts' is not a module
I don't know how to fix this.
On a side note, doing the exact same thing with the D3 library throws no error i.e.
npm install @types/d3 --save-dev
import * as d3 from 'd3';
works just fine
EDIT - 11 May 2018
At the top of your file add these to access any ambient variables
declare var SP: any
declare var _spPageContextInfo: any
You do not import typings.
If you can import from 'd3' without any compilation errors then your library folder must have a reference to 'd3' notably ./node_modules/d3.
Some Info on typings is that it guides the compiler as it generates JavaScript files. Additionally, it gives you type checking at design which is a huge benefit to javascript.
you can check if there are modules for sharepoint Here is what i found : https://www.npmjs.com/browse/keyword/sharepoint
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With