- 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.
推薦閱讀
- Android Jetpack開發(fā):原理解析與應(yīng)用實(shí)戰(zhàn)
- TensorFlow Lite移動端深度學(xué)習(xí)
- 深度強(qiáng)化學(xué)習(xí)算法與實(shí)踐:基于PyTorch的實(shí)現(xiàn)
- The HTML and CSS Workshop
- Learning Python Design Patterns
- Julia高性能科學(xué)計(jì)算(第2版)
- 執(zhí)劍而舞:用代碼創(chuàng)作藝術(shù)
- PHP 7從零基礎(chǔ)到項(xiàng)目實(shí)戰(zhàn)
- BeagleBone Robotic Projects(Second Edition)
- Everyday Data Structures
- HTML5+CSS3+jQuery Mobile APP與移動網(wǎng)站設(shè)計(jì)從入門到精通
- Python Web自動化測試設(shè)計(jì)與實(shí)現(xiàn)
- 從零開始學(xué)UI:概念解析、實(shí)戰(zhàn)提高、突破規(guī)則
- After Effects CC案例設(shè)計(jì)與經(jīng)典插件(視頻教學(xué)版)
- Mastering Python