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

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

主站蜘蛛池模板: 宜川县| 衡南县| 广德县| 白银市| 北流市| 大同县| 太白县| 天台县| 芦溪县| 探索| 泾川县| 南漳县| 玉环县| 沙田区| 普兰店市| 新乐市| 沐川县| 凯里市| 广南县| 新蔡县| 南川市| 平昌县| 塔河县| 铁力市| 新津县| 盘锦市| 元谋县| 九龙坡区| 富源县| 苍南县| 林芝县| 佛教| 安岳县| 通海县| 张家港市| 卓尼县| 拜城县| 左云县| 鹤庆县| 杨浦区| 天峨县|