提交 7c053a2c 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

fix Room.create() typing error

上级 6228a6d2
......@@ -67,11 +67,11 @@ export abstract class Message extends PuppetAccessory implements Sayable {
]
}
public static create<T extends Message>(
this: { new (...args: any[]): T },
...args: any[],
): T {
return new this(...args)
public static create<T extends typeof Message>(
this: T,
...args: any[]
): T['prototype'] {
return new (this as any)(...args)
}
/**
......
......@@ -70,10 +70,10 @@ export const PUPPET_EVENT_DICT = {
export type PuppetEventName = keyof typeof PUPPET_EVENT_DICT
export type PuppetContact = typeof Contact & Constructor<{}>
export type PuppetFriendRequest = typeof FriendRequest & Constructor<{}>
export type PuppetMessage = typeof Message & Constructor<{}>
export type PuppetRoom = typeof Room & Constructor<{}>
export type PuppetContact = typeof Contact & Constructor<Contact>
export type PuppetFriendRequest = typeof FriendRequest & Constructor<FriendRequest>
export type PuppetMessage = typeof Message & Constructor<Message>
export type PuppetRoom = typeof Room & Constructor<Room>
export interface PuppetClasses {
Contact: PuppetContact,
......@@ -162,7 +162,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public emit(
event: PuppetEventName,
...args: any[],
...args: any[]
): boolean {
return super.emit(event, ...args)
}
......
......@@ -113,14 +113,13 @@ export class Wechaty extends PuppetAccessory implements Sayable {
public readonly cuid: string
// tslint:disable-next-line:variable-name
public Contact : typeof Contact // & Constructor<{}>
public Contact : typeof Contact
// tslint:disable-next-line:variable-name
public FriendRequest : typeof FriendRequest // & Constructor<{}>
public FriendRequest : typeof FriendRequest
// tslint:disable-next-line:variable-name
public Message : typeof Message // & Constructor<{}>
public Message : typeof Message
// tslint:disable-next-line:variable-name
public Room : typeof Room // & Constructor<{}>
// public Room : typeof Room & Constructor<{}>
public Room : typeof Room
/**
* get the singleton instance of Wechaty
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册