我有一个包含两个主文件夹的Typescript项目:src
和test
.
在编译TS代码时,我只想编译src
文件夹.我不需要dist
文件夹里的测试.
因此,我将这些设置设置为tsconfig.json
:
"rootDir": "./src",
"outDir": "./dist",
我以为那是做这件事的方法.但不幸的是,当我运行tsc
编译器时,我收到一条错误消息:
error TS6059: File '...my-proj/test/test.ts' is not under 'rootDir' '...my-proj/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Matched by default include pattern '**/*'
(另一个意外结果是,除了将src/*
个文件编译到dist
文件夹外,编译器还在test
文件夹中与原始文件并排创建js
个文件.)
我怎样才能实现我的目标呢?