If you want to import a module in Javascript, consider using SystemJS.
Let's say you have a module called app.ts that exports a variable named value.
Here is an example of the app.ts module:
export let value = 'ABCASF';
To import this module in a script tag, you can use the following code:
System.import('app.js').then(function(appModule) {
console.log(appModule.value);
}, console.error.bind(console));
Remember, the module name provided in the System.import function may vary depending on your configuration.
For TypeScript classes transpiled into ES5 functions, you can utilize them in javascript like this:
Consider the example.ts class:
export class Example {
constructor(public someValue: string, private someOtherValue: number) {
}
public method() {
return this.someOtherValue;
}
}
And when importing this class in a script tag:
System.import('example.js').then(function(example) {
// Example class is a function within the module
// Create a new instance using 'new'
var value = new example.Example('a', 5);
// Utilize the class as usual
console.log(value.method());
}, console.error.bind(console));