我如何 运行 Node 上的 Typescript 脚本而不从中导入任何内容?

How can I run a Typescript script on Node without importing anything from it?

Typescript 手册提到 scripts, as opposed to modules

Conversely, a file without any top-level import or export declarations is treated as a script whose contents are available in the global scope (and therefore to modules as well).

我有几个脚本不导入任何东西,只是迭代地做一些工作,像这样:

// script.ts

console.log('test')

我想 运行 从 index.ts(在 package.json 中定义为 main)中将它们一一进行。但是,当我只导入它们时:

// index.ts

console.log(1)
import {} from './script'
console.log(2)

它在编译后的 JS 中没有做任何事情:

// index.js (compiled)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
console.log(1);
// << shouldn't there be something here?
console.log(2);
//# sourceMappingURL=index.js.map

当我 运行 我编译 index.js 时,如何正确调用该脚本以使其成为根内容 运行s?

脚本是这样导入的:

import './script'

不使用 from