We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Build

To kick things off, let's get our TypeScript project started with a classic "Hello, World!" program.

GitHub

I highly recommend that you create a git repository for Chirpy hosted on GitHub (or whichever host you prefer), then clone the repo down onto your local machine. It's not a requirement, but a best practice. Use Git to save your work as you go.

TypeScript Projects

The npm init command creates a package.json file to track the project's scripts and dependencies. The TypeScript compiler reads tsconfig.json to find the source files in src and compile them into JavaScript files in dist.

Assignment

Set up a runnable TypeScript project.

npm init -y
npm install -D typescript @types/node
{
  "compilerOptions": {
    "target": "esnext",
    "module": "nodenext",
    "rootDir": "./src",
    "outDir": "./dist",
    "strict": true,
    "moduleResolution": "nodenext",
    "esModuleInterop": true,
    "skipLibCheck": true
  },
  "include": ["./src/**/*.ts"],
  "exclude": ["node_modules"]
}
{
...
  "type": "module",
  "scripts": {
    "build": "npx tsc",
    "start": "node dist/index.js",
    "dev": "npx tsc && node dist/index.js"
  },
...
}

Run and submit the CLI tests from the project root.