Skip to content

Commit c2b54b6

Browse files
committed
Replace alert function with console.log where applicable. PR770
1 parent c04bf33 commit c2b54b6

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

doc/handbook/Basic Types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ let c: Color = Color.Green;
135135
enum Color {Red = 1, Green, Blue}
136136
let colorName: string = Color[2];
137137

138-
alert(colorName); // 显示'Green'因为上面代码里它的值是2
138+
console.log(colorName); // 显示'Green'因为上面代码里它的值是2
139139
```
140140

141141
# 任意值
@@ -180,7 +180,7 @@ list[1] = 100;
180180

181181
```ts
182182
function warnUser(): void {
183-
alert("This is my warning message");
183+
console.log("This is my warning message");
184184
}
185185
```
186186

doc/handbook/Declaration Merging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ namespace Animal {
163163

164164
namespace Animal {
165165
export function doAnimalsHaveMuscles() {
166-
return haveMuscles; // <-- error, haveMuscles is not visible here
166+
return haveMuscles; // Error, because haveMuscles is not accessible here
167167
}
168168
}
169169
```
@@ -207,7 +207,7 @@ namespace buildLabel {
207207
export let prefix = "Hello, ";
208208
}
209209

210-
alert(buildLabel("Sam Smith"));
210+
console.log(buildLabel("Sam Smith"));
211211
```
212212

213213
相似的,命名空间可以用来扩展枚举型:

doc/handbook/Generics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ let stringNumeric = new GenericNumber<string>();
216216
stringNumeric.zeroValue = "";
217217
stringNumeric.add = function(x, y) { return x + y; };
218218

219-
alert(stringNumeric.add(stringNumeric.zeroValue, "test"));
219+
console.log(stringNumeric.add(stringNumeric.zeroValue, "test"));
220220
```
221221

222222
与接口一样,直接把泛型类型放在类后面,可以帮助我们确认类的所有属性都在使用相同的类型。

doc/handbook/Type Checking JavaScript Files.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ c.prop = "string"; // Error: string is not assignable to number|undefined
5353
相似地,`require`函数调用被识别为模块导入。例如:
5454

5555
```ts
56-
// import module "fs"
56+
// Import module "fs"
5757
const fs = require("fs");
5858

5959

60-
// export function readFile
60+
// Export function readFile
6161
module.exports.readFile = function(f) {
6262
return fs.readFileSync(f);
6363
}
@@ -109,9 +109,9 @@ bar(1, 2, 3); // Error, too many arguments
109109
*/
110110
function sayHello(somebody) {
111111
if (!somebody) {
112-
somebody = 'John Doe';
112+
somebody = "John Doe";
113113
}
114-
alert('Hello ' + somebody);
114+
console.log("Hello " + somebody);
115115
}
116116

117117
sayHello();

doc/handbook/Type Compatibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ x = y;
5050

5151
```ts
5252
function greet(n: Named) {
53-
alert('Hello, ' + n.name);
53+
console.log('Hello, ' + n.name);
5454
}
5555
greet(y); // OK
5656
```

0 commit comments

Comments
 (0)