Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file.type is not a function #78

Open
atorber opened this issue Apr 4, 2022 · 3 comments
Open

file.type is not a function #78

atorber opened this issue Apr 4, 2022 · 3 comments

Comments

@atorber
Copy link

atorber commented Apr 4, 2022

When I used puppet-wxwork in wechaty version 0.62.1, I encountered an error:

TypeError: file.type is not a function
at PuppetService.messageSendFile (/Users/choogoo/workspace/wechaty-mqtt-link/node_modules/wechaty-puppet-service/dist/src/client/puppet-service.js:660:46)

I found the error code. Can you help me solve the problem of file-box?

image

I tried the file-box latest and next versions, and the error is the same.

The wechaty-puppet-service version is 0.21.11

When I try to skip the if judgment, the problem is solved. Is this the problem of file-box or wechaty-puppet-service?

image

@huan
Copy link
Owner

huan commented Apr 4, 2022

Could you please try the latest version of the wechaty-puppet-service@1.19.2 to see if this issue exists? (Using https://github.com/wechaty/getting-started for easy getting started with Wechaty v1.x)

The FileBox has a breaking change between versions for the type because we upgraded to using the Interface instead of the Implementation.

  • in the previous version, it's a method (filebox.type()),
  • but in the latest version, it's a property (filebox.type).

See:

file-box/src/file-box.ts

Lines 434 to 442 in b345a22

/**
* We are using a getter for `type` is because
* getter name can be enumurated by the `Object.hasOwnProperties()`*
* but property name can not.
*
* * required by `validInterface()`
*/
readonly _type: FileBoxType
get type () { return this._type }

@atorber
Copy link
Author

atorber commented Apr 4, 2022

Another way of thinking, can I solve it by reducing the version of file box?

I want to solve the problem under 0.xx, and then try to migrate to 1.xx

@huan
Copy link
Owner

huan commented Apr 4, 2022

Another way of thinking, can I solve it by reducing the version of the file box?

Of course. You can lock the FileBox version by npm install file-box@0.x.y as you needed.

I want to solve the problem under 0.xx, and then try to migrate to 1.xx

If you can set up a reproducible repo, I might be able to help by figuring the workable version out for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants