官术网_书友最值得收藏!

--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:

  1. Let's give this a try by entering the following in a terminal:
tsc orderDetail --watch
  1. 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;
}
  1. 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.

主站蜘蛛池模板: 客服| 博湖县| 苍梧县| 梨树县| 阿克苏市| 潮州市| 天津市| 凯里市| 柳林县| 长寿区| 南安市| 萨嘎县| 寿阳县| 黎平县| 镇赉县| 辰溪县| 日土县| 赤城县| 嫩江县| 沾益县| 保定市| 四子王旗| 新乐市| 北宁市| 本溪市| 北京市| 昌都县| 林州市| 夏津县| 凤阳县| 抚远县| 沙河市| 龙里县| 肥西县| 沧州市| 张家界市| 兴山县| 睢宁县| 宝清县| 马边| 宜宾县|