- Learn React with TypeScript 3
- Carl Rippon
- 226字
- 2021-06-10 19:16:39
Specifying files for compilation
There are several ways to tell the TypeScript compiler which files to process. The simplest method is to explicitly list the files in the files field:
{
"compilerOptions": {
...
},
"files": ["product.ts", "orderDetail.ts"]
}
However, that approach is difficult to maintain as our code base grows. A more maintainable approach is to define file patterns for what to include and exclude with the include and exclude fields.
The following example looks at the use of these fields:
- Let's add the following include fields, which tell the compiler to compile TypeScript files found in the src folder and its subfolders:
{
"compilerOptions": {
...
},
"include": ["src/**/*"]
}
- At the moment, our source files aren't in a folder called src, but let's run a compile anyway:
tsc
- As expected, we get No inputs were found in the config file... from the compiler.
Let's create an src folder and move orderDetail.ts into this folder. If we do a compile again, it will successfully find the files and do a compilation.
So, we have lots of options for adapting the TypeScript compiler to our particular situation. Some options, such as --noImplicitAny, force us to write good TypeScript code. We can take the checks on our code to the next level by introducing linting into our project, which we'll look at in the next section.
- SPSS數據挖掘與案例分析應用實踐
- Implementing Modern DevOps
- 新一代通用視頻編碼H.266/VVC:原理、標準與實現
- Kinect for Windows SDK Programming Guide
- 計算機應用基礎實踐教程
- Microsoft Dynamics AX 2012 R3 Financial Management
- RESTful Java Web Services(Second Edition)
- 響應式架構:消息模式Actor實現與Scala、Akka應用集成
- OpenResty完全開發指南:構建百萬級別并發的Web應用
- 深入剖析Java虛擬機:源碼剖析與實例詳解(基礎卷)
- C語言程序設計實訓教程與水平考試指導
- Spring 5 Design Patterns
- SEO教程:搜索引擎優化入門與進階(第3版)
- C/C++程序設計教程
- 川哥教你Spring Boot 2實戰