node --check 的 deno 等价物是什么

What is the deno equivalent of node --check

在 node 中有一个 --check 选项来检查代码是否有效执行,如果有效则实际上 运行ning 它。 我一直在寻找 deno 中的等效项(deno 帮助,deno 运行 帮助,deno lint 帮助)

我能想到的最接近的是 deno lint,但它会很乐意检查以下打字稿代码(在 test.ts 中),deno run 随后拒绝 运行 (显然)。

什么是规范的 deno“干 运行”?

test.ts:

const message = "hello!";
message();

check if code is valid for execution

"dry run"

这些概念不存在。我想你想要的是使用 static type-checking (实际上没有 运行 模块)分析你的 TypeScript 代码。这称为 compilation,在这种情况下您想要的 Deno 子命令是 cache:

deno cache module.ts

Re-cache 入口点模块和所有依赖项:

deno cache --reload module.ts

使用你的例子test.ts:

% deno cache test.ts
Check file:///Users/deno/test.ts
error: TS2349 [ERROR]: This expression is not callable.
  Type 'String' has no call signatures.
message();
~~~~~~~
    at file:///Users/deno/test.ts:2:1