Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Part 5.1Including TypeScript in a webpage

Browsers run JavaScript, not TypeScript. Keep TypeScript in src, compile it to dist, then reference the generated JavaScript from HTML.

Compile first

index.html
<script type="module" src="./dist/main.js"></script>

Load a module

Use type="module" for modern browser code. It enables import and export, defers execution until HTML has been parsed and gives each file its own scope.

Feedback 👍
Comments are sent via email to me.