Skip to content

Commit c05b7c5

Browse files
committed
Improve typescript types
1 parent 22ceb4e commit c05b7c5

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/homeManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type CreateHomeParams = {
1010
rooms: string[];
1111
};
1212

13-
export function createHome(params: CreateHomeParams) {
13+
export function createHome(params: CreateHomeParams): Promise<string> {
1414
return tuya.createHome(params);
1515
}
1616

src/user.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,29 @@ export function logout(): Promise<string> {
3434
return tuya.logout();
3535
}
3636

37-
// TODO: provide typings
38-
export function getCurrentUser() {
39-
return tuya.getCurrentUser();
37+
export async function getCurrentUser(): Promise<User | null> {
38+
const user = tuya.getCurrentUser();
39+
// The iOS SDK returns an empty user model but the Android one doesn't.
40+
return user && user.email ? user : null;
4041
}
4142

4243
export function cancelAccount(): Promise<string> {
4344
return tuya.cancelAccount();
4445
}
4546

47+
export type User = {
48+
email: string;
49+
username: string;
50+
sid: string;
51+
timezoneId: string;
52+
uid: string;
53+
userType: number;
54+
headPic: string;
55+
mobile: string;
56+
nickName: string;
57+
phoneCode: string;
58+
};
59+
4660
export type RegisterAccountWithEmailParams = {
4761
countryCode: string;
4862
email: string;

0 commit comments

Comments
 (0)