I am trying to write a typescript app that uses sendgrid, but unlike with other definitions I got from typings
the one from typings install sendgrid --ambient
is causing me some headaches:
I am able to instantiate the client like so:
import * as sendgrid from 'sendgrid';
import Email = Sendgrid.Email;
import Instance = Sendgrid.Instance;
...
private client: Instance;
...
this.client = sendgrid(user, key);
And then later in the code I am trying to send an email, which is why ts is forcing me to import the EMail interface in the first place.
var email = new Email();
...
this.client.send(email, (err, data) => {
if (err) {
throw err;
}
});
tslint doesn't throw any error, but when I build and run the program (or just my tests), I get this:
Mocha exploded! ReferenceError: Sendgrid is not defined at Object. (/Users/chrismatic/codingprojects/weview/weview-node/build/server/components/mail/clients/sendgrid.js:4:13)
Has anybody a working implementation to showcase, or do I have to write my own interface? Thanks in advance for the help
EDIT:
The generated js file looks something like this:
var sendgrid = require('sendgrid');
var Email = Sendgrid.Email;
If I decapitalize "Sendgrid", then the error disappears, but I can't do so in the ts file