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

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

主站蜘蛛池模板: 灵石县| 青海省| 雅江县| 南涧| 体育| 定日县| 始兴县| 九寨沟县| 民勤县| 盐津县| 郧西县| 邵武市| 屏东县| 澎湖县| 成都市| 东平县| 台南市| 孟津县| 文水县| 宁南县| 永康市| 德江县| 西城区| 阜宁县| 仁布县| 东乌| 文水县| 嵊泗县| 东辽县| 阿城市| 丰都县| 盐池县| 定兴县| 吴堡县| 扎鲁特旗| 建湖县| 越西县| 精河县| 盐山县| 泾川县| 双流县|