Skip to content

Commit

Permalink
feat(core): new Session() respect non-enumerable properties
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Sep 4, 2023
1 parent b1adaa9 commit 798ea7b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ export class Session {
public bot: Bot
public app: Context['root']

constructor(bot: Bot, payload?: Partial<Session.Payload>) {
constructor(bot: Bot, payload: Partial<Session.Payload> = {}) {
this.data = {}
Object.assign(this, payload)
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(payload))) {
Object.defineProperty(this, key, descriptor)
}
this.selfId = bot.selfId
this.platform = bot.platform
defineProperty(this, 'bot', bot)
Expand Down

0 comments on commit 798ea7b

Please sign in to comment.