microsoft / azure-devops-extension-sdk

Client SDK for developing Azure DevOps extensions
MIT License
123 stars 39 forks source link

`getUser` should never return undefined #1

Closed cschleiden closed 5 years ago

cschleiden commented 5 years ago

Why does this return IUserContext | undefined? Shouldn't we always have a user?

/**
* Gets information about the current user
*/
export declare function getUser(): IUserContext | undefined;
nkirchem commented 5 years ago

If you call any of the synchronous methods like getUser before the initial handshake has completed (i.e. in a ready callback) then you'll get undefined. I'm thinking to explicitly throw in that case, then we can leave the more strict typing (no undefined). That should make it easier to consume.

cschleiden commented 5 years ago

I agree, that sounds easier to consume.

nkirchem commented 5 years ago

Fixed in 2.0.2