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

unify all puppet implementations to have a default value for constructor()

上级 63713ba7
......@@ -7,7 +7,7 @@
"wechaty": {
"DEFAULT_HEAD": 0,
"DEFAULT_PORT": 8080,
"DEFAULT_PUPPET": "wechat4u",
"DEFAULT_PUPPET": "puppeteer",
"DEFAULT_PROFILE": "default",
"DEFAULT_PROTOCOL": "io|0.0.1",
"DEFAULT_TOKEN": "WECHATY_IO_TOKEN",
......@@ -118,8 +118,9 @@
"rxjs": "^6.1.0",
"state-switch": "^0.6.2",
"watchdog": "^0.8.1",
"wechaty-puppet": "^0.2.10",
"wechaty-puppet-wechat4u": "^0.2.7",
"wechaty-puppet": "^0.2.12",
"wechaty-puppet-puppeteer": "^0.2.10",
"wechaty-puppet-wechat4u": "^0.2.11",
"ws": "^5.2.0",
"xml2json": "^0.11.2"
},
......@@ -179,7 +180,7 @@
"tuling123-client": "^0.0.2",
"typedoc": "^0.11.1",
"typescript": "^2.9.2",
"wechaty-puppet-mock": "^0.2.1"
"wechaty-puppet-mock": "^0.2.4"
},
"files_comment__whitelist_npm_publish": "http://stackoverflow.com/a/8617868/1123955",
"files": [
......
// import { PuppetMock } from 'wechaty-puppet-mock'
import { PuppetMock } from 'wechaty-puppet-mock'
import { PuppetWechat4u } from 'wechaty-puppet-wechat4u'
// import { PuppetPuppeteer } from 'wechaty-puppet-puppeteer'
import { PuppetPuppeteer } from 'wechaty-puppet-puppeteer'
import { PuppetPadchat } from './puppet-padchat'
......@@ -8,11 +8,11 @@ import { PuppetPadchat } from './puppet-padchat'
* Wechaty Official Puppet Plugins List
*/
export const PUPPET_DICT = {
default: PuppetWechat4u,
default: PuppetPuppeteer,
//////////////////////////
// mock: PuppetMock,
mock: PuppetMock,
padchat: PuppetPadchat,
// puppeteer: PuppetPuppeteer,
puppeteer: PuppetPuppeteer,
wechat4u: PuppetWechat4u,
}
......
......@@ -108,7 +108,7 @@ export class PuppetPadchat extends Puppet {
private padchatManager? : PadchatManager
constructor(
public options: PuppetOptions,
public options: PuppetOptions = {},
) {
super({
timeout: 60 * 4, // Default set timeout to 4 minutes for PuppetPadchat
......
......@@ -534,6 +534,17 @@ export class Wechaty extends Accessory implements Sayable {
...this.options.puppetOptions,
}
/**
* We will meet the following error:
*
* [ts] Cannot use 'new' with an expression whose type lacks a call or construct signature.
*
* When we have different puppet with different `constructor()` args.
* For example: PuppetA allow `constructor()` but PuppetB requires `constructor(options)`
*
* SOLUTION: we enforce all the PuppetImplenmentation to have `options` and should not allow default parameter.
* Issue: https://github.com/Chatie/wechaty-puppet/issues/2
*/
return new MyPuppet(options)
} else if (puppet instanceof Puppet) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册