'How to create a simple (Hello World) node.js TypeScript project with ES6 modules?

Imagine a very simple program with a main file and some functions in a separate file, using ES6 modules and intended to be run with node.js.

my-utils.ts:

import * as fs from "fs";

export function readSimpleFile() {
    return fs.fileReadSync("hello.txt", "utf-8");
}

main.ts:

import {readSimpleFile} from "./my-utils"

console.log(readSimpleFile());

What is the minimum set of files I need to add to the project and commands I have to run to get it building, running and checking types?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source