TypeScript in The Build Process 9 exercises

Configure the Output Directory for Compiled Files

The first step in the solution is to go into tsconfig.json and look for the outDir setting. This is how you can specify the output directory for compiled files:

// inside tsconfig.json
"outDir": "./dist", /* Specify an output folder for all emitted files. */

Loading solution


00:00 So the start of the solution is to go into the tsconfig.json and look inside here and try to find the outdir. Outdir, out directory, specifying output folder for all emitted files. This is a really, really useful setting because it means you just get to organize

00:18 all of your emitted code into one place. And we can also see that whenever we change the tsconfig.json here, if I close the right directory, then this will basically tell the TypeScript compiler, tell the TypeScript CLI, what to do. So when I run tscwatch inside here,

00:37 it's going to first of all create a disk directory. And then we have now an example.js in there. So if I look at my example.ts and then open my example.js in another file here, so we've got this one on the left, this one on the right. Let me pull this apart for you.

00:54 We can see that when I change to hello, Matt, for instance, then it's going to change on the right-hand side too. So this means you just get to be a bit more organized. And it also shows how the tsconfig.json influences the way that TypeScript works inside that directory.