TypeScript in The Build Process 9 exercises
Problem

Unexpected Token Error in the Browser

Here we have a file example.ts that contains this run function:


const run = (message: string) => {
console.log(message);
}
run("Hello!");

Alongside that, we have a file index.html that contains the basic HTML structure and includes this script tag in the body:



Loading exercise

Transcript

00:00 In this exercise, we're going to investigate TypeScript in the browser. We have an example.ts file here, which is just a run function which has message, string, and console.log message, and we're running hello here. Next to this, we just have an index.html file.

00:17 This index.html has some basic head stuff in here, nothing too scary here, and we have a script tag where we have source example.ts here. When we go into the browser here, we're going to see that there's an uncaught syntax error saying unexpected token colon.

00:34 Your job is to work out why that's happening, like what seems to be wrong with this code, and if we can change it in any way to make it work, or just what on earth is happening, why this isn't working. Good luck.