Skip to content

Commit 5a21327

Browse files
committed
no message
1 parent 77b8634 commit 5a21327

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/why-typescript.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ This type inference is well motivated. If you do stuff like shown in this exampl
3232

3333
### Types can be Explicit
3434
As we've mentioned before, TypeScript will infer as much as it can safely, however you can use annotations to:
35-
1. Help along the compiler, and more importantly the next developer who has to read your code (that might be future you!).
36-
1. Enforce that what the compiler sees is, what you thought it should see. That is your understanding of the code matches an algorithmic analysis of the code (done by the compiler).
35+
1. Help along the compiler, and more importantly document stuff for the next developer who has to read your code (that might be future you!).
36+
1. Enforce that what the compiler sees, is what you thought it should see. That is your understanding of the code matches an algorithmic analysis of the code (done by the compiler).
3737

38-
TypeScript uses postfix type annotations popular in other *optionally* annotated languages (e.g. ActionScript).
38+
TypeScript uses postfix type annotations popular in other *optionally* annotated languages (e.g. ActionScript and F#).
3939

4040
```ts
4141
var foo: number = 123;
@@ -46,10 +46,10 @@ So if you do something wrong the compiler will error e.g.:
4646
var foo: number = '123'; // Error: cannot assign a `string` to a `number`
4747
```
4848

49-
We will discuss all the details of all the annotation methods supported by TypeScript in a later chapter.
49+
We will discuss all the details of all the annotation syntax supported by TypeScript in a later chapter.
5050

5151
### Types are structural
52-
In some languages (specifically nominally typed ones) static typing results in unnecessary ceremony because even though *you know* that the code will work fine the language semantics force you to copy stuff around. This is why stuff like [automapper for C#](http://automapper.org/) exists. In TypeScript because we really want it to be easy for JavaScript developers, and be minimum cognitive overload types are *structural*. This means that *duck typing* is a first class language construct. An example is in order:
52+
In some languages (specifically nominally typed ones) static typing results in unnecessary ceremony because even though *you know* that the code will work fine the language semantics force you to copy stuff around. This is why stuff like [automapper for C#](http://automapper.org/) is *vital* for C#. In TypeScript because we really want it to be easy for JavaScript developers with a minimum cognitive overload, types are *structural*. This means that *duck typing* is a first class language construct. Consider the following example. The function `iTakePoint2D` will accept anything that contains all the things (`x` and `y`) it expects:
5353

5454
```ts
5555
interface Point2D {
@@ -85,7 +85,7 @@ var foo = 123;
8585
foo = '456';
8686
```
8787

88-
So you can incrementally upgrade your JavaScript code to TypeScript. This is very different from how many other language compilers work and is there for your ease.
88+
So you can incrementally upgrade your JavaScript code to TypeScript. This is very different from how many other language compilers work and yet another reason to move to TypeScript.
8989

9090
### Types can be ambient
9191
A major design goal of TypeScript was to make it possible for you to safely and easily use existing JavaScript libraries in TypeScript. TypeScript does this by means of *declaration*. TypeScript provides you with a sliding scale of how much or how little effort you want to put in your declarations, the more effort you put the more type safety + code intelligence you get. Note that definitions for most of the popular libraries have already been written for you by the [DefinitelyTyped community](https://github.com/borisyankov/DefinitelyTyped) so for the most purposes:

0 commit comments

Comments
 (0)