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

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

主站蜘蛛池模板: 迭部县| 祥云县| 安西县| 炎陵县| 淅川县| 峨眉山市| 天镇县| 五华县| 石渠县| 张家川| 呼玛县| 财经| 北京市| 安龙县| 甘洛县| 江达县| 南通市| 镇远县| 嘉黎县| 谢通门县| 新龙县| 康保县| 西充县| 尼玛县| 疏勒县| 隆回县| 富蕴县| 唐河县| 岗巴县| 兴隆县| 乐安县| 新竹市| 虎林市| 青神县| 万山特区| 莫力| 肥乡县| 陵川县| 周宁县| 荣成市| 卓尼县|