This lesson has been retired.

Video Processing Status: completed

No video source files were found yet. Check back in an hour. If there's still a problem let us know.

Become a member
to unlock all features

    Configuring TypeScript Which Files to Compile with "Files" and "OutDir"

    John LindquistJohn Lindquist

    This lesson shows how to configure the .tsconfig so you only compile the .ts files you want. It then shows how to configure which directory you'd like to compile the files to using "outDir".



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson


    00:00 A common scenario for many applications and libraries is to have something like a main entry file where we'll call this app. You basically start your app here and import everything into this TS file. For your tsconfig, what you do, instead of excluding all the node modules, you'd tell it explicitly what you want to include in files.

    00:23 Let's say I want to include main.ts. I'm also going to come in here and say I want to output the files into an OutDir of dist. Now, when I run tsc, it will take the main.ts, compile everything down into main.js.

    00:43 If I were to create a new file and call it 2.ts, and we'll say class 2, and run tsc again, you'll see that this 2 class did not get compiled and included in my dist. If I want to include it, all I'd have to do is import 2.

    01:07 Now, when I compile, because I told my main.ts to import this 2.ts, now 2.ts got compiled. My main required or used whatever module definition is defined in your module settings here.