0

我正在尝试Mocha使用以下命令运行单元测试Windows

mocha --require ts-node/register test.spec.ts

并得到以下错误

error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

尽管我的tsconfig.json文件中有以下内容。

"experimentalDecorators": true,

谁能建议我如何引用该tsconfig.json文件?

4

1 回答 1

0

在我的package.json脚本中,我使用以下命令在环境变量中设置我的文件tsconfig.json路径:TS_NODE_PROJECTcross-env

通过运行这样的事情,您应该能够解决装饰器问题:

cross-env TS_NODE_PROJECT=<your-ts-config-json-file> mocha --require ts-node/register test.spec.ts
于 2020-12-14T13:34:49.220 回答