- 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.
推薦閱讀
- SPSS數據挖掘與案例分析應用實踐
- VMware View Security Essentials
- Mastering Zabbix(Second Edition)
- C程序設計簡明教程(第二版)
- Android項目開發入門教程
- Groovy for Domain:specific Languages(Second Edition)
- Ext JS 4 Web Application Development Cookbook
- 微信小程序項目開發實戰
- 自然語言處理Python進階
- Extending Puppet(Second Edition)
- Haskell Data Analysis Cookbook
- RSpec Essentials
- Python項目實戰從入門到精通
- R數據科學實戰:工具詳解與案例分析
- Visual C++程序設計與項目實踐