Reading input (stdin)

Read what you type in the IDE's Input tab with Node's fs module.

Runs in Zerethon IDE · TypeScript 7 Official TypeScript documentation ↗

Type the input in the Input tab before pressing Run, then read all of standard input (file descriptor 0) at once.

main.ts
import * as fs from 'fs';

const lines: string[] = fs.readFileSync(0, 'utf8').split('\n');
const name = lines[0];
const [a, b] = lines[1].split(' ').map(Number);
console.log(`Hello, ${name}! ${a} + ${b} = ${a + b}`);

Input (stdin)

Ada
3 4

Output

Hello, Ada! 3 + 4 = 7