You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/compiler/binder-functions.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Note: `locals` is defined on `Node` and is of type `SymbolTable`. Note that `Sou
9
9
TIP: local functions are used heavily within the TypeScript compiler. A local function very likely uses variables from the parent function (captured by closure). In the case of `bind` (a local function within `bindSourceFile`) it (or function it calls) will setup the `symbolCount` and `classifiableNames` among others, that are then stored on the returned `SourceFile`.
10
10
11
11
#### `bind`
12
-
Bind takes any `Node` (not just `SourceFile`). First thing it does is assign the `node.parent` (if `parent` variable has been setup ... which again is something the binder does during its processing within the `bindChildren` function), then hands off to `bindWorker` which does the *heavy* lifting. Finally it calls `bindChildren` (a function that simply stores the binder state e.g. current `parent` within its function local vars, then calls `bind` on each child, and then restores the binder state). Now lets look at `bindWorker` which is the more interesting function.
12
+
Bind takes any `Node` (not just `SourceFile`). First thing it does is assign the `node.parent` (if `parent` variable has been setup ... which again is something the binder does during its processing within the `bindChildren` function), then hands off to `bindWorker` which does the *heavy* lifting. Finally it calls `bindChildren` (a function that simply stores the binder state e.g. current `parent` within its function local vars, then calls `bind` on each child, and then restores the binder state). Now let's look at `bindWorker` which is the more interesting function.
13
13
14
14
#### `bindWorker`
15
15
This function switches on `node.kind` (of type `SyntaxKind`) and delegates work to the appropriate `bindFoo` function (also defined within `binder.ts`). For example if the `node` is a `SourceFile` it calls (eventually and only if its an external file module) `bindAnonymousDeclaration`
Copy file name to clipboardExpand all lines: docs/enums.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ col = 0; // Effectively same as Color.Red
39
39
```
40
40
41
41
#### Enums and Strings
42
-
Before we look further into enums lets look at the JavaScript that it generates, here is a sample TypeScript:
42
+
Before we look further into enums let's look at the JavaScript that it generates, here is a sample TypeScript:
43
43
44
44
```ts
45
45
enumTristate {
@@ -59,7 +59,7 @@ var Tristate;
59
59
})(Tristate || (Tristate = {}));
60
60
```
61
61
62
-
lets focus on the line `Tristate[Tristate["False"] = 0] = "False";`. Within it `Tristate["False"] = 0` should be self explanatory, i.e. sets `"False"` member of `Tristate` variable to be `0`. Note that in JavaScript the assignment operator returns the assigned value (in this case `0`). Therefore the next thing executed by the JavaScript runtime is `Tristate[0] = "False"`. This means that you can use the `Tristate` variable to convert a string version of the enum to a number or a number version of the enum to a string. This is demonstrated below:
62
+
let's focus on the line `Tristate[Tristate["False"] = 0] = "False";`. Within it `Tristate["False"] = 0` should be self explanatory, i.e. sets `"False"` member of `Tristate` variable to be `0`. Note that in JavaScript the assignment operator returns the assigned value (in this case `0`). Therefore the next thing executed by the JavaScript runtime is `Tristate[0] = "False"`. This means that you can use the `Tristate` variable to convert a string version of the enum to a number or a number version of the enum to a string. This is demonstrated below:
@@ -38,4 +38,4 @@ Essentially TypeScript is linting JavaScript. Just doing a better job at it than
38
38
39
39
## You still need to learn JavaScript
40
40
41
-
That said TypeScript is very pragmatic about the fact that *you do write JavaScript* so there are some things about JavaScript that you still need to know in order to not be caught off-guard. Lets discuss them next.
41
+
That said TypeScript is very pragmatic about the fact that *you do write JavaScript* so there are some things about JavaScript that you still need to know in order to not be caught off-guard. Let's discuss them next.
Copy file name to clipboardExpand all lines: docs/options/intro.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
There are a few things that TypeScript prevents you from doing out of the box e.g using a variable that *isn't ever declared* (of course you can use a *declaration file* for external systems).
4
4
5
-
That said, traditionally programming languages have a hard boundary between what is and isn't allowed by the type system. TypeScript is different in that it gives you control on where you put the slider. This is really to allow you to use the JavaScript you know and love with as much safety as **you** want. There are lot of compiler options to control exactly this slider so lets have a look.
5
+
That said, traditionally programming languages have a hard boundary between what is and isn't allowed by the type system. TypeScript is different in that it gives you control on where you put the slider. This is really to allow you to use the JavaScript you know and love with as much safety as **you** want. There are lot of compiler options to control exactly this slider so let's have a look.
6
6
7
7
8
8
### Boolean Options
@@ -25,4 +25,4 @@ tsc --someBooleanOption
25
25
26
26
> All of these are `false` by default.
27
27
28
-
Click [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html) to see all compiler options.
28
+
Click [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html) to see all compiler options.
Copy file name to clipboardExpand all lines: docs/promise.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ The `Promise` class is something that exists in many modern JavaScript engines a
4
4
5
5
### Callback style code
6
6
7
-
In order to fully appreciate promises lets present a simple sample that proves the difficulty of creating reliable Async code with just callbacks. Consider the simple case of authoring an async version of loading JSON from a file. A synchronous version of this can be quite simply
7
+
In order to fully appreciate promises let's present a simple sample that proves the difficulty of creating reliable Async code with just callbacks. Consider the simple case of authoring an async version of loading JSON from a file. A synchronous version of this can be quite simply
8
8
9
9
```ts
10
10
importfs=require('fs');
@@ -129,7 +129,7 @@ loadJSON('good.json', function (err, data) {
129
129
130
130
if (err) console.log('Error:', err.message);
131
131
else {
132
-
//lets simulate an error by trying to access a property on an undefined variable
132
+
//let's simulate an error by trying to access a property on an undefined variable
133
133
var foo;
134
134
// The following code throws `Error: Cannot read property 'bar' of undefined`
135
135
console.log(foo.bar);
@@ -176,7 +176,7 @@ A promise can be either `pending` or `resolved` or `rejected`.
Lets look at creating a promise. Its a simple matter of calling `new` on `Promise` (the promise constructor). The promise constructor is passed `resolve` and `reject` functions for settling the promise state.
179
+
Let's look at creating a promise. Its a simple matter of calling `new` on `Promise` (the promise constructor). The promise constructor is passed `resolve` and `reject` functions for settling the promise state.
180
180
181
181
```ts
182
182
const promise =newPromise((resolve, reject) => {
@@ -255,7 +255,7 @@ Promise.reject(new Error('something bad happened'))
255
255
return123;
256
256
})
257
257
.catch((err) => {
258
-
console.log(err.message); // something bad happened
258
+
console.log(err.message); // something bad happened
259
259
});
260
260
```
261
261
@@ -344,7 +344,7 @@ Just wrap the function call in a promise and
344
344
-`reject` if an error occurs,
345
345
-`resolve` if it is all good.
346
346
347
-
E.g. lets wrap `fs.readFile`
347
+
E.g. let's wrap `fs.readFile`
348
348
349
349
```ts
350
350
importfs=require('fs');
@@ -414,7 +414,7 @@ function loadItem(id: number): Promise<{id: number}> {
Copy file name to clipboardExpand all lines: docs/types/lib.d.ts.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ You can exclude this file from the compilation context by specifying the `--noLi
17
17
18
18
### Example Usage
19
19
20
-
As always lets look at examples of this file being used in action.
20
+
As always let's look at examples of this file being used in action.
21
21
22
22
```ts
23
23
var foo =123;
@@ -39,7 +39,7 @@ The contents of `lib.d.ts` are primarily a bunch of *variable* declarations e.g.
39
39
40
40
The simplest way to discover what is what is to type in code *that you know works* e.g. `Math.floor` and then F12 (go to definition) using your IDE (atom-typescript has great support for this).
41
41
42
-
Lets look at a sample *variable* declaration, e.g. `window` is defined as:
42
+
Let's look at a sample *variable* declaration, e.g. `window` is defined as:
43
43
```ts
44
44
declarevar window:Window;
45
45
```
@@ -223,24 +223,24 @@ However if you want finer grained control of your environment you should use the
223
223
224
224
Sometimes (many times) you want to decouple the relationship between the compile target (the generates JavaScript version) and the ambient library support. A common example is `Promise`, e.g today (in June 2016) you most likely want to `--target es5` but still use latest stuff like `Promise`. To support this you can take explicit control of `lib` using the `lib` compiler option.
225
225
226
-
> Note: using `--lib` decouples any lib magic from `--target` giving you better control.
226
+
> Note: using `--lib` decouples any lib magic from `--target` giving you better control.
227
227
228
-
You can provide this option on the command line or in `tsconfig.json` (recommended):
228
+
You can provide this option on the command line or in `tsconfig.json` (recommended):
229
229
230
230
**Command line**:
231
231
```
232
232
tsc --target es5 --lib dom,es6
233
-
```
234
-
**tsconfig.json**:
233
+
```
234
+
**tsconfig.json**:
235
235
```json
236
236
"compilerOptions": {
237
237
"lib": ["dom", "es6"]
238
238
}
239
239
```
240
240
241
-
The libs can be categorized into categories:
241
+
The libs can be categorized into categories:
242
242
243
-
* JavaScript Bulk Feature:
243
+
* JavaScript Bulk Feature:
244
244
* es5
245
245
* es6
246
246
* es2015
@@ -268,11 +268,11 @@ The libs can be categorized into categories:
268
268
269
269
> NOTE: the `--lib` option provides extremely fine tuned control. So you most likey want to pick an item from the bulk + enviroment categories.
0 commit comments