CMD - Guidelines
0
Comments
CMD - Guidelines
// npm init // Project Name : myapp , and enter ,enter, enter //tsc init -y // npm i -D @types/node // npm i chalk // npm i inquirer // npm i -D @types/inquirer //Setting in ts config & Package.json (Follow the instructions in Video) // Video Link : https://www.youtube.com/watch?v=vIBkwIbICNM // Only Use "tsc" for compile , Not "tsc filename.ts" (Expalined in the Video);
Inquirer & Chalk In TypeScript - Class Code
import inquirer from "inquirer"; import chalk from "chalk"; // console.log( // chalk.green("This sentence is "), // chalk.bgYellow.blue.bold("important"), // chalk.green("!") // ); console.log(chalk.red("This Sentence is in red Color") , chalk.bgGreen.red.bold("important") , chalk.bgCyan.blue.bold("?????")); inquirer.prompt( [ // Array { // Object name : "myName" , type : "input" , message : "What is Your Name : " }, { name : "fruitList", type : "list", choices : ["Orange" , "Apple" , "Banana" , "Mango"], message: "What is Your Favourite Fruit" }, { name : "confirmbox", type: "confirm", message: "Do You Want to Delete the File ?? " } ] ).then((answer) => { console.log(`My Name is ${chalk.bgBlack.white(answer.myName)}, my Favourite is ${chalk.bgBlue.green(answer.fruitList)}`); if (answer.confirmbox){ console.log('The File is Deleted'); }else{ console.log(' The File is Not Deleted'); } }) // Second Method const answer = await inquirer.prompt([ // { // name: "myName", // type: "input", // message: "What is Your Name : " // }, // { // name: "fruitList", // type: "list", // choices: ["Orange", "Apple", "Banana", "Mango"], // message: "What is Your Favourite Fruit" // }, // { // name: "confirmbox", // type: "confirm", // message: "Do You Want to Delete the File ?? " // } // ]) // console.log(`My Name is ${chalk.bgBlack.white(answer.myName)}, my Favourite is ${chalk.bgBlue.green(answer.fruitList)}`); // if (answer.confirmbox) { // console.log('The File is Deleted'); // } // else { // console.log(' The File is Not Deleted'); // };
Export File Code - Class Code
let myName : string = "Abdul Hannan"; let array1 : any = ["Hannan" , true , false , 1 , 3, 5 ] function myfunc (name : string){ return name; } export {myName , array1 , myfunc };
Import File Code - Class Code
import { array1 , myfunc, myName } from "./export.js"; console.log(myName); console.log(myfunc("Abdul Hannan")); console.log(array1);
Post a Comment