TypeScript札记:初体验
1、简介
TypeScript 是一种由微软开发的自由和开源的编程语言。它是JavaScript的一个超集,而且本质上向这个语言添加了可选的静态类型和基于类的面向对象编程。
TypeScript是一种Compile-to-JavaScript的语言
TypeScript扩展了JavaScript的句法,所以现有的JavaScript程序可以不加修改,直接在TypeScript下工作。同时,TypeScript编译产生JavaScript以确保兼容性。
2、特点&优势
2.1、兼容现有JS代码
2.2、类型系统,面向对象设计,保证程序的健壮性(编译检查)
2.3、良好的语法,良好的工具支持
2.4、良好的社区支持
3、快速开始
3.1、 工具
如果是VS开发,安装 TypeScript 1.4 for Visual Studio 2013,版本随时变化,建议下载最新版本。
如果是NPM用户,那么直接 npm install -g typescript
3.2、 Hello Jay
使用VS的用户,直接新建项(TypeScript File即可);使用其他IDE的用户,如果IDE支持TypeScript,那么直接新建TypeScript;其他则新建文本文件,后缀名为ts。如果是不能在IDE中编译,那么可以直接通过npm安装typescript之后,使用tsc fileName.ts,进行编译。
打开1.ts文件,输入:
function hello(name: string){
  return 'Hello,' + name;
}
var res = hello('Jay');
console.log(res);
执行tsc 1.ts之后,生成一个1.js文件(具有可读性的标准js文件):
function hello(name) {
    return 'Hello,' + name;
}
var res = hello('Jay');
console.log(res);
4、参考资料
1、 官网:http://www.typescriptlang.org/
2、 入门指南: https://github.com/vilic/typescript-guide
*:first-child {
  margin-top: 0 !important;
}
body>*:last-child {
  margin-bottom: 0 !important;
}
/* BLOCKS
=============================================================================*/
p, blockquote, ul, ol, dl, table, pre {
  margin: 15px 0;
}
/* HEADERS
=============================================================================*/
h1, h2, h3, h4, h5, h6 {
  margin: 20px 0 10px;
  padding: 0;
  font-weight: bold;
  -webkit-font-smoothing: antialiased;
}
h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
  font-size: inherit;
}
h1 {
  font-size: 28px;
  color: #000;
}
h2 {
  font-size: 24px;
  border-bottom: 1px solid #ccc;
  color: #000;
}
h3 {
  font-size: 18px;
}
h4 {
  font-size: 16px;
}
h5 {
  font-size: 14px;
}
h6 {
  color: #777;
  font-size: 14px;
}
body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
  margin-top: 0;
  padding-top: 0;
}
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
  margin-top: 0;
  padding-top: 0;
}
h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
  margin-top: 10px;
}
/* LINKS
=============================================================================*/
a {
  color: #4183C4;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
/* LISTS
=============================================================================*/
ul, ol {
  padding-left: 30px;
}
ul li > :first-child,
ol li > :first-child,
ul li ul:first-of-type,
ol li ol:first-of-type,
ul li ol:first-of-type,
ol li ul:first-of-type {
  margin-top: 0px;
}
ul ul, ul ol, ol ol, ol ul {
  margin-bottom: 0;
}
dl {
  padding: 0;
}
dl dt {
  font-size: 14px;
  font-weight: bold;
  font-style: italic;
  padding: 0;
  margin: 15px 0 5px;
}
dl dt:first-child {
  padding: 0;
}
dl dt>:first-child {
  margin-top: 0px;
}
dl dt>:last-child {
  margin-bottom: 0px;
}
dl dd {
  margin: 0 0 15px;
  padding: 0 15px;
}
dl dd>:first-child {
  margin-top: 0px;
}
dl dd>:last-child {
  margin-bottom: 0px;
}
/* CODE
=============================================================================*/
pre, code, tt {
  font-size: 12px;
  font-family: Consolas, "Liberation Mono", Courier, monospace;
}
code, tt {
  margin: 0 0px;
  padding: 0px 0px;
  white-space: nowrap;
  border: 1px solid #eaeaea;
  background-color: #f8f8f8;
  border-radius: 3px;
}
pre>code {
  margin: 0;
  padding: 0;
  white-space: pre;
  border: none;
  background: transparent;
}
pre {
  background-color: #f8f8f8;
  border: 1px solid #ccc;
  font-size: 13px;
  line-height: 19px;
  overflow: auto;
  padding: 6px 10px;
  border-radius: 3px;
}
pre code, pre tt {
  background-color: transparent;
  border: none;
}
kbd {
    -moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    background-color: #DDDDDD;
    background-image: linear-gradient(#F1F1F1, #DDDDDD);
    background-repeat: repeat-x;
    border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD;
    border-image: none;
    border-radius: 2px 2px 2px 2px;
    border-style: solid;
    border-width: 1px;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    line-height: 10px;
    padding: 1px 4px;
}
/* QUOTES
=============================================================================*/
blockquote {
  border-left: 4px solid #DDD;
  padding: 0 15px;
  color: #777;
}
blockquote>:first-child {
  margin-top: 0px;
}
blockquote>:last-child {
  margin-bottom: 0px;
}
/* HORIZONTAL RULES
=============================================================================*/
hr {
  clear: both;
  margin: 15px 0;
  height: 0px;
  overflow: hidden;
  border: none;
  background: transparent;
  border-bottom: 4px solid #ddd;
  padding: 0;
}
/* IMAGES
=============================================================================*/
img {
  max-width: 100%
}
-->
TypeScript札记:初体验的更多相关文章
- TypeScript+Vue初体验Demo
		
github: https://github.com/lanleilin/Typescript-Vue-Demo
 - .NET平台开源项目速览(15)文档数据库RavenDB-介绍与初体验
		
不知不觉,“.NET平台开源项目速览“系列文章已经15篇了,每一篇都非常受欢迎,可能技术水平不高,但足够入门了.虽然工作很忙,但还是会抽空把自己知道的,已经平时遇到的好的开源项目分享出来.今天就给大家 ...
 - Xamarin+Prism开发详解四:简单Mac OS 虚拟机安装方法与Visual Studio for Mac 初体验
		
Mac OS 虚拟机安装方法 最近把自己的电脑升级了一下SSD固态硬盘,总算是有容量安装Mac 虚拟机了!经过心碎的安装探索,尝试了国内外的各种安装方法,最后在youtube上找到了一个好方法. 简单 ...
 - Spring之初体验
		
Spring之初体验 Spring是一个轻量级的Java Web开发框架,以IoC(Inverse of Control 控制反转)和 ...
 - Xamarin.iOS开发初体验
		
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKwAAAA+CAIAAAA5/WfHAAAJrklEQVR4nO2c/VdTRxrH+wfdU84pW0
 - 【腾讯Bugly干货分享】基于 Webpack & Vue & Vue-Router 的 SPA 初体验
		
本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/57d13a57132ff21c38110186 导语 最近这几年的前端圈子,由于 ...
 - 【Knockout.js 学习体验之旅】(1)ko初体验
		
前言 什么,你现在还在看knockout.js?这货都已经落后主流一千年了!赶紧去学Angular.React啊,再不赶紧的话,他们也要变out了哦.身旁的90后小伙伴,嘴里还塞着山东的狗不理大蒜包, ...
 - 在同一个硬盘上安装多个 Linux 发行版及 Fedora 21 、Fedora 22 初体验
		
在同一个硬盘上安装多个 Linux 发行版 以前对多个 Linux 发行版的折腾主要是在虚拟机上完成.我的桌面电脑性能比较强大,玩玩虚拟机没啥问题,但是笔记本电脑就不行了.要在我的笔记本电脑上折腾多个 ...
 - 百度EChart3初体验
		
由于项目需要在首页搞一个订单数量的走势图,经过多方查找,体验,感觉ECharts不错,封装的很细,我们只需要看自己需要那种类型的图表,搞定好自己的json数据就OK.至于说如何体现出来,官网的教程很详 ...
 - Python导出Excel为Lua/Json/Xml实例教程(二):xlrd初体验
		
Python导出Excel为Lua/Json/Xml实例教程(二):xlrd初体验 相关链接: Python导出Excel为Lua/Json/Xml实例教程(一):初识Python Python导出E ...
 
随机推荐
- 解决用navicate远程连接数据库出现1045 access denied for user 'root'@'localhost' using password yes
			
在mysql命令行中执行 SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456'); GRANT ALL PRIVILEGES ON *.* ...
 - Git版本工具的使用
			
Git版本工具:Git是一个开源的分布式版本控制系统,可用于敏捷高效的处理任何或大或小的项目.详细介绍地址:https://git-scm.com/downloads.今天主要为大家分享一下怎样把本地 ...
 - php对csv文件的读取,写入,输出下载操作
			
在实际工作中,很多时候需要把网站上的一些数据下载到CSV文件里,方便以后查看. 亦或者是用CSV进行一些批量的上传工作. 这个时候我们就需要对CSV进行读写操作. 1.CSV的读取操作 <?ph ...
 - 深入学习golang(4)—new与make
			
Go语言中的内建函数new和make是两个用于内存分配的原语(allocation primitives).对于初学者,这两者的区别也挺容易让人迷糊的.简单的说,new只分配内存,make用于slic ...
 - 如何通过Socket TCP发送并接收一个文件?
			
一.小结 1.大包发小包收,只发一次. 2.发时把文件扩展名,文件长度也随同一起发送,方便接收端接收时另存为正确的文件类型,并判断是否已经接收完毕. 如果不一起发送,分为文件扩展名,文件长度,文件内容 ...
 - AWVS漏洞测试-02节-添加一个简单的新闻系统
			
实现一个简单的新闻发布系统 有登录 注册 添加新闻 浏览新闻 评论新闻 新闻列表 这些基本功能 使用asp.net webform 首先是登录页 protected void Button1_Clic ...
 - 【LeetCode】263. Ugly Number
			
Ugly Number Write a program to check whether a given number is an ugly number. Ugly numbers are posi ...
 - 【C#】剪切出图片的一部分
			
, , , ); Bitmap bmpNew = bmpBase.Clone(rect, bmpBase.PixelFormat); // 画像をGIF形式で保存 string ...
 - 关于Unity程序在IOS和Android上显示内嵌网页的方式
			
近期因为有须要在Unity程序执行在ios或android手机上显示内嵌网页.所以遍从网上搜集了一下相关的资料.整理例如以下: UnityWebCore 从搜索中先看到了这个.下载下来了以后发现这个的 ...
 - 项目管理知识体系指南(PMBOOK指南)(第5版) 阅读摘要
			
1.7.2 项目经理的人际技能 领导力: 团队建设: 激励: 沟通: 影响力: 决策能力: 政治和文化意识: 谈判: 建立信任: 冲突管理: 教练技术: 3.4 规划过程组 在制定项目管理计划和项目文 ...