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

#40 typescript compile success!

上级 f5d4afd7
......@@ -52,3 +52,4 @@ t/
t.*
.DS_Store
/dev.js
/dist/
......@@ -80,7 +80,7 @@ class IoClient {
this.targetState('connected')
this.currentState('connecting')
this.wechaty = new Wechaty({
this.wechaty = Wechaty.instance({
profile: Config.DEFAULT_PROFILE
})
......@@ -165,7 +165,7 @@ class IoClient {
res.send('Wechaty IO Bot Alive!')
})
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
app.listen(port, () => {
this.log.verbose('IoClient', 'initWeb() Wechaty IO Bot listening on port ' + port + '!')
......
......@@ -17,9 +17,9 @@ import Message from './message'
import Room from './room'
import log from './brolog-env'
type ContactGetterFunc = {
(id: string): Promise<any>
}
// type ContactGetterFunc = {
// (id: string): Promise<any>
// }
abstract class Puppet extends EventEmitter {
public user: Contact
......
......@@ -44,6 +44,16 @@ class Wechaty extends EventEmitter {
public uuid: string
public static instance(setting?: WechatySetting) {
if (setting && this._instance) {
throw new Error('there has already a instance. no params allowed any more')
}
if (!this._instance) {
this._instance = new Wechaty(setting)
}
return this._instance
}
private constructor(private setting: WechatySetting) {
super()
log.verbose('Wechaty', 'contructor()')
......@@ -72,13 +82,6 @@ class Wechaty extends EventEmitter {
// Wechaty._instance = this
}
public static instance(setting: WechatySetting) {
if (!this._instance) {
this._instance = new Wechaty(setting)
}
return this._instance
}
public toString() { return 'Class Wechaty(' + this.setting.type + ')'}
public version(forceNpm = false) {
......
{
"compilerOptions": {
"target": "es6"
, "module": "amd"
, "moduleResolution": "node"
, "outDir": "dist"
, "noImplicitAny": false
, "strictNullChecks": true
, "outFile": "dist/wechaty.lib.js"
, "sourceMap": true
, "noUnusedLocals": true
, "noUnusedParameters": false
, "strictNullChecks": false
, "noImplicitAny": false
, "noImplicitThis": false
, "noImplicitReturns": false
, "noFallthroughCasesInSwitch": false
}
, "exclude": [
"node_modules"
, "dist"
, "**/*.spec.ts"
]
, "files": [
"src/*.ts"
, "bin/*.ts"
, "example/*.ts"
, "include": [
"src/**/*.ts"
// , "bin/*.ts"
// , "example/*.ts"
// , "test/*.ts"
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册