wechaty-puppet-padlocal-demo icon indicating copy to clipboard operation
wechaty-puppet-padlocal-demo copied to clipboard

Type 'PuppetPadlocal' is not assignable to type 'Puppet'.

Open forconz opened this issue 4 years ago • 7 comments

PS D:\Projects\Test\wechaty-puppet-padlocal-demo> npm run demo

[email protected] demo D:/Projects/Test/wechaty-puppet-padlocal-demo/node_modules/.bin/ts-node main.ts

D:\Projects\Test\wechaty-puppet-padlocal-demo\node_modules\ts-node\src\index.ts:513 return new TSError(diagnosticText, diagnosticCodes) ^ TSError: ⨯ Unable to compile TypeScript: main.ts:13:5 - error TS2322: Type 'PuppetPadlocal' is not assignable to type '"wechaty-puppet-hostie" | "wechaty-puppet-puppeteer" | "wechaty-puppet-service" | "wechaty-puppet-mock" | "wechaty-puppet-wechat" | "wechaty-puppet-wechat4u" | "wechaty-puppet-padlocal" | ... 6 more ... | Puppet'. Type 'PuppetPadlocal' is not assignable to type 'Puppet'. Property 'options' is protected but type 'PuppetPadlocal' is not a class derived from 'Puppet'.

13 puppet, ~~~~~~

node_modules/wechaty/dist/src/wechaty.d.ts:13:5 13 puppet?: PuppetModuleName | Puppet; ~~~~~~ The expected type comes from property 'puppet' which is declared here on type 'WechatyOptions'

at createTSError (D:\Projects\Test\wechaty-puppet-padlocal-demo\node_modules\ts-node\src\index.ts:513:12)
at reportTSError (D:\Projects\Test\wechaty-puppet-padlocal-demo\node_modules\ts-node\src\index.ts:517:19)
at getOutput (D:\Projects\Test\wechaty-puppet-padlocal-demo\node_modules\ts-node\src\index.ts:752:36)
at Object.compile (D:\Projects\Test\wechaty-puppet-padlocal-demo\node_modules\ts-node\src\index.ts:968:32)
at Module.m._compile (D:\Projects\Test\wechaty-puppet-padlocal-demo\node_modules\ts-node\src\index.ts:1056:42)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (D:\Projects\Test\wechaty-puppet-padlocal-demo\node_modules\ts-node\src\index.ts:1059:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)

forconz avatar Sep 07 '21 17:09 forconz

A modification need to be made in creating the bot: Use const bot = new Wechaty({ name: "TestBot", puppet: "wechaty-puppet-padlocal", puppetOptions: { token:"token", } }) change token by your own token

GNFu avatar Sep 26 '21 19:09 GNFu

Same issue for me, with mbp, [email protected], token from http://pad-local.com/.

For @GNFu 's solution, still not work, traceback here:

➜ wechaty-puppet-padlocal-demo git:(patch-1) npm run demo

[email protected] demo ./node_modules/.bin/ts-node main.ts

TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined at new NodeError (internal/errors.js:322:7) at checkListener (events.js:135:11) at _addListener (events.js:433:3) at StateSwitch.addListener (events.js:497:10) at PuppetPadlocal._startClient (/Users/zhangbin/workspace/wechaty-puppet-padlocal-demo/node_modules/wechaty-puppet-padlocal/src/puppet-padlocal.ts:145:20) at PuppetPadlocal.start (/Users/zhangbin/workspace/wechaty-puppet-padlocal-demo/node_modules/wechaty-puppet-padlocal/src/puppet-padlocal.ts:141:16) at Wechaty.start (/Users/zhangbin/workspace/wechaty-puppet-padlocal-demo/node_modules/wechaty/src/wechaty.ts:695:25) at processTicksAndRejections (internal/process/task_queues.js:95:5) { code: 'ERR_INVALID_ARG_TYPE' } 19:03:20 ERR Wechaty start() exception: The "listener" argument must be of type function. Received undefined 19:03:20 ERR TestBot on error: 19:03:20 WARN Wechaty stop() puppet.stop() exception: The "listener" argument must be of type function. Received undefined 19:03:20 INFO TestBot started.

iamsk avatar Jan 20 '22 11:01 iamsk

Yep, confirmed from my end as well:

wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:513
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
main.ts(13,5): error TS2322: Type 'PuppetPadlocal' is not assignable to type '"wechaty-puppet-hostie" | "wechaty-puppet-puppeteer" | "wechaty-puppet-service" | "wechaty-puppet-mock" | "wechaty-puppet-wechat" | "wechaty-puppet-wechat4u" | "wechaty-puppet-padlocal" | ... 6 more ... | Puppet'.
  Type 'PuppetPadlocal' is missing the following properties from type 'Puppet': cacheContactPayload, cacheFriendshipPayload, cacheMessagePayload, cacheRoomPayload, and 17 more.

    at createTSError (/path/to/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:513:12)
    at reportTSError (/path/to/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:517:19)
    at getOutput (/path/to/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:752:36)
    at Object.compile (/path/to/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:968:32)
    at Module.m._compile (/path/to/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:1056:42)
    at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Object.require.extensions.<computed> [as .ts] (/path/to/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:1059:12)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)

My env:

node -v; npm -v; npm ls | grep wechaty
v14.19.0
8.5.0
├── [email protected]
└── [email protected]

AntonioSun avatar Feb 15 '22 22:02 AntonioSun

Have you tried the [email protected] with Node.js v16?

I think those versions would solve your problem. @AntonioSun

huan avatar Mar 01 '22 01:03 huan

Oh thanks @huan, what's the corresponding wechaty-puppet versions that goes with [email protected]? If I don't specify it, it goes to version 1, and fails my npm install.

AntonioSun avatar Mar 01 '22 14:03 AntonioSun

@AntonioSun never specific a wechaty-puppet version manually because it was highly coupled with the wechaty version.

v1 is not compatible with v0.x

If the wechaty 0.68 works for you, then my suggestion is just to use it.

The PadLocal is preparing to upgrade to support wechaty v1, you can see this PR:

  • https://github.com/wechaty/puppet-padlocal/pull/125

huan avatar Mar 01 '22 23:03 huan

what's the corresponding wechaty-puppet versions that goes with [email protected]?

This is what happened when I don't specify the wechaty-puppet versions:

$ npm list --depth=1 | grep -E 'wechaty|file-'
+-- [email protected]
+-- [email protected]
| +-- [email protected]
`-- [email protected]
  +-- [email protected]
  +-- [email protected]

If I don't specify it, it goes to version 1.

See the [email protected] one under [email protected].

Consequently, this is what I get when running ding-dong.js:

TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined
    at checkListener (node:events:258:3)
    at _addListener (node:events:553:3)
    at StateSwitch.addListener (node:events:617:10)
    at PuppetPadlocal._startClient (/.../node_modules/wechaty-puppet-padlocal/dist/puppet-padlocal.js:98:24)
    at PuppetPadlocal.start (/.../node_modules/wechaty-puppet-padlocal/dist/puppet-padlocal.js:95:20)
    at Wechaty.start (/.../node_modules/wechaty/dist/src/wechaty.js:524:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}
14:35:23 ERR Wechaty start() exception: The "listener" argument must be of type function. Received undefined
14:35:23 ERR StarterBot TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined

Anyway, I now know that the corresponding wechaty-puppet versions that goes with [email protected] is [email protected]. thx!

AntonioSun avatar Mar 06 '22 19:03 AntonioSun