Skip to content

Commit

Permalink
translate release notes (#64)
Browse files Browse the repository at this point in the history
* Revert "Revert "translate release notes (#61)" (#63)"

This reverts commit 724002b.

* revert

---------

Co-authored-by: Xavi Lee <[email protected]>
Co-authored-by: Patrick Zhong <[email protected]>
  • Loading branch information
3 people authored Mar 18, 2024
1 parent 724002b commit d5dfce4
Show file tree
Hide file tree
Showing 39 changed files with 7,191 additions and 7,474 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
## 改进性能

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)
1.1版本的编译器速度比所有之前发布的版本快4倍。阅读[这篇博客里的有关图表](http://blogs.msdn.com/b/typescript/archive/2014/10/06/announcing-typescript-1-1-ctp.aspx)

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

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:
TypeScript现在只在使用`--declaration`标记时才严格强制模块里类型的可见性。这在Angular里很有用,例如:

```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: 18 additions & 19 deletions docs/documentation/zh/release-notes/TypeScript 1.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,50 @@ permalink: /zh/docs/handbook/release-notes/typescript-1-3.html
oneline: TypeScript 1.3 Release Notes
---

## 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:
类里面新的`protected`修饰符作用与其它语言如C++,C\#和Java中的一样。一个类的`protected`成员只在这个类的子类中可见:

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

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

## Tuple types
## 元组类型

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:
元组类型表示一个数组,其中元素的类型都是已知的,但是不一样是同样的类型。比如,你可能想要表示一个第一个元素是`string`类型第二个元素是`number`类型的数组:

```ts
// Declare a tuple type
var x: [string, number];
// Initialize it
x = ["hello", 10]; // OK
// Initialize it incorrectly
x = [10, "hello"]; // Error
// 初始化
x = ['hello', 10]; // OK
// 错误的初始化
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' does not have 'substr'
console.log(x[1].substr(1)); // Error, 'number'没有'substr'方法
```

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

```ts
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
x[3] = 'world'; // OK
console.log(x[5].toString()); // OK, 'string''number'都有toString
x[6] = true; // Error, boolean不是number或string
```

Loading

0 comments on commit d5dfce4

Please sign in to comment.