parent
bd08131dfb
commit
683ebb81a5
79
README.md
79
README.md
@ -9,43 +9,50 @@ TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
|
||||
|
||||
## 目录
|
||||
|
||||
* [基础类型](./doc/handbook/Basic Types.md)
|
||||
* [枚举](./doc/handbook/Enums.md)
|
||||
* [变量声明](./doc/handbook/Variable Declarations.md)
|
||||
* [接口](./doc/handbook/Interfaces.md)
|
||||
* [高级类型](./doc/handbook/Advanced Types.md)
|
||||
* [类](./doc/handbook/Classes.md)
|
||||
* [命名空间和模块](./doc/handbook/Namespaces and Modules.md)
|
||||
* [命名空间](./doc/handbook/Namespaces.md)
|
||||
* [模块](./doc/handbook/Modules.md)
|
||||
* [模块解析](./doc/handbook/Module Resolution.md)
|
||||
* [函数](./doc/handbook/Functions.md)
|
||||
* [泛型](./doc/handbook/Generics.md)
|
||||
* [混入](./doc/handbook/Mixins.md)
|
||||
* [声明合并](./doc/handbook/Declaration Merging.md)
|
||||
* [类型推论](./doc/handbook/Type Inference.md)
|
||||
* [类型兼容性](./doc/handbook/Type Compatibility.md)
|
||||
* [书写.d.ts文件](./doc/handbook/Writing Definition Files.md)
|
||||
* [Iterators 和 Generators](./doc/handbook/Iterators and Generators.md)
|
||||
* [Symbols](./doc/handbook/Symbols.md)
|
||||
* [Decorators](./doc/handbook/Decorators.md)
|
||||
* [JSX](./doc/handbook/JSX.md)
|
||||
* [tsconfig.json](./doc/handbook/tsconfig.json.md)
|
||||
* [编译选项](./doc/handbook/Compiler Options.md)
|
||||
* [在MSBuild里使用编译选项](./doc/handbook/Compiler Options in MSBuild.md)
|
||||
* [与其它构建工具整合](./doc/handbook/Integrating with Build Tools.md)
|
||||
* [NPM包的类型](./doc/handbook/Typings for NPM Packages.md)
|
||||
* Wiki
|
||||
* [TypeScript里的this](./doc/handbook/this-in-TypeScript.md)
|
||||
* [编码规范](./doc/handbook/coding_guidelines.md)
|
||||
* [常见编译错误](./doc/handbook/Common Errors.md)
|
||||
* [支持TypeScript的编辑器](./doc/handbook/TypeScript-Editor-Support.md)
|
||||
* [结合ASP.NET v5使用TypeScript](./doc/handbook/Using-TypeScript-With-ASP.NET-5.md)
|
||||
* [架构概述](./doc/handbook/Architectural-Overview.md)
|
||||
* [发展路线图](./doc/handbook/Roadmap.md)
|
||||
* 快速上手
|
||||
* [快速上手](./doc/handbook/quick-start/README.md)
|
||||
* [React和webpack](./doc/handbook/quick-start/react-webpack.md)
|
||||
* [ASP.NET](./doc/handbook/quick-start/asp-net.md)
|
||||
* [ASP.NET 4](./doc/handbook/quick-start/asp-net.md)
|
||||
* [新增功能](./doc/release-notes/README.md)
|
||||
* [TypeScript 1.1](./doc/release-notes/TypeScript 1.1.md)
|
||||
* [TypeScript 1.1](./doc/release-notes/TypeScript 1.3.md)
|
||||
* [TypeScript 1.1](./doc/release-notes/TypeScript 1.4.md)
|
||||
* [手册](./doc/handbook/Basic Types.md)
|
||||
* [基础类型](./doc/handbook/Basic Types.md)
|
||||
* [枚举](./doc/handbook/Enums.md)
|
||||
* [变量声明](./doc/handbook/Variable Declarations.md)
|
||||
* [接口](./doc/handbook/Interfaces.md)
|
||||
* [高级类型](./doc/handbook/Advanced Types.md)
|
||||
* [类](./doc/handbook/Classes.md)
|
||||
* [命名空间和模块](./doc/handbook/Namespaces and Modules.md)
|
||||
* [命名空间](./doc/handbook/Namespaces.md)
|
||||
* [模块](./doc/handbook/Modules.md)
|
||||
* [模块解析](./doc/handbook/Module Resolution.md)
|
||||
* [函数](./doc/handbook/Functions.md)
|
||||
* [泛型](./doc/handbook/Generics.md)
|
||||
* [混入](./doc/handbook/Mixins.md)
|
||||
* [声明合并](./doc/handbook/Declaration Merging.md)
|
||||
* [类型推论](./doc/handbook/Type Inference.md)
|
||||
* [类型兼容性](./doc/handbook/Type Compatibility.md)
|
||||
* [书写.d.ts文件](./doc/handbook/Writing Definition Files.md)
|
||||
* [Iterators 和 Generators](./doc/handbook/Iterators and Generators.md)
|
||||
* [Symbols](./doc/handbook/Symbols.md)
|
||||
* [Decorators](./doc/handbook/Decorators.md)
|
||||
* [JSX](./doc/handbook/JSX.md)
|
||||
* [工程配置](./doc/handbook/tsconfig.json.md)
|
||||
* [tsconfig.json](./doc/handbook/tsconfig.json.md)
|
||||
* [NPM包的类型](./doc/handbook/Typings for NPM Packages.md)
|
||||
* [编译选项](./doc/handbook/Compiler Options.md)
|
||||
* [在MSBuild里使用编译选项](./doc/handbook/Compiler Options in MSBuild.md)
|
||||
* [与其它构建工具整合](./doc/handbook/Integrating with Build Tools.md)
|
||||
* [Wiki](./doc/wiki/README.md)
|
||||
* [TypeScript里的this](./doc/wiki/this-in-TypeScript.md)
|
||||
* [编码规范](./doc/wiki/coding_guidelines.md)
|
||||
* [常见编译错误](./doc/wiki/Common Errors.md)
|
||||
* [支持TypeScript的编辑器](./doc/wiki/TypeScript-Editor-Support.md)
|
||||
* [结合ASP.NET v5使用TypeScript](./doc/wiki/Using-TypeScript-With-ASP.NET-5.md)
|
||||
* [架构概述](./doc/wiki/Architectural-Overview.md)
|
||||
* [发展路线图](./doc/wiki/Roadmap.md)
|
||||
|
||||
|
||||
**TypeScript Handbook**
|
||||
|
||||
|
77
SUMMARY.md
77
SUMMARY.md
@ -1,38 +1,45 @@
|
||||
# Summary
|
||||
|
||||
* [基础类型](./doc/handbook/Basic Types.md)
|
||||
* [枚举](./doc/handbook/Enums.md)
|
||||
* [变量声明](./doc/handbook/Variable Declarations.md)
|
||||
* [接口](./doc/handbook/Interfaces.md)
|
||||
* [高级类型](./doc/handbook/Advanced Types.md)
|
||||
* [类](./doc/handbook/Classes.md)
|
||||
* [命名空间和模块](./doc/handbook/Namespaces and Modules.md)
|
||||
* [命名空间](./doc/handbook/Namespaces.md)
|
||||
* [模块](./doc/handbook/Modules.md)
|
||||
* [模块解析](./doc/handbook/Module Resolution.md)
|
||||
* [函数](./doc/handbook/Functions.md)
|
||||
* [泛型](./doc/handbook/Generics.md)
|
||||
* [混入](./doc/handbook/Mixins.md)
|
||||
* [声明合并](./doc/handbook/Declaration Merging.md)
|
||||
* [类型推论](./doc/handbook/Type Inference.md)
|
||||
* [类型兼容性](./doc/handbook/Type Compatibility.md)
|
||||
* [书写.d.ts文件](./doc/handbook/Writing Definition Files.md)
|
||||
* [Iterators 和 Generators](./doc/handbook/Iterators and Generators.md)
|
||||
* [Symbols](./doc/handbook/Symbols.md)
|
||||
* [Decorators](./doc/handbook/Decorators.md)
|
||||
* [JSX](./doc/handbook/JSX.md)
|
||||
* [tsconfig.json](./doc/handbook/tsconfig.json.md)
|
||||
* [编译选项](./doc/handbook/Compiler Options.md)
|
||||
* [在MSBuild里使用编译选项](./doc/handbook/Compiler Options in MSBuild.md)
|
||||
* [与其它构建工具整合](./doc/handbook/Integrating with Build Tools.md)
|
||||
* [NPM包的类型](./doc/handbook/Typings for NPM Packages.md)
|
||||
* Wiki
|
||||
* [TypeScript里的this](./doc/handbook/this-in-TypeScript.md)
|
||||
* [编码规范](./doc/handbook/coding_guidelines.md)
|
||||
* [常见编译错误](./doc/handbook/Common Errors.md)
|
||||
* [支持TypeScript的编辑器](./doc/handbook/TypeScript-Editor-Support.md)
|
||||
* [结合ASP.NET v5使用TypeScript](./doc/handbook/Using-TypeScript-With-ASP.NET-5.md)
|
||||
* [架构概述](./doc/handbook/Architectural-Overview.md)
|
||||
* [发展路线图](./doc/handbook/Roadmap.md)
|
||||
* 快速上手
|
||||
* [快速上手](./doc/handbook/quick-start/README.md)
|
||||
* [React和webpack](./doc/handbook/quick-start/react-webpack.md)
|
||||
* [ASP.NET 4](./doc/handbook/quick-start/asp-net.md)
|
||||
* [新增功能](./doc/release-notes/README.md)
|
||||
* [TypeScript 1.1](./doc/release-notes/TypeScript 1.1.md)
|
||||
* [TypeScript 1.1](./doc/release-notes/TypeScript 1.3.md)
|
||||
* [TypeScript 1.1](./doc/release-notes/TypeScript 1.4.md)
|
||||
* [手册](./doc/handbook/Basic Types.md)
|
||||
* [基础类型](./doc/handbook/Basic Types.md)
|
||||
* [枚举](./doc/handbook/Enums.md)
|
||||
* [变量声明](./doc/handbook/Variable Declarations.md)
|
||||
* [接口](./doc/handbook/Interfaces.md)
|
||||
* [高级类型](./doc/handbook/Advanced Types.md)
|
||||
* [类](./doc/handbook/Classes.md)
|
||||
* [命名空间和模块](./doc/handbook/Namespaces and Modules.md)
|
||||
* [命名空间](./doc/handbook/Namespaces.md)
|
||||
* [模块](./doc/handbook/Modules.md)
|
||||
* [模块解析](./doc/handbook/Module Resolution.md)
|
||||
* [函数](./doc/handbook/Functions.md)
|
||||
* [泛型](./doc/handbook/Generics.md)
|
||||
* [混入](./doc/handbook/Mixins.md)
|
||||
* [声明合并](./doc/handbook/Declaration Merging.md)
|
||||
* [类型推论](./doc/handbook/Type Inference.md)
|
||||
* [类型兼容性](./doc/handbook/Type Compatibility.md)
|
||||
* [书写.d.ts文件](./doc/handbook/Writing Definition Files.md)
|
||||
* [Iterators 和 Generators](./doc/handbook/Iterators and Generators.md)
|
||||
* [Symbols](./doc/handbook/Symbols.md)
|
||||
* [Decorators](./doc/handbook/Decorators.md)
|
||||
* [JSX](./doc/handbook/JSX.md)
|
||||
* [工程配置](./doc/handbook/tsconfig.json.md)
|
||||
* [tsconfig.json](./doc/handbook/tsconfig.json.md)
|
||||
* [NPM包的类型](./doc/handbook/Typings for NPM Packages.md)
|
||||
* [编译选项](./doc/handbook/Compiler Options.md)
|
||||
* [在MSBuild里使用编译选项](./doc/handbook/Compiler Options in MSBuild.md)
|
||||
* [与其它构建工具整合](./doc/handbook/Integrating with Build Tools.md)
|
||||
* [wiki](./doc/wiki/README.md)
|
||||
* [TypeScript里的this](./doc/wiki/this-in-TypeScript.md)
|
||||
* [编码规范](./doc/wiki/coding_guidelines.md)
|
||||
* [常见编译错误](./doc/wiki/Common Errors.md)
|
||||
* [支持TypeScript的编辑器](./doc/wiki/TypeScript-Editor-Support.md)
|
||||
* [结合ASP.NET v5使用TypeScript](./doc/wiki/Using-TypeScript-With-ASP.NET-5.md)
|
||||
* [架构概述](./doc/wiki/Architectural-Overview.md)
|
||||
* [发展路线图](./doc/wiki/Roadmap.md)
|
||||
|
23
doc/release-notes/TypeScript 1.1.md
Normal file
23
doc/release-notes/TypeScript 1.1.md
Normal file
@ -0,0 +1,23 @@
|
||||
# TypeScript 1.1
|
||||
|
||||
## 改进性能
|
||||
|
||||
1.1版本的编译器速度比所有之前发布的版本快4倍。阅读[这篇博客里的有关图表](http://blogs.msdn.com/b/typescript/archive/2014/10/06/announcing-typescript-1-1-ctp.aspx)
|
||||
|
||||
## 更好的模块可见性规则
|
||||
|
||||
TypeScript现在只在使用`--declaration`标记时才严格强制模块里类型的可见性。这在Angular里很有用,例如:
|
||||
|
||||
```ts
|
||||
module MyControllers {
|
||||
interface ZooScope extends ng.IScope {
|
||||
animals: Animal[];
|
||||
}
|
||||
export class ZooController {
|
||||
// Used to be an error (cannot expose ZooScope), but now is only
|
||||
// an error when trying to generate .d.ts files
|
||||
constructor(public $scope: ZooScope) { }
|
||||
/* more code */
|
||||
}
|
||||
}
|
||||
```
|
48
doc/release-notes/TypeScript 1.3.md
Normal file
48
doc/release-notes/TypeScript 1.3.md
Normal file
@ -0,0 +1,48 @@
|
||||
# TypeScript 1.3
|
||||
|
||||
## 受保护的
|
||||
|
||||
类里面新的`protected`修饰符作用与其它语言如C++,C#和Java中的一样。一个类的`protected`成员只在这个类的子类中可见:
|
||||
|
||||
```ts
|
||||
class Thing {
|
||||
protected doSomething() { /* ... */ }
|
||||
}
|
||||
|
||||
class MyThing extends Thing {
|
||||
public myMethod() {
|
||||
// OK,可以在子类里访问受保护的成员
|
||||
this.doSomething();
|
||||
}
|
||||
}
|
||||
var t = new MyThing();
|
||||
t.doSomething(); // Error,不能在类外部访问受保护成员
|
||||
```
|
||||
|
||||
## 元组类型
|
||||
|
||||
元组类型表示一个数组,其中元素的类型都是已知的,但是不一样是同样的类型。比如,你可能想要表示一个第一个元素是`string`类型第二个元素是`number`类型的数组:
|
||||
|
||||
```ts
|
||||
// Declare a tuple type
|
||||
var x: [string, number];
|
||||
// 初始化
|
||||
x = ['hello', 10]; // OK
|
||||
// 错误的初始化
|
||||
x = [10, 'hello']; // Error
|
||||
```
|
||||
|
||||
但是访问一个已知的索引,会得到正确的类型:
|
||||
|
||||
```ts
|
||||
console.log(x[0].substr(1)); // OK
|
||||
console.log(x[1].substr(1)); // Error, 'number'没有'substr'方法
|
||||
```
|
||||
|
||||
注意在TypeScript1.4里,当访问超出已知索引的元素时,会返回联合类型:
|
||||
|
||||
```ts
|
||||
x[3] = 'world'; // OK
|
||||
console.log(x[5].toString()); // OK, 'string'和'number'都有toString
|
||||
x[6] = true; // Error, boolean不是number或string
|
||||
```
|
241
doc/release-notes/TypeScript 1.4.md
Normal file
241
doc/release-notes/TypeScript 1.4.md
Normal file
@ -0,0 +1,241 @@
|
||||
# TypeScript 1.4
|
||||
|
||||
## 联合类型
|
||||
|
||||
### 概述
|
||||
|
||||
联合类型有助于表示一个值的类型可以是多种类型之一的情况。比如,有一个API接命令行传入`string`类型,`string[]`类型或者是一个返回`string`的函数。你就可以这样写:
|
||||
|
||||
```ts
|
||||
interface RunOptions {
|
||||
program: string;
|
||||
commandline: string[]|string|(() => string);
|
||||
}
|
||||
```
|
||||
|
||||
给联合类型赋值也很直观 -- 只要这个值能满足联合类型中任意一个类型那么就可以赋值给这个联合类型:
|
||||
|
||||
```ts
|
||||
var opts: RunOptions = /* ... */;
|
||||
opts.commandline = '-hello world'; // OK
|
||||
opts.commandline = ['-hello', 'world']; // OK
|
||||
opts.commandline = [42]; // Error, 数字不是字符串或字符串数组
|
||||
```
|
||||
|
||||
当读取联合类型时,你可以访问类型共有的属性:
|
||||
|
||||
```ts
|
||||
if(opts.length === 0) { // OK, string和string[]都有'length'属性
|
||||
console.log("it's empty");
|
||||
}
|
||||
```
|
||||
|
||||
使用类型保护,你可以轻松地使用联合类型:
|
||||
|
||||
```ts
|
||||
function formatCommandline(c: string|string[]) {
|
||||
if(typeof c === 'string') {
|
||||
return c.trim();
|
||||
} else {
|
||||
return c.join(' ');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 严格的泛型
|
||||
|
||||
随着联合类型可以表示有很多类型的场景,我们决定去改进泛型调用的规范性。之前,这段代码编译不会报错(出乎意料):
|
||||
|
||||
```ts
|
||||
function equal<T>(lhs: T, rhs: T): boolean {
|
||||
return lhs === rhs;
|
||||
}
|
||||
|
||||
// 之前没有错误
|
||||
// 现在会报错:在string和number之前没有最佳的基本类型
|
||||
var e = equal(42, 'hello');
|
||||
```
|
||||
|
||||
通过联合类型,你可以指定你想要的行为,在函数定义时或在调用的时候:
|
||||
|
||||
```ts
|
||||
// 'choose' function where types must match
|
||||
function choose1<T>(a: T, b: T): T { return Math.random() > 0.5 ? a : b }
|
||||
var a = choose1('hello', 42); // Error
|
||||
var b = choose1<string|number>('hello', 42); // OK
|
||||
|
||||
// 'choose' function where types need not match
|
||||
function choose2<T, U>(a: T, b: U): T|U { return Math.random() > 0.5 ? a : b }
|
||||
var c = choose2('bar', 'foo'); // OK, c: string
|
||||
var d = choose2('hello', 42); // OK, d: string|number
|
||||
```
|
||||
|
||||
### 更好的类型推断
|
||||
|
||||
当一个集合里有多种类型的值时,联合类型会为数组或其它地方提供更好的类型推断:
|
||||
|
||||
```ts
|
||||
var x = [1, 'hello']; // x: Array<string|number>
|
||||
x[0] = 'world'; // OK
|
||||
x[0] = false; // Error, boolean is not string or number
|
||||
```
|
||||
|
||||
## `let` 声明
|
||||
在JavaScript里,`var`声明会被“提升”到所在作用域的顶端。这可能会引发一些让人不解的bugs:
|
||||
|
||||
```ts
|
||||
console.log(x); // meant to write 'y' here
|
||||
/* later in the same block */
|
||||
var x = 'hello';
|
||||
```
|
||||
|
||||
TypeScript已经支持新的ES6的关键字`let`,声明一个块级作用域的变量。一个`let`变量只能在声明之后的位置被引用,并且作用域为声明它的块里:
|
||||
|
||||
```ts
|
||||
if(foo) {
|
||||
console.log(x); // Error, cannot refer to x before its declaration
|
||||
let x = 'hello';
|
||||
} else {
|
||||
console.log(x); // Error, x is not declared in this block
|
||||
}
|
||||
```
|
||||
`let`只在设置目标为ECMAScript 6 (`--target ES6`)时生效。
|
||||
|
||||
## `const` 声明
|
||||
|
||||
另一个TypeScript支持的ES6里新出现的声明类型是`const`。不能给一个`const`类型变量赋值,只能在声明的时候初始化。这对于那些在初始化之后就不想去改变它的值的情况下是很有帮助的:
|
||||
|
||||
```ts
|
||||
const halfPi = Math.PI / 2;
|
||||
halfPi = 2; // Error, can't assign to a `const`
|
||||
```
|
||||
|
||||
`const`只在设置目标为ECMAScript 6 (`--target ES6`)时生效。
|
||||
|
||||
## 模版字符串
|
||||
|
||||
TypeScript现已支持ES6模块字符串。通过它可以方便地在字符串中嵌入任何表达式:
|
||||
|
||||
```ts
|
||||
var name = "TypeScript";
|
||||
var greeting = `Hello, ${name}! Your name has ${name.length} characters`;
|
||||
```
|
||||
|
||||
当编译目标为ES6之前的版本时,这个字符串被分解为:
|
||||
|
||||
```js
|
||||
var name = "TypeScript!";
|
||||
var greeting = "Hello, " + name + "! Your name has " + name.length + " characters";
|
||||
```
|
||||
|
||||
## 类型守护
|
||||
|
||||
JavaScript常用模式之一是在运行时使用`typeof`或`instanceof`检查表达式的类型。 在`if`语句里使用它们的时候,TypeScript可以识别出这些条件并且随之改变类型推断的结果。
|
||||
|
||||
使用`typeof`来检查一个变量:
|
||||
|
||||
```ts
|
||||
var x: any = /* ... */;
|
||||
if(typeof x === 'string') {
|
||||
console.log(x.subtr(1)); // Error, 'subtr' does not exist on 'string'
|
||||
}
|
||||
// x is still any here
|
||||
x.unknown(); // OK
|
||||
```
|
||||
|
||||
结合联合类型使用`typeof`和`else`:
|
||||
|
||||
```ts
|
||||
var x: string|HTMLElement = /* ... */;
|
||||
if(typeof x === 'string') {
|
||||
// x is string here, as shown above
|
||||
} else {
|
||||
// x is HTMLElement here
|
||||
console.log(x.innerHTML);
|
||||
}
|
||||
```
|
||||
|
||||
结合类和联合类型使用`instanceof`:
|
||||
|
||||
```ts
|
||||
class Dog { woof() { } }
|
||||
class Cat { meow() { } }
|
||||
var pet: Dog|Cat = /* ... */;
|
||||
if(pet instanceof Dog) {
|
||||
pet.woof(); // OK
|
||||
} else {
|
||||
pet.woof(); // Error
|
||||
}
|
||||
```
|
||||
|
||||
## 类型别名
|
||||
|
||||
你现在可以使用`type`关键字来为类型定义一个“别名”:
|
||||
|
||||
```ts
|
||||
type PrimitiveArray = Array<string|number|boolean>;
|
||||
type MyNumber = number;
|
||||
type NgScope = ng.IScope;
|
||||
type Callback = () => void;
|
||||
```
|
||||
|
||||
类型别名与其原始的类型完全一致;它们只是简单的替代名。
|
||||
|
||||
## `const enum`(完全嵌入的枚举)
|
||||
|
||||
枚举很有帮助,但是有些程序实际上并不需要它生成的代码并且想要将枚举变量所代码的数字值直接替换到对应位置上。新的`const enum`声明与正常的`enum`在类型安全方面具有同样的作用,只是在编译时会清除掉。
|
||||
|
||||
```ts
|
||||
const enum Suit { Clubs, Diamonds, Hearts, Spades }
|
||||
var d = Suit.Diamonds;
|
||||
```
|
||||
Compiles to exactly:
|
||||
```js
|
||||
var d = 1;
|
||||
```
|
||||
|
||||
TypeScript也会在可能的情况下计算枚举值:
|
||||
|
||||
```ts
|
||||
enum MyFlags {
|
||||
None = 0,
|
||||
Neat = 1,
|
||||
Cool = 2,
|
||||
Awesome = 4,
|
||||
Best = Neat | Cool | Awesome
|
||||
}
|
||||
var b = MyFlags.Best; // emits var b = 7;
|
||||
```
|
||||
|
||||
## `-noEmitOnError` 命令行选项
|
||||
|
||||
TypeScript编译器的默认行为是当存在类型错误(比如,将`string`类型赋值给`number`类型)时仍会生成.js文件。这在构建服务器上或是其它场景里可能会是不想看到的情况,因为希望得到的是一次“纯净”的构建。新的`noEmitOnError`标记可以阻止在编译时遇到错误的情况下继续生成.js代码。
|
||||
|
||||
它现在是MSBuild工程的默认行为;这允许MSBuild持续构建以我们想要的行为进行,输出永远是来自纯净的构建。
|
||||
|
||||
## AMD 模块名
|
||||
|
||||
默认情况下AMD模块以匿名形式生成。这在使用其它工具(比如,r.js)处理生成的模块的时可能会带来麻烦。
|
||||
|
||||
新的`amd-module name`标签允许给编译器传入一个可选的模块名:
|
||||
|
||||
```TypeScript
|
||||
//// [amdModule.ts]
|
||||
///<amd-module name='NamedModule'/>
|
||||
export class C {
|
||||
}
|
||||
```
|
||||
|
||||
结果会把`NamedModule`赋值成模块名,做为调用AMD`define`的一部分:
|
||||
|
||||
```JavaScript
|
||||
//// [amdModule.js]
|
||||
define("NamedModule", ["require", "exports"], function (require, exports) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
exports.C = C;
|
||||
});
|
||||
```
|
0
doc/release-notes/TypeScript 1.5.md
Normal file
0
doc/release-notes/TypeScript 1.5.md
Normal file
89
preface.md
89
preface.md
@ -21,42 +21,49 @@ TypeScript目前还在积极的开发完善之中,不断地会有新的特性
|
||||
|
||||
## 目录
|
||||
|
||||
* [基础类型](./doc/handbook/Basic Types.html)
|
||||
* [枚举](./doc/handbook/Enums.html)
|
||||
* [变量声明](./doc/handbook/Variable Declarations.html)
|
||||
* [接口](./doc/handbook/Interfaces.html)
|
||||
* [高级类型](./doc/handbook/Advanced Types.html)
|
||||
* [类](./doc/handbook/Classes.html)
|
||||
* [命名空间和模块](./doc/handbook/Namespaces and Modules.html)
|
||||
* [命名空间](./doc/handbook/Namespaces.html)
|
||||
* [模块](./doc/handbook/Modules.html)
|
||||
* [模块解析](./doc/handbook/Module Resolution.html)
|
||||
* [函数](./doc/handbook/Functions.html)
|
||||
* [泛型](./doc/handbook/Generics.html)
|
||||
* [混入](./doc/handbook/Mixins.html)
|
||||
* [声明合并](./doc/handbook/Declaration Merging.html)
|
||||
* [类型推论](./doc/handbook/Type Inference.html)
|
||||
* [类型兼容性](./doc/handbook/Type Compatibility.html)
|
||||
* [书写.d.ts文件](./doc/handbook/Writing Definition Files.html)
|
||||
* [Iterators 和 Generators](./doc/handbook/Iterators and Generators.html)
|
||||
* [Symbols](./doc/handbook/Symbols.html)
|
||||
* [Decorators](./doc/handbook/Decorators.html)
|
||||
* [JSX](./doc/handbook/JSX.html)
|
||||
* [tsconfig.json](./doc/handbook/tsconfig.json.html)
|
||||
* [编译选项](/doc/handbook/Complier Options.html)
|
||||
* [在MSBuild里使用编译选项](./doc/handbook/Compiler Options in MSBuild.html)
|
||||
* [与其它构建工具整合](./doc/handbook/Integrating with Build Tools.html)
|
||||
* [NPM包的类型](./doc/handbook/Typings for NPM Packages.html)
|
||||
* Wiki
|
||||
* [TypeScript里的this](./doc/handbook/this-in-TypeScript.html)
|
||||
* [编码规范](./doc/handbook/coding_guidelines.html)
|
||||
* [常见编译错误](./doc/handbook/Common Errors.html)
|
||||
* [支持TypeScript的编辑器](./doc/handbook/TypeScript-Editor-Support.html)
|
||||
* [结合ASP.NET v5使用TypeScript](./doc/handbook/Using-TypeScript-With-ASP.NET-5.html)
|
||||
* [架构概述](./doc/handbook/Architectural-Overview.html)
|
||||
* [发展路线图](./doc/handbook/Roadmap.html)
|
||||
* 快速上手
|
||||
* [快速上手](./doc/handbook/quick-start/README.html)
|
||||
* [React和webpack](./doc/handbook/quick-start/react-webpack.html)
|
||||
* [ASP.NET 4](./doc/handbook/quick-start/asp-net.html)
|
||||
* [新增功能](./doc/release-notes/README.html)
|
||||
* [TypeScript 1.1](./doc/release-notes/TypeScript 1.1.html)
|
||||
* [TypeScript 1.1](./doc/release-notes/TypeScript 1.3.html)
|
||||
* [TypeScript 1.1](./doc/release-notes/TypeScript 1.4.html)
|
||||
* [手册](./doc/handbook/Basic Types.html)
|
||||
* [基础类型](./doc/handbook/Basic Types.html)
|
||||
* [枚举](./doc/handbook/Enums.html)
|
||||
* [变量声明](./doc/handbook/Variable Declarations.html)
|
||||
* [接口](./doc/handbook/Interfaces.html)
|
||||
* [高级类型](./doc/handbook/Advanced Types.html)
|
||||
* [类](./doc/handbook/Classes.html)
|
||||
* [命名空间和模块](./doc/handbook/Namespaces and Modules.html)
|
||||
* [命名空间](./doc/handbook/Namespaces.html)
|
||||
* [模块](./doc/handbook/Modules.html)
|
||||
* [模块解析](./doc/handbook/Module Resolution.html)
|
||||
* [函数](./doc/handbook/Functions.html)
|
||||
* [泛型](./doc/handbook/Generics.html)
|
||||
* [混入](./doc/handbook/Mixins.html)
|
||||
* [声明合并](./doc/handbook/Declaration Merging.html)
|
||||
* [类型推论](./doc/handbook/Type Inference.html)
|
||||
* [类型兼容性](./doc/handbook/Type Compatibility.html)
|
||||
* [书写.d.ts文件](./doc/handbook/Writing Definition Files.html)
|
||||
* [Iterators 和 Generators](./doc/handbook/Iterators and Generators.html)
|
||||
* [Symbols](./doc/handbook/Symbols.html)
|
||||
* [Decorators](./doc/handbook/Decorators.html)
|
||||
* [JSX](./doc/handbook/JSX.html)
|
||||
* [工程配置](./doc/handbook/tsconfig.json.html)
|
||||
* [tsconfig.json](./doc/handbook/tsconfig.json.html)
|
||||
* [NPM包的类型](./doc/handbook/Typings for NPM Packages.html)
|
||||
* [编译选项](./doc/handbook/Compiler Options.html)
|
||||
* [在MSBuild里使用编译选项](./doc/handbook/Compiler Options in MSBuild.html)
|
||||
* [与其它构建工具整合](./doc/handbook/Integrating with Build Tools.html)
|
||||
* [wiki](./doc/wiki/README.html)
|
||||
* [TypeScript里的this](./doc/wiki/this-in-TypeScript.html)
|
||||
* [编码规范](./doc/wiki/coding_guidelines.html)
|
||||
* [常见编译错误](./doc/wiki/Common Errors.html)
|
||||
* [支持TypeScript的编辑器](./doc/wiki/TypeScript-Editor-Support.html)
|
||||
* [结合ASP.NET v5使用TypeScript](./doc/wiki/Using-TypeScript-With-ASP.NET-5.html)
|
||||
* [架构概述](./doc/wiki/Architectural-Overview.html)
|
||||
* [发展路线图](./doc/wiki/Roadmap.html)
|
||||
|
||||
|
||||
## 主要修改 (Latest 10 updates)
|
||||
@ -65,12 +72,12 @@ TypeScript目前还在积极的开发完善之中,不断地会有新的特性
|
||||
* 2016-04-01 新增特性:[多态的`this`类型](./doc/handbook/Advanced Types.html)
|
||||
* 2016-04-01 新增特性:[字符串字面量类型](./doc/handbook/Advanced Types.html)
|
||||
* 2016-02-27 新增章节:快速上手[React和webpack](./doc/handbook/quick-start/react-webpack.html)
|
||||
* 2016-01-31 新增章节:[TypeScript里的this](./doc/handbook/this-in-TypeScript.html)
|
||||
* 2016-01-24 新增章节:[发展路线图](./doc/handbook/Roadmap.html)
|
||||
* 2016-01-23 新增章节:[编码规范](./doc/handbook/coding_guidelines.html)
|
||||
* 2016-01-23 新增章节:[架构概述](./doc/handbook/Architectural-Overview.html)
|
||||
* 2015-12-27 新增章节:[结合ASP.NET v5使用TypeScript](./doc/handbook/Using-TypeScript-With-ASP.NET-5.html)
|
||||
* 2015-12-26 新增章节:[支持TypeScript的编辑器](./doc/handbook/TypeScript-Editor-Support.html)
|
||||
* 2016-01-31 新增章节:[TypeScript里的this](./doc/wiki/this-in-TypeScript.html)
|
||||
* 2016-01-24 新增章节:[发展路线图](./doc/wiki/Roadmap.html)
|
||||
* 2016-01-23 新增章节:[编码规范](./doc/wiki/coding_guidelines.html)
|
||||
* 2016-01-23 新增章节:[架构概述](./doc/wiki/Architectural-Overview.html)
|
||||
* 2015-12-27 新增章节:[结合ASP.NET v5使用TypeScript](./doc/wiki/Using-TypeScript-With-ASP.NET-5.html)
|
||||
* 2015-12-26 新增章节:[支持TypeScript的编辑器](./doc/wiki/TypeScript-Editor-Support.html)
|
||||
|
||||
|
||||
## 相关链接
|
||||
|
Loading…
Reference in New Issue
Block a user