My First TypeScript Project

Overview

Prerequisites

Part 1 - Initializing Project Config

projectName="my-first-typescript"
mkdir $projectName
cd $projectName
ts --init

Part 2 - Serving Project

Part 3 - Setting Up Project Structure

mkdir ./src # directory to store typescript source & webpage metafiles
mkdir ./src/static/css
mkdir ./src/static/image
mkdir ./src/static/ts
mkdir ./src/static/js
mkdir ./templates # directory to store webpage html source files

Part 4 - Modifying Config

Part 4 - Linking index

echo '
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="">
  <meta name="author" content="">

  <link href="./static/css/style.css" rel="stylesheet">
  <script type="text/javascript" src="./static/js/utils.js"></script>
  <script type="text/javascript" src="./static/js/header-functions.js"></script>
</head>


<body>
  <h1>The quickest of brown foxes.</h1>
  <footer>
    <script type="text/javascript" src="./static/js/footer-functions.js"></script>
  </footer>
</body>

</html>
' > ./templates/index.html

Part 5 - Writing the TypeScript

echo '
const log: any = (prompt) => console.log(prompt);
' > ./src/static/ts/utils.ts
echo '
log("Hello world!");
' > ./src/static/ts/header-functions.ts