The browser editor is enough for this course’s exercises. Running locally is an optional next step that gives you real files, a compiler command and repeatable tests. Download the study planner ZIP and extract it before running any commands.
Install Node.js 22 or later, which includes npm. A terminal is a text interface where you run commands in a folder. Open a terminal inside the extracted study-planner folder; its package.json should be visible there. node --version and npm --version confirm that the tools are available. These are terminal commands, not TypeScript to paste into a playground.
Run npm install once to download this project’s pinned compiler. Run npm run check to type-check without writing output. Run npm start to compile and execute the main program, and npm test to compile and run the tests. The first install needs a network connection. Normal execution uses no remote service.
Read the six source files. model.ts contains types, validation and reporting. main.ts calls those functions. tsconfig.json stores compiler settings. package.json names dependencies and commands. tests.mjs tests the emitted JavaScript; README.md explains the contract. Compilation creates dist/; installation creates node_modules/. Do not edit generated files to fix source mistakes.
The import in main.ts uses ./model.js intentionally: Node runs the compiled JavaScript. With this project’s NodeNext settings, TypeScript resolves that import to model.ts during checking. Do not paste that import into these single-file editors. The local compiler and browser use the same strict safety checks, with module settings appropriate to each environment.
Read a two-file program
A module is a file with explicit exports and imports. export makes a declaration available to another file; it does not run the function. A named import gives the caller access to those exported values. You have not needed modules in the single-file editors, so read this small example before the project files.
In model.ts (file contents, not a standalone playground):
export function double(minutes: number): number {
return minutes * 2;
}
In main.ts:
import { double } from "./model.js";
console.log(double(25));
The braces select a named export; they are module syntax, not a new record. ./ means the same folder. Compilation creates dist/model.js and dist/main.js. Running node dist/main.js prints 50. The real project follows the same pattern with parseSessions and summarize. Keep its original files while reading; these two tiny files only illustrate the relationship.
The project’s tests.mjs file is JavaScript, so its Node imports do not require learning new TypeScript syntax. test(name, callback) groups a case; assert.deepEqual(actual, expected) compares the values and structure of records or arrays and fails the case if they differ. assert.equal compares individual values. The test runner prints pass/fail results. The in-browser lesson uses the small assertion helper already taught; you can review the Node test file after the core exercise.
The shell commands in the project’s README are meant to be run one at a time inside its folder:
npm install
npm run check
npm start
npm test
No errors from check means the compiler accepted the program. Start prints 1 complete, 25 min. Test reports six passing runtime cases. This does not save sessions permanently or start a website.
Predict, check, then run
Before running, write down the output and explain which information the checker knows. Click Check types first, then Check & run.
const environment = "browser console";
console.log(`Current runner: ${environment}`);
console.log("Local project: npm run check, npm start, npm test");Enable JavaScript to edit and type-check this example.
Check your prediction
Current runner: browser console
Local project: npm run check, npm start, npm test Your turn
Running TypeScript Locally: practise
Practise the same source-level error locally or here: define minutes as a number with value 25, then print its double. Introduce a string assignment and confirm checking fails. Restore valid code. If working locally, confirm npm start prints 1 complete, 25 min and npm test passes.
// This box accepts TypeScript, not shell commands. Declare minutes and print twice its value.Enable JavaScript to edit and type-check this example.
Hint 1: the idea
The local compiler checks source; Node executes its emitted JavaScript.
Hint 2: a first step
Use a numeric annotation and multiplication. Save shell commands for a terminal.
Show one solution
const minutes: number = 25;
console.log(minutes * 2);Enable JavaScript to edit and type-check this example.
50Explain the types at the function boundary and the runtime checks, if any. Compare your approach before copying this answer.
Change it and explain it
If working locally, change a field type in main.ts and confirm both check and start stop at the compiler error. Fix the source and rerun. If staying in the browser, use Download .ts to save your own exercise, and explain why saving source is different from compiling it.
Completion is saved in this browser only. It does not measure mastery.