From dda941b0fece58548ce2fd16fffeb48be6f8ce76 Mon Sep 17 00:00:00 2001 From: "Zhuohuan LI (CARPE DIEM)" Date: Thu, 20 Oct 2016 20:40:39 +0800 Subject: [PATCH] fix #54 --- src/wechaty.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wechaty.ts b/src/wechaty.ts index ec7ffc00..0a0ff453 100644 --- a/src/wechaty.ts +++ b/src/wechaty.ts @@ -134,7 +134,12 @@ export class Wechaty extends EventEmitter implements Sayable { return this.npmVersion } - public user(): Contact | null { return this.puppet && this.puppet.user } + public user(): Contact { + if (!this.puppet || !this.puppet.user) { + throw new Error('no user') + } + return this.puppet.user + } public reset(reason?: string) { log.verbose('Wechaty', 'reset() because %s', reason) -- GitLab