I have several files I want to compile using a script. These files rely on the paths
compile option to resolve its modules. As I want to target these files specifically I am bound to supplying them to tsc
(as I don't want to create a separate tsconfig.json
that targets these files for this task)
I've looked at the option to pass the --path
parameter to tsc
, but this is not allowed (error TS6064: Option 'paths' can only be specified in 'tsconfig.json' file.
)
Can I somehow only compile specific .ts
files while using the paths
option?
Update (22-06-17)
As per request some specific examples:
The relevant settings in the tsconfig.json
file are the following:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"Components/*": [
"./src/Components/*"
]
}
}
}
so the relevant part is the paths setting, where you can create shorthands to import files from a certain directory. so you can import a file like import {header} from 'Components/header.ts'
in stead of import {header} from '../../Components/header.ts'
But I need to compile specific files from the command line. But if I try:
tsc --project tsconfig.json entryFile.ts
it will give me the error:
error TS5042: Option 'project' cannot be mixed with source files on a command line.
and if I try to provide the paths
option to the cli I get the following error:
error TS6064: Option 'paths' can only be specified in 'tsconfig.json' file.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…