Situation
Every time I launch my application from index.html
, linking the main.js
file, which has been compiled from Typescript using es6
as the target and ESNext
as the module, an error pops up in the browser:
Error
main.js:3 Uncaught SyntaxError: Unexpected token {
Main.ts
/// IMPORTS
//////////////////////////////////////////////////////////////////////
import { Player } from './classes/Player' <= Error Found!
import { printTable } from './helpers/Helpers'
/// MAIN COMMANDS
//////////////////////////////////////////////////////////////////////
let p1 = new Player('Bob', 'Hunter', 1, 10);
printTable(p1);
Idea
I seem to be importing my code incorrectly, and am struggling to understand why. This method of importing exported code, classes, etc., is commonly used, so I can't figure out where I'm going wrong. Everything runs smoothly when all code is in one file, but when I try to organize it differently, issues arise.
Any advice would be greatly appreciated.
- Thank you in advance!