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

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

主站蜘蛛池模板: 扎囊县| 尼木县| 江陵县| 库伦旗| 年辖:市辖区| 衡阳市| 岳阳市| 舒兰市| 司法| 大宁县| 河曲县| 宜兰市| 浦北县| 乐山市| 醴陵市| 苍南县| 磐安县| 安福县| 宁海县| 库车县| 安顺市| 措勤县| 迁安市| 牟定县| 白玉县| 孟津县| 通河县| 屯门区| 黎川县| 怀仁县| 罗平县| 磴口县| 新蔡县| 田林县| 镇原县| 东丰县| 宁津县| 宜丰县| 彭泽县| 铅山县| 义马市|