Skip to content

Commit

Permalink
Revert "translate release notes (#61)" (#63)
Browse files Browse the repository at this point in the history
This reverts commit d3ad547.
  • Loading branch information
awxiaoxian2020 authored Mar 18, 2024
1 parent 6ec39eb commit 724002b
Show file tree
Hide file tree
Showing 40 changed files with 7,769 additions and 7,482 deletions.
12 changes: 6 additions & 6 deletions docs/documentation/zh/release-notes/TypeScript 1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ permalink: /zh/docs/handbook/release-notes/typescript-1-1.html
oneline: TypeScript 1.1 Release Notes
---

## 改进性能
## Performance Improvements

1.1版本的编译器速度比所有之前发布的版本快4倍。阅读[这篇博客里的有关图表](http://blogs.msdn.com/b/typescript/archive/2014/10/06/announcing-typescript-1-1-ctp.aspx)
The 1.1 compiler is typically around 4x faster than any previous release. See [this blog post for some impressive charts.](https://web.archive.org/web/20141007020020/http://blogs.msdn.com/b/typescript/archive/2014/10/06/announcing-typescript-1-1-ctp.aspx)

## 更好的模块可见性规则
## Better Module Visibility Rules

TypeScript现在只在使用`--declaration`标记时才严格强制模块里类型的可见性。这在Angular里很有用,例如:
TypeScript now only strictly enforces the visibility of types in modules if the [`declaration`](/tsconfig#declaration) flag is provided. This is very useful for Angular scenarios, for example:

```ts
module MyControllers {
Expand All @@ -21,8 +21,8 @@ module MyControllers {
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) { }
constructor(public $scope: ZooScope) {}
/* more code */
}
}
```
```
37 changes: 19 additions & 18 deletions docs/documentation/zh/release-notes/TypeScript 1.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,51 @@ permalink: /zh/docs/handbook/release-notes/typescript-1-3.html
oneline: TypeScript 1.3 Release Notes
---

## 受保护的
## Protected

类里面新的`protected`修饰符作用与其它语言如C++,C\#和Java中的一样。一个类的`protected`成员只在这个类的子类中可见:
The new `protected` modifier in classes works like it does in familiar languages like C++, C#, and Java. A `protected` member of a class is visible only inside subclasses of the class in which it is declared:

```ts
class Thing {
protected doSomething() { /* ... */ }
protected doSomething() {
/* ... */
}
}

class MyThing extends Thing {
public myMethod() {
// OK,可以在子类里访问受保护的成员
// OK, can access protected member from subclass
this.doSomething();
}
}
var t = new MyThing();
t.doSomething(); // Error,不能在类外部访问受保护成员
t.doSomething(); // Error, cannot call protected member from outside class
```

## 元组类型
## Tuple types

元组类型表示一个数组,其中元素的类型都是已知的,但是不一样是同样的类型。比如,你可能想要表示一个第一个元素是`string`类型第二个元素是`number`类型的数组:
Tuple types express an array where the type of certain elements is known, but need not be the same. For example, you may want to represent an array with a `string` at position 0 and a `number` at position 1:

```ts
// Declare a tuple type
var x: [string, number];
// 初始化
x = ['hello', 10]; // OK
// 错误的初始化
x = [10, 'hello']; // Error
// Initialize it
x = ["hello", 10]; // OK
// Initialize it incorrectly
x = [10, "hello"]; // Error
```

但是访问一个已知的索引,会得到正确的类型:
When accessing an element with a known index, the correct type is retrieved:

```ts
console.log(x[0].substr(1)); // OK
console.log(x[1].substr(1)); // Error, 'number'没有'substr'方法
console.log(x[1].substr(1)); // Error, 'number' does not have 'substr'
```

注意在TypeScript1.4里,当访问超出已知索引的元素时,会返回联合类型:
Note that in TypeScript 1.4, when accessing an element outside the set of known indices, a union type is used instead:

```ts
x[3] = 'world'; // OK
console.log(x[5].toString()); // OK, 'string''number'都有toString
x[6] = true; // Error, boolean不是number或string
x[3] = "world"; // OK
console.log(x[5].toString()); // OK, 'string' and 'number' both have toString
x[6] = true; // Error, boolean isn't number or string
```

Loading

0 comments on commit 724002b

Please sign in to comment.