- 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;
}
}
- SoapUI Cookbook
- Microsoft Application Virtualization Cookbook
- PHP基礎案例教程
- 算法訓練營:入門篇(全彩版)
- HTML5+CSS3網頁設計
- AIRIOT物聯網平臺開發框架應用與實戰
- Learning Concurrency in Kotlin
- C語言開發基礎教程(Dev-C++)(第2版)
- PHP+Ajax+jQuery網站開發項目式教程
- App Inventor創意趣味編程進階
- Struts 2.x權威指南
- 深入解析Java編譯器:源碼剖析與實例詳解
- Drupal 8 Development Cookbook(Second Edition)
- After Effects CC案例設計與經典插件(視頻教學版)
- JavaScript Mobile Application Development