Open rsweetland opened 5 years ago
After spending a lot of time on trying to find a proper way to write the export in the declaration file, I decided to actually change the source code.
Right now, the sdk exports a class as the whole export object via:
module.exports = MailBotsClient
This pattern is quite weird to use in typescript as it requires either a special way of importing the module
import thing = require("./Thing");
which works fine until you want to use that import as a type
or to enable a compiler flag (esModuleInterop) and use default import style syntax:
import MailBotsClient from "@mailbots/mailbots-sdk";
, but this leads to other compiling issues.
The easiest fix is to export a named export from the mailbots-sdk.js
module:
module.exports = {
MailBotsClient
};
and use standard typescript module syntax. More details can be found in (this article)[https://dzone.com/articles/import-statements-in-typescript-which-syntax-to-us].
Need to remember that after we integrate this branch we will have breaking changes in code that uses this sdk.
Add declarations for all method and class names for fun and easy TypeScript development in other libs.