Forum Discussion
Samaresh Das
Mar 29, 2017Copper Contributor
sharepoint type script in SPFX
Hi All, I am working in SPFX with angular 2. I wanted to use sharepoint type script in my project. I have installed the sharepoint type script with npm command "typings install dt~sharepoint --glob...
Luis Mañez
Mar 29, 2017MVP
Sorry, I was wrong about using _spPageContextInfo. it's possible to use it on spfx (I think the issue I remember is when using the Local workbench)
This sample
https://github.com/SharePoint/sp-dev-fx-webparts/blob/98138de57fd8ba3eb19afa69caf032ab785f0b0e/samples/react-search/src/webparts/searchSpfx/flux/helpers/SearchTokenHelper.ts
is using that variable, but I don't see the sharepoint typings. Instead, it's creating a custom interface with all _spPageContextInfo properties, and declaring the variable as:
declare const _spPageContextInfo: IPageContext;
Where IPageContext is a custom interface defined here:
https://github.com/SharePoint/sp-dev-fx-webparts/blob/98138de57fd8ba3eb19afa69caf032ab785f0b0e/samples/react-search/src/webparts/searchSpfx/utils/IPageContext.ts
This sample
https://github.com/SharePoint/sp-dev-fx-webparts/blob/98138de57fd8ba3eb19afa69caf032ab785f0b0e/samples/react-search/src/webparts/searchSpfx/flux/helpers/SearchTokenHelper.ts
is using that variable, but I don't see the sharepoint typings. Instead, it's creating a custom interface with all _spPageContextInfo properties, and declaring the variable as:
declare const _spPageContextInfo: IPageContext;
Where IPageContext is a custom interface defined here:
https://github.com/SharePoint/sp-dev-fx-webparts/blob/98138de57fd8ba3eb19afa69caf032ab785f0b0e/samples/react-search/src/webparts/searchSpfx/utils/IPageContext.ts