我有几个文件要用脚本编译.这些文件依赖于paths
compile选项来解析其模块.由于我想专门针对这些文件,我必须将它们提供给tsc
(因为我不想为这个任务创建一个单独的tsconfig.json
来针对这些文件)
我已经研究过将--path
参数传递给tsc
的选项,但这是不允许的(error TS6064: Option 'paths' can only be specified in 'tsconfig.json' file.
)
在使用paths
选项时,我是否可以只编译特定的.ts
个文件?
Update (22-06-17)
根据要求,提供一些具体示例:
tsconfig.json
文件中的相关设置如下:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"Components/*": [
"./src/Components/*"
]
}
}
}
因此,相关的部分是路径设置,您可以在其中创建从特定目录导入文件的速记.所以你可以导入一个像import {header} from 'Components/header.ts'
这样的文件,而不是import {header} from '../../Components/header.ts'
但是我需要从命令行编译特定的文件.但如果我try :
tsc --project tsconfig.json entryFile.ts
它会告诉我错误:
error TS5042: Option 'project' cannot be mixed with source files on a command line.
如果我try 向cli提供paths
选项,则会出现以下错误:
error TS6064: Option 'paths' can only be specified in 'tsconfig.json' file.