Reputation: 9697
I have a mixed Java/Typescript project which uses Maven as a build tool together with the frontend-maven-plugin and I can build my project as expected from the command line. I have an issue however with IntelliJ 2018.2 in that it keeps transpiling .js
files for my .ts
source code. The .js
files are picked up by the Jest test runner so test are run twice and cause the Maven build to fail as they do not pass linting.
I have the TypeScript Language Service enabled as if that is disabled IntelliJ shows me errors throughout my TypeScript code. If I un-tick "Recompile on changes" then every .ts file shows a prompt at the top asking if I want to "Compile TypeScript to JavaScript? Yes/No/Configure".
Is it possible to configure IntelliJ so it writes .js
files into a separate build directory (which is excluded) in the same way create-react-app works?
Upvotes: 6
Views: 2981
Reputation: 93748
Make sure to disable Recompile on changes in Settings | Languages & Frameworks | TypeScript.
To write .js
files to the separate folder, set the "outDir"
in your tsconfig.json
to the desired path. If you aren't using tsconfig.json
, you can specify --outDir <DIRECTORY>
in Options: field. But I'd strongly recommend setting up tsconfig.json
instead of passing cmd options to compiler - using tsconfig.json is an industry standard for working with TypeScript applications
Upvotes: 12