Seeking assistance with maintaining directory structure when compiling Typescript to Javascript in Intellij Idea. The current directory setup is as follows:
root
- ts
- SomeClass1.ts
- SomeFolder
- AwesomeClass2.ts
- tsc
The desired compiled file structure should be:
root
- tsc
- SomeClass1.js
- SomeFolder
- AwesomeClass2.js
https://i.sstatic.net/CVQMt.png
This is my Typescript configuration:
https://i.sstatic.net/bl207.png
https://i.sstatic.net/MGYUV.png
However, during compilation, the console displays this error:
https://i.sstatic.net/sI2so.png
- Setting "Use output path" to "tsc" results in successful compilation, but the directory structure is lost, causing RequireJS to not locate the files.
- Setting "Use output path" to "tsc\$FileDirRelativeToSourcepath$" generates the error "cannot read the property 'replace' of undefined".
- Disabling "Use output path" and utilizing "--outDir" with "Command line options" compiles the files into the correct directory, but IntelliJ no longer automatically recompiles changed files.
UPDATE, solution by Nitzan Tomer:
To address this issue, create tsconfig.json in the root directory:
{
"compilerOptions": {
"module": "amd",
"target": "es5",
"outDir": "tsc",
"rootDir": "ts",
"sourceMap": true,
"declaration": true
},
"exclude": [
"tsc"
]
}
Remember to enable "use tsconfig.json" in IntelliJ for proper functionality.