Skip to content

Commit 75b80e7

Browse files
committed
Replace alert function with console.log where applicable
Fix minor style issues
1 parent 284581b commit 75b80e7

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎pages/Basic Types.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ For example, if we had the value `2` but weren't sure what that mapped to in the
135135
enum Color {Red = 1, Green, Blue}
136136
let colorName: string = Color[2];
137137

138-
alert(colorName); // Displays 'Green' as its value is 2 above
138+
console.log(colorName); // Displays 'Green' as its value is 2 above
139139
```
140140

141141
# Any
@@ -180,7 +180,7 @@ You may commonly see this as the return type of functions that do not return a v
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

‎pages/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
Similarly, namespaces can be used to extend enums with static members:

‎pages/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
Just as with interface, putting the type parameter on the class itself lets us make sure all of the properties of the class are working with the same type.

‎pages/Type Checking JavaScript Files.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ If properties are never set in the class body, they are considered unknown. If y
5151
In a `.js` files CommonJS module format is allowed as an input module format. Assignments to `exports`, and `module.exports` are recognized as export declarations. Similarly, `require` function calls are recognized as module imports. For example:
5252

5353
```ts
54-
// import module "fs"
54+
// Import module "fs"
5555
const fs = require("fs");
5656

5757

58-
// export function readFile
58+
// Export function readFile
5959
module.exports.readFile = function(f) {
6060
return fs.readFileSync(f);
6161
}
@@ -106,9 +106,9 @@ JSDoc annotated functions are excluded from this rule. Use JSDoc optional parame
106106
*/
107107
function sayHello(somebody) {
108108
if (!somebody) {
109-
somebody = 'John Doe';
109+
somebody = "John Doe";
110110
}
111-
alert('Hello ' + somebody);
111+
console.log("Hello " + somebody);
112112
}
113113

114114
sayHello();
@@ -132,7 +132,7 @@ import { Component } from "react";
132132

133133
class MyComponent extends Component {
134134
render() {
135-
this.props.b; // Allowed, since this.props is of type any
135+
this.props.b; // Allowed, since this.props is of type any
136136
}
137137
}
138138
```

‎pages/Type Compatibility.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ The same rule for assignment is used when checking function call arguments:
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)