1 00:00:02,260 --> 00:00:06,340 So this is now how we can manage multiple files with typescript. 2 00:00:06,340 --> 00:00:11,530 Now one word about having multiple files when you work with multiple files as we're doing it here. 3 00:00:11,560 --> 00:00:18,070 You can also import them into each other with modules which you might know from Manila javascript. 4 00:00:18,090 --> 00:00:20,020 Here we have modules as well. 5 00:00:20,080 --> 00:00:23,870 It is something I'll cover in a dedicated section of this course though. 6 00:00:23,890 --> 00:00:29,290 So for now we just have two files which are not imported into each other but which are instead imported 7 00:00:29,290 --> 00:00:31,030 into index h to. 8 00:00:31,090 --> 00:00:37,300 Now with that out of the way though we know that we can manage this as a project and then we can compile 9 00:00:37,360 --> 00:00:39,090 multiple files here. 10 00:00:39,100 --> 00:00:44,800 Now let's have a look at the T conflict Jason File because this is a crucial file for managing this 11 00:00:44,800 --> 00:00:45,720 project. 12 00:00:45,730 --> 00:00:51,340 It essentially tells typescript how it should compile these files. 13 00:00:51,340 --> 00:00:58,420 Now before we dive into the compiler options where we as the name suggests can configure how the compiler 14 00:00:58,420 --> 00:00:59,660 behaves. 15 00:00:59,680 --> 00:01:06,400 Let's scroll down to the place before the closing curly brace but after this nested closing curly brace 16 00:01:06,900 --> 00:01:12,880 and let's see some of the options we can add here which don't affect the compiler or the compilation 17 00:01:12,880 --> 00:01:20,440 step behavior but instead how the compiler works with this project because there for example you can 18 00:01:20,440 --> 00:01:23,690 set exclude option. 19 00:01:23,740 --> 00:01:30,670 Now if you add exclude here that will be an array and what you can't enter here are paths to files which 20 00:01:30,670 --> 00:01:36,430 should not be included in computation when you run TSC on the entire project. 21 00:01:36,430 --> 00:01:41,400 So for example here we could say we want to exclude analytics teams from compilation. 22 00:01:41,410 --> 00:01:43,410 Now of course this does make much sense here. 23 00:01:43,420 --> 00:01:51,540 But just to show how this works if we do that we now rerun TSC and first of all delete analytics Chase 24 00:01:51,640 --> 00:01:53,600 so that we can see if it is recreated. 25 00:01:53,800 --> 00:02:00,490 If we now run TSC or TSC in watch mode you see no analytics chairs follows created the reason for that 26 00:02:00,490 --> 00:02:02,090 is that we're excluding that file. 27 00:02:02,110 --> 00:02:07,020 Now of course for this file this doesn't make a lot of sense because I typically want to include it. 28 00:02:07,240 --> 00:02:12,460 But if you had a file that for some reason shouldn't be compiled you can't execute it like this. 29 00:02:12,490 --> 00:02:19,870 You can also work with wildcards and for example if you had a file that's named analytics dot def dot 30 00:02:19,890 --> 00:02:26,090 t s and you don't want to compile that you could say all files that end with Def not test should not 31 00:02:26,090 --> 00:02:31,970 be compiled and you can do that by also adding an asterisk here which is a wildcard basically and now 32 00:02:31,970 --> 00:02:36,230 types will ignore any files that have dot def or T S included. 33 00:02:36,530 --> 00:02:43,670 You could also add asterisks asterisk slash here and that would mean any file with that pattern in any 34 00:02:43,670 --> 00:02:45,820 folder will be ignored. 35 00:02:45,830 --> 00:02:47,470 So these are things you can set up here. 36 00:02:47,480 --> 00:02:51,440 The only thing I want to set up here and that is a setting you will often find. 37 00:02:51,590 --> 00:02:55,340 Instead I want to exclude node modules. 38 00:02:55,340 --> 00:03:02,340 And the idea here is that I don't want to compile any typescript files I might have inside of node modules. 39 00:03:02,360 --> 00:03:09,450 Now node modules is that folder that holds all the dependencies we install here in packets Jason. 40 00:03:09,620 --> 00:03:15,380 And the dependencies of these dependencies and therefore these are third party libraries we're importing 41 00:03:15,380 --> 00:03:16,720 which we don't want to touch. 42 00:03:16,850 --> 00:03:22,520 And if any of these libraries should ship some typescript code then we certainly don't want to compile 43 00:03:22,520 --> 00:03:22,690 it. 44 00:03:22,730 --> 00:03:29,140 It will just slow down our accumulation process and in the worst case it might even break our project. 45 00:03:29,240 --> 00:03:34,940 So therefore it's quite common to exclude node modules here though I will say if you don't specify the 46 00:03:34,940 --> 00:03:41,300 execute option at all node modules is automatically excluded as a default setting. 47 00:03:41,480 --> 00:03:43,990 So you don't really need to add this option here. 48 00:03:44,000 --> 00:03:47,140 This would be the default. 49 00:03:47,140 --> 00:03:52,110 I just want to show that excluding exists and how you could use it if the only thing you want excellent 50 00:03:52,140 --> 00:03:55,740 is node modules you don't have to add the exclude key at all. 51 00:03:55,750 --> 00:04:01,240 If you do add it though you should set node modules because otherwise it will not exclude that. 52 00:04:01,440 --> 00:04:02,550 Now besides exclude. 53 00:04:02,560 --> 00:04:06,660 We also have include and include allows it to do the opposite. 54 00:04:06,670 --> 00:04:12,580 It allows you to specifically tell typescript which files you want to include in the compilation process 55 00:04:12,920 --> 00:04:16,150 and anything that's not listed here will not be compiled. 56 00:04:16,410 --> 00:04:24,350 So if a point at apt yes here you'll see if I rerun TSC we all will get no analytics t file or no analytics 57 00:04:24,360 --> 00:04:25,600 J as file I should say. 58 00:04:25,600 --> 00:04:26,260 Why. 59 00:04:26,320 --> 00:04:33,250 Because analytics J is not included in include and as I said if we do set to include key then we really 60 00:04:33,250 --> 00:04:35,810 have to include everything we want to compile. 61 00:04:35,850 --> 00:04:42,280 So of course here we could then also add analytics tests here and with that addition we would start 62 00:04:42,310 --> 00:04:48,880 and compile it as we see now we have the analytics chairs file or as an alternative we specify a whole 63 00:04:48,880 --> 00:04:55,300 folder here which typically holds the files we want to compile exclude by the way if set alongside include 64 00:04:55,570 --> 00:04:57,190 will filter down include. 65 00:04:57,190 --> 00:05:03,610 So if we exclude some sub folder of a folder with that as part of include then that excluded sub folder 66 00:05:03,610 --> 00:05:05,010 will be excluded. 67 00:05:05,020 --> 00:05:08,410 So basically we compile include minus exclude. 68 00:05:08,740 --> 00:05:13,810 Now of course here I don't want to set include I want to compile all types of files and therefore I 69 00:05:13,810 --> 00:05:18,970 don't have to worry about that excluding node modules is all I need and as I explained theoretically 70 00:05:18,970 --> 00:05:23,290 I don't even need to add that because that would be excluded by default. 71 00:05:23,290 --> 00:05:25,240 Now we also have a files option. 72 00:05:25,330 --> 00:05:30,280 This allows you to point at the individual files so it's a bit like include with the difference that 73 00:05:30,280 --> 00:05:34,570 here you can specify whole folders what you want to include instead. 74 00:05:34,660 --> 00:05:38,230 You really just specify the individual files you want to compile. 75 00:05:38,230 --> 00:05:44,320 That might be option for smaller projects where you know you will only work with free files and for 76 00:05:44,320 --> 00:05:48,610 some reason you've got a couple of other types good files which you don't want to touch though. 77 00:05:48,610 --> 00:05:51,330 Then you can set the list of files like this. 78 00:05:51,400 --> 00:05:58,570 In reality you might not need that setting that often though and therefore dates it with the basic compilation 79 00:05:58,570 --> 00:06:00,930 or project management options here. 80 00:06:00,940 --> 00:06:07,900 Now of course there is way more we can specify though way more we can specify about the compiler itself 81 00:06:08,290 --> 00:06:10,690 and how it behaves during the computation step.