I'm using SystemJS as a module system to compile my TypeScript files but whenever I load the page in browser (via live-server) I get following error:
ReferenceError: Sensor is not defined
at (index):17
at <anonymous>
This is my index.html file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Sensor</title>
</head>
<body>
<input type="text" id="textField"/>
<p id="text"></p>
<script src="node_modules/systemjs/dist/system.js"></script>
<script>
SystemJS.import('dist/index.js').then( function() {
var textField = new Sensor(document.getElementById('textField')).setName('textField');
}).catch(function(err) { console.log(err); });
</script>
</body>
</html>
This is my tsconfig.json file:
{
"compileOnSave": true,
"compilerOptions": {
"module": "system",
"target": "es5",
"outFile": "dist/index.js"
},
"files": [
"./src/sensor.ts",
"./src/signal.ts",
"./src/signal_receiver.ts"
]
}
I checked output file and it looks like Sensor is defined:
System.register("sensor", ["signal", "signal_receiver"], function (exports_3, context_3) {
...
exports_3("Sensor", Sensor);
Edit: I checked now and none of the functions were defined when I tried to call them.