Skip to content

Run it in the Browser

Video Lecture

Run it in the Browser Run it in the Browser

Description

Create a file called foo.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>TypeScript for Absolute Beginners : https://sbcode.net/tsbeginners/</title>
    <style>
      body {
        overflow: hidden;
        margin: 0px;
        font-size: 8vw;
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script src="foo.js"></script>
  </body>
</html>

Add these lines to the end of your foo.ts

const root = document.getElementById('root') as HTMLDivElement
root.innerHTML = fred.getGarply()

Recompile

tsc foo.ts

And open foo.html in your browser.