- Learn React with TypeScript 3
- Carl Rippon
- 141字
- 2021-06-10 19:16:38
--watch
This option makes the TypeScript compiler run indefinitely. Whenever a source file is changed, the compiling process is triggered automatically to generate the new version. This is a useful option to switch on during our developments:
- Let's give this a try by entering the following in a terminal:
tsc orderDetail --watch
- The compiler should run and, when completed, give the message Watching for file changes. Let's change the getTotal method in the OrderDetail class to handle situations when discount is undefined:
getTotal(discount: number): number {
const priceWithoutDiscount = this.product.unitPrice * this.quantity;
const discountAmount = priceWithoutDiscount * (discount || 0);
return priceWithoutDiscount - discountAmount;
}
- When we save orderDetail.ts, the compiler will say File change detected. Starting incremental compilation... and carry out the compilation.
To exit the watch mode, we can kill the terminal by clicking the bin icon in the Terminal.
推薦閱讀
- Learning Single:page Web Application Development
- What's New in TensorFlow 2.0
- Oracle Database 12c Security Cookbook
- Web Development with MongoDB and Node(Third Edition)
- 機器學習與R語言實戰
- Deep Learning with R Cookbook
- Troubleshooting Citrix XenApp?
- Python Digital Forensics Cookbook
- Python編程基礎與數據分析
- Microsoft Azure Security
- 深度剖析ApacheDubbo核心技術內幕
- Python算法交易實戰
- 數據結構:C語言描述(融媒體版)
- NIO與Socket編程技術指南
- Python樹莓派編程