Seeking to retrieve the current user within a Sharepoint App on Sharepoint server. This functionality functioned successfully in a previous app developed using AngularJS.
The AngularJS code which achieved this was structured as shown below
var thisUser = $().SPServices.SPGetCurrentUser({
fieldName: "Title",
debug: false
});
Now attempting to implement the same code in Angular version 6, however upon building the project, an error is encountered:
ERROR in src/app/pedido/pedido.component.ts(68,43): error TS2339:
Property 'SPGetCurrentUser' does not exist on type '(options?: any) => any'.
The SPServices library has been added to angular.json and in the src/
directory, a file named typings.d.ts
includes the following content:
interface JQuery {
SPServices(options?: any): any;
SPFilterNode(options?: any): any;
SPGetCurrentUser(options?: any): any;
}
Despite implementing this interface successfully in other projects, the attempt to access the SPGetCurrentUser
property within SPServices
prevents successful compilation of this specific project. How can this issue be resolved?
To address this within my pedido.component.ts
, I have declared the variable $
as shown below:
declare var $: JQueryStatic;
This declaration has functioned effectively in all prior projects except for this particular one...
For reference, I am utilizing this library from sympmarc