-
Notifications
You must be signed in to change notification settings - Fork 69
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
[WIP] Cannot read property 'MessageState' of undefined #242
Comments
I seem to have located the problem:
Only the default export is being exported, even though the types - including from within the Message namespace - are being exported from the index when declared in TypeScript: mailjet-apiv3-nodejs/lib/index.ts Lines 16 to 18 in 4024d94
I saw in the commit history that at one point it was considered to remove this line and it seems to have not been done. Why has this decision only been taken for the browser and not the Node version? Would it not be useful for these types to be available? |
Hi @alecrobertson1 I'm not sure why it was done. But I've tried the import you mentioned and it works. Can you please share the whole code snippet? |
Hi @ai-wintermute I have created a very simple test project to demonstrate the problem, it is available at https://github.com/alecrobertson1/TestProject. If you run the main file using
|
I'm running into the same problem here, trying to implement a simple subscribe/unsubscribe function in TypeScript: import Mailjet, { BulkContactManagement } from "node-mailjet";
import type { ContactSubscription } from "node-mailjet";
const mailjet = new Mailjet({
apiKey: process.env.MAILJET_API_KEY,
apiSecret: process.env.MAILJET_API_SECRET,
});
const subscribeToNewsletter = (id: number, shouldSub = true) => {
const contactLists: ContactSubscription.PostContactManageContactsListsBody = {
ContactsLists: [
{
ListID: MAILJET_NEWSLETTER_ID,
Action: shouldSub
? BulkContactManagement.ManageContactsAction.AddForce
: BulkContactManagement.ManageContactsAction.UnSub,
},
],
};
return mailjet
.post("contact", { version: "v3" })
.id(id)
.action("managecontactslists")
.request<ContactSubscription.PostContactManageContactsListsResponse>(
contactLists
);
}; The |
I'm just reaching out to ask about the status of this issue. This issue impacts our work, and Is there any update or approximate timeline for a fix? TypeError: Cannot read properties of undefined (reading 'TrackOpens') |
Hi @Arsalanliaqat PR with the hotfix is ready but it breaks the default import functionality. That's why we're considering other options, and it takes time. Sorry for the inconvenience. |
I am using node-mailjet within a node project that is the basis of an AWS lambda.
I am importing the Message namespace from the node-mailjet package as follows:
import { Message } from 'node-mailjet'
When the application runs (transpiled using Webpack), Message is undefined and so when I refer to the MessageState enum on this namespace, the application fails. I require the MessageState enum so I can do error handling and logging.
This appears to be an issue with how node-mailjet is processing its namespaces, with the transpiled code not including this namespace or any of its exports and so they come back as undefined.
The text was updated successfully, but these errors were encountered: