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

fix: Constants export in index.js #285

Merged
merged 5 commits into from
Aug 3, 2020

Conversation

stefanfuchs
Copy link
Contributor

I came across an error while trying to use the enums present in index.d.ts; Example:

import WhatsappWeb = require('whatsapp-web.js')
if (messageType === WhatsappWeb.MessageType.TEXT) // Error: cannot read property 'TEXT' of undefined

I found out that even though MessageType is defined in index.d.ts, it should also be exported in index.js, in order for it to be present at runtime.
This PR exports all the Constants in index.js and fixes the issue.

Note: I used the spread operator to export all the constants at once. If you think it should be better to export them individually, please let me know and I can try doing that also.

@stefanfuchs
Copy link
Contributor Author

Note2: I also added some missing contants that were in the Constants.js but not index.d,ts:

  • WhatsWebURL: string
  • DefaultOptions: ClientOptions

@pedroslopez
Copy link
Owner

LGTM

Thank you :)

@pedroslopez pedroslopez merged commit fbdfd2c into pedroslopez:master Aug 3, 2020
Belfio pushed a commit to Belfio/whatsapp-web.js that referenced this pull request Jan 9, 2024
* fix: add Constants export in index.js
* fix: add missing constants export in index.d.ts


Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
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

Successfully merging this pull request may close these issues.

2 participants