Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Issue with pnp.sp.profiles.getPropertiesFor() Wrong defined resulttype #656

Closed
zyborc opened this issue Dec 5, 2017 · 4 comments
Closed

Comments

@zyborc
Copy link

zyborc commented Dec 5, 2017

Category

[ ] Enhancement

[x] Bug

[ ] Question

Version

Please specify what version of the library you are using: [ 3.0.2]

Expected / Desired Behavior / Question

I want to get the profile picture of a user in my angular2 app.
I use the following code:
return new Promise((resolve, reject) => { pnp.sp.profiles.getPropertiesFor(AccountName).then(res => { const pictureUrl = res.PictureUrl; resolve(pictureUrl); });

I get the typescript error that any[] dont have the property PictureUrl. When i change the typing in node_modules\sp-pnp-js\lib\sharepoint\userprofiles.d.ts from
getPropertiesFor(loginName: string): Promise<any[]>;
to
getPropertiesFor(loginName: string): Promise<any>;

the code runs as it should.

Im reporting this because im using continues integration from visual studio online and i cant change the code in there for the build process and it runs on this error.

Maybe its my fault and i should use the function differently. But since the code is working with my change of the typings i hope you could update it or show me the correct way to use the function.

Kind regards,

Alex

@koltyakov
Copy link
Collaborator

Thanks, @zyborc!

You're right, there was an issue with promise return type.
I've pushed a PR fixing this, targeted for 3.0.3.

Temporary, you can workaround CI linting with (res as any).PictureUrl:

return pnp.sp.profiles.getPropertiesFor(AccountName)
  .then(res => (res as any).PictureUrl);

@zyborc
Copy link
Author

zyborc commented Dec 5, 2017

@koltyakov Thanks a lot!

The workaround is perfect :-)

@zyborc zyborc closed this as completed Dec 5, 2017
@doxic012
Copy link

doxic012 commented Jun 11, 2018

This issue is still persistent in pnp/pnpjs 1.1.0

@patrick-rodgers
Copy link
Contributor

Hi @doxic012 - perhaps you meant to post this in the other repo? If you could open an issue there with details that would help us track things. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants