⚠️ This lesson is retired and might contain outdated information.

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

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 8 years ago
Updated 5 years ago

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".

[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.

egghead
egghead
~ a minute ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today