Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescript take user input from console

import * as readline from 'node:readline';
import { stdin, stdout } from 'process';

const rl = readline.createInterface({
    input: stdin,
    output: stdout
});

rl.question("What is your name? ", function (answer: string) {
  console.log(`Oh, so your name is ${answer}`);
  console.log("Closing the interface");
  rl.close();
});
Source by sebhastian.com #
 
PREVIOUS NEXT
Tagged: #typescript #user #input #console
ADD COMMENT
Topic
Name
8+3 =