全新打字稿安装 WSL 后无法 运行 基本 hello_world.ts 文件

Unable to run basic hello_world.ts file after fresh typescript installation WSL

我正在尝试开始使用 Typescript。

我已经学习了官方的 5 分钟教程:https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html

npm install -g typescript

这显然太容易让人难以置信。在对 SO 进行一些研究之后,我在这些命令方面取得了进展:

➜  test_typescript npm config get prefix bin
/home/amehmeto/.npm-new
➜  test_typescript export PATH=/home/amehmeto/.npm-new/bin:$PATH
➜  test_typescript tsc -v
Version 3.7.2
➜  test_typescript tsc hello.ts
➜  test_typescript cat hello.ts
function greeter(person) {
    return "Hello, " + person;
}

let user = "Jane User";

document.body.textContent = greeter(user);
➜  test_typescript node hello.ts
/mnt/c/Users/Shadow/Development/test_typescript/hello.ts:7
document.body.textContent = greeter(user);
^

ReferenceError: document is not defined
    at Object.<anonymous> (/mnt/c/Users/Shadow/Development/test_typescript/hello.ts:7:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
    at Module.load (internal/modules/cjs/loader.js:914:32)
    at Function.Module._load (internal/modules/cjs/loader.js:822:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1143:12)
    at internal/main/run_main_module.js:16:11
➜  test_typescript vim hello.ts
➜  test_typescript tsc hello.ts
➜  test_typescript node hello.ts
Hello, Jane User

我把hello.ts的最后一行改成了console.log(greeter(user));

所以它与 node 命令一起工作,我理解这是因为脚本是纯粹的 javascript。但是tsc拼命保持沉默。

我想我对该教程的阅读还不够多,我希望 tsc 相当于 node.js。不是,就是编译,做好,只做。