Currently, I am working on developing a plugin example and facing an issue. I am struggling to make the module loader recognize that the plugin has additional functionality compared to the original. I believe I am close to a solution, but a little nudge in the right direction would be greatly appreciated.
If you are interested, you can find the plugin example code on GitHub here.
Within my main file named Communicator.ts, I have the following code snippet:
import * as communicatorModularAMD from "communicatorModularAMD";
class Communicator {
constructor() { }
greet(message: string) {
return communicatorModularAMD.goodbye();
}
};
var communicator = new Communicator();
document!.body.innerHTML = communicator.greet("Hello, world");
Essentially, CommunicatorModularAMD is a JavaScript library I have developed and integrated into this project. My goal is to showcase how to create a plugin for it, hence the following code snippet:
define(['CommunicatorModularAMD'], function() {
return {
goodbye: function() {
return "<h1>Goodbye!</h1>";
}
};
});
Alongside this, I have a declaration file with the following content:
import * as m from 'communicatorModularAMD';
declare module 'communicatorModularAMD' {
export function goodbye(): string;
}
Although the TypeScript compiles without any errors, the "goodbye" function is not found when I attempt to run the application. Upon inspecting the console.log output of the communicatorModularAMD object, it becomes evident that "goodbye" is missing.