在TypeScript中,`lib.es6.d.ts`和`lib.es2015.d.ts`之间的区别是什么?

时间:2018-03-15 01:51:51

标签: typescript ecmascript-6

根据我的理解,ES6和ES2015是一回事。但是在打字稿中,这两件事有2种类型声明:lib.es6.d.tslib.es2015.d.ts。有什么区别?我应该使用哪一个?

1 个答案:

答案 0 :(得分:3)

ES6和ES2015是同义词。 TypeScript using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class ExportGridView : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GridView1.DataSource = BindData(); GridView1.DataBind(); } } private string ConnectionString { get { return @"Server=localhost;Database=Northwind; Trusted_Connection=true"; } } private DataSet BindData() { // make the query string query = "SELECT * FROM Categories"; SqlConnection myConnection = new SqlConnection(ConnectionString); SqlDataAdapter ad = new SqlDataAdapter(query, myConnection); DataSet ds = new DataSet(); ad.Fill(ds, "Categories"); return ds; } protected void Button1_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition", "attachment; filename=FileName.xls"); Response.Charset = ""; // If you want the option to open the Excel file without saving than // comment out the line below // Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); GridView1.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); } public override void VerifyRenderingInServerForm(Control control) { // Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time. } //resource : https://www.daniweb.com/programming/web-development/threads/360606/how-to-export-data-from-gridview-to-excel-in-asp-net } target具有相同的名称,在TypeScript中的行为类似 - 而且它们都是。

liblib.d.ts是累积库文件。它们是generated from other libraries

  

此目录中的文件用于生成lib.d.ts和lib.es6.d.ts。

它们包括各自的规范库以及lib.es6.d.ts

DOMlib.es6.d.ts之间的区别在于,前者包含在默认情况下,lib.es2015.d.ts设置为target时未指定ES6,而后者与lib设置为lib一起使用。即ES6--target ES6相同。

--target ES6 --lib ES6,DOM,DOM.Iterable,Scripthost库是细粒度的,因此在必要时ES2015ES6可以替换为a subset of featuresES2015等。