Quickly create a local typescript running environment.

Quickly create a native Typescript runtime environment.

npm init -f
npm -D i typescript@4
npm -D i @types/node@12 @types/vscode@1
npm -D i ts-node

npm -g i https://github.com/zhmhbest/AttachConfiguration
attach package.json "main='src/index.ts'"
attach package.json "scripts>build='tsc -p ./'"
attach package.json "scripts>watch='tsc -watch -p ./'"
attach package.json "scripts>start='ts-node src/index.ts'"

mkdir src
mkdir .vscode
touch ./tsconfig.json
touch ./src/index.ts
touch ./.vscode/launch.json

tsconfig.json

{
    "compilerOptions": {
        "sourceMap": true,
        "module": "CommonJS",
        "target": "ES2016",
        "lib": ["ES2016"],
        "rootDir": "./src",
        "outDir": "./out",
        "strict": true,
        "skipLibCheck": true,
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true,
        "noUnusedParameters": true,
    },
    "include": ["./src/**/*"],
    "exclude": ["node_modules", "dist", "out"]
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "node",
            "request": "launch",
            "args": [
                "${workspaceRoot}/src/index.ts"
            ],
            "runtimeArgs": [
                "--nolazy",
                "-r",
                "ts-node/register"
            ],
            "sourceMaps": true,
            "cwd": "${workspaceRoot}",
            "protocol": "inspector",
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen"
        }
    ]
}

index.ts

function sayHello() {
    console.log("Hello!");
}
sayHello();

Read More: