I'm trying to recover the current user on a Sharepoint App inside Sharepoint server, It works in an old app I've tested here builded on AngularJS.
The code on AngularJS app is like this code below
var thisUser = $().SPServices.SPGetCurrentUser({
fieldName: "Title",
debug: false
});
Now I'm trying to use the same code in Angular version 6, but when I try to build the project using this code. An error is accused
ERROR in src/app/pedido/pedido.component.ts(68,43): error TS2339:
Property 'SPGetCurrentUser' does not exist on type '(options?: any) => any'.
I've added the lib of SPServices on my angular.json, and on my src/
folder, I've the file typings.d.ts
with the content below
interface JQuery {
SPServices(options?: any): any;
SPFilterNode(options?: any): any;
SPGetCurrentUser(options?: any): any;
}
Using this interface I can build other projects, just this one that tries to access the property SPGetCurrentUser
in the SPServices
don't let me build my project, what I can do to solve this?
On my pedido.component.ts
I've declared the $
, like the example below
declare var $: JQueryStatic;
It worked in all other projects, only in this one that doesn't...
I'm using this lib from sympmarc
My friend here found a solution to this problem, He changed the content in typings.d.ts
to the example below
interface JQuery {
//SPServices?(options?: any): any; // This line was removed
SPServices: any; // This line was added
// Now the property SPGetCurrentUser can be viewed in the SPServices
SPFilterNode(options?: any): any;
}