- Learn React with TypeScript 3
- Carl Rippon
- 162字
- 2021-06-10 19:16:37
--target
This determines the ECMAScript version the transpiled code will be generated in.
The default is ES3, which will ensure the code works in a wide range of browsers and their different versions. However, this compilation target will generate the most amount of code because the compiler will generate polyfill code for features that aren't supported in ES3.
The ESNext option is the other extreme, which compiles to the latest supported proposed ES features. This will generate the least amount of code, but will only work on browsers that have implemented the features we have used.
As an example, let's compile orderDetail.ts targeting ES6 browsers. Enter the following in the terminal:
tsc orderDetail --target es6
Our transpiled JavaScript will be very different from the last compilation and much closer to our source TypeScript because classes are supported in es6:
export class OrderDetail {
getTotal(discount) {
const priceWithoutDiscount = this.product.unitPrice * this.quantity;
const discountAmount = priceWithoutDiscount * discount;
return priceWithoutDiscount - discountAmount;
}
}
- Java Web開發學習手冊
- Java技術手冊(原書第7版)
- Java編程指南:基礎知識、類庫應用及案例設計
- Instant QlikView 11 Application Development
- Kotlin Standard Library Cookbook
- PhpStorm Cookbook
- ADI DSP應用技術集錦
- SQL Server 2016數據庫應用與開發
- 全棧自動化測試實戰:基于TestNG、HttpClient、Selenium和Appium
- Go語言編程
- 軟件測試分析與實踐
- 征服C指針(第2版)
- 深入淺出 HTTPS:從原理到實戰
- Android應用程序設計
- Microsoft XNA 4.0 Game Development Cookbook