Create a node project:
$ npm init
Add to your node project:
$ npm install typescript --save-dev
Add TypeScript config
$ npx tsc --init
Create a ts file for example narahate.ts:
function buildNarahate(firstName: string, layer?: string) {
if (layer) {
return firstName + " lives in the" + layer + " layer of the Abyss";
} else {
return firstName;
}
}
console.log(buildNarahate("Belaf", "sixth"));
console.log(buildNarahate("Belaf"));
then run:
$ npx ts-node ./typescriptfilename.ts
Output:
Belaf lives in the sixth layer of the Abyss
Belaf