Recently, I encountered a scenario where I have a TypeScript script called test.ts
structured like this:
class Foo {
public static bar() {
console.log("test");
}
}
The requirement was to call this TypeScript function from plain JavaScript located in a file named test.html
:
<script src="test.js"></script>
<script>
Foo.bar();
</script>
Both test.html
and test.js
exist in the same directory and are compiled and bundled by webpack. The task at hand was to make this interaction possible.
After making some modifications, my program now looks like this:
class Foo {
public bar() {
console.log("test");
}
}
Despite these changes, the JavaScript code still fails to recognize the Foo
class. Any suggestions on how to fix this issue would be greatly appreciated.