Skip to content

Commit 6c0aa6e

Browse files
committed
change readme format
1 parent 908a8b0 commit 6c0aa6e

33 files changed

+215
-166
lines changed

README.md

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,44 @@
11
# TypeScript-NotesForProfessionals
22

3-
| Chapter | Details |
4-
|:-------:|:-------:|
5-
| 1: Getting started with TypeScript | [Readme](/chapters/1/readme.md) |
6-
| 2: Why and when to use TypeScript | [Readme](/chapters/2/readme.md) |
7-
| 3: TypeScript Core Types | [Readme](/chapters/3/readme.md) |
8-
| 4: Arrays | [Readme](/chapters/4/app.ts) |
9-
| 5: Enums | [Readme](/chapters/5/readme.md) |
10-
| 6: Functions | [Readme]() |
11-
| 7: Classes | [Readme]() |
12-
| 8: Class Decorator | [Readme]() |
13-
| 9: Interfaces | [Readme]() |
14-
| 10: Generics | [Readme]() |
15-
| 11: Strict null checks | [Readme]() |
16-
| 12: User-defined Type Guards | [Readme]() |
17-
| 13: TypeScript basic examples | [Readme]() |
18-
| 14: Importing external libraries | [Readme]() |
19-
| 15: Modules - exporting and importing | [Readme]() |
20-
| 16: Publish TypeScript definition files | [Readme]() |
21-
| 17: Using TypeScript with webpack | [Readme]() |
22-
| 18: Mixins | [Readme]() |
23-
| 19: How to use a JavaScript library without a type definition file | [Readme]() |
24-
| 20: TypeScript installing typescript and running the typescript compiler tsc | [Readme]() |
25-
| 21: Configure typescript project to compile all files in typescript. | [Readme]() |
26-
| 22: Integrating with Build Tools | [Readme]() |
27-
| 23: Using TypeScript with RequireJS | [Readme]() |
28-
| 24: TypeScript with AngularJS | [Readme]() |
29-
| 25: TypeScript with SystemJS | [Readme]() |
30-
| 26: Using TypeScript with React (JS & native) | [Readme]() |
31-
| 27: TSLint - assuring code quality and consistency | [Readme]() |
32-
| 28: tsconfig.json | [Readme]() |
33-
| 29: Debugging | [Readme]() |
34-
| 30: Unit Testing | [Readme]() |
3+
* Chapter 1: Getting started with TypeScript
4+
5+
- [Section 1.1: Installation and setup](/book_pages/chapter1/section1.1.md)
6+
- [Section 1.2: Basic syntax](/book_pages/chapter1/section1.2.md)
7+
- [Section 1.3: Hello World](/book_pages/chapter1/section1.3.md)
8+
- [Section 1.4: Running TypeScript using ts-node](/book_pages/chapter1/section1.4.md)
9+
- [Section 1.5: TypeScript REPL in Node.js](/book_pages/chapter1/section1.5.md)
10+
11+
* Chapter 2: Why and when to use TypeScript
12+
13+
- [Section 2.1: Safety](/book_pages/chapter2/section2.1.md)
14+
- [Section 2.2: Readability](/book_pages/chapter2/section2.2.md)
15+
- [Section 2.3: Tooling](/book_pages/chapter2/section2.3.md)
16+
17+
* <details>
18+
<summary>Chapter 3: TypeScript Core Types</summary>
19+
20+
- [Section 3.1: String Literal Types](/book_pages/chapter3/section3.1.md)
21+
- [Section 3.2: Tuple](/book_pages/chapter3/section3.2.md)
22+
- [Section 3.3: Boolean](/book_pages/chapter3/section3.3.md)
23+
- [Section 3.4: Intersection Types](/book_pages/chapter3/section3.4.md)
24+
- [Section 3.5: Types in function arguments and return value Number](/book_pages/chapter3/section3.5.md)
25+
- [Section 3.6: Types in function arguments and return value. String](/book_pages/chapter3/section3.6.md)
26+
- [Section 3.7: const Enum](/book_pages/chapter3/section3.7.md)
27+
- [Section 3.8: Number](/book_pages/chapter3/section3.8.md)
28+
- [Section 3.9: String](/book_pages/chapter3/section3.9.md)
29+
- [Section 3.10: Array](/book_pages/chapter3/section3.10.md)
30+
- [Section 3.11: Enum](/book_pages/chapter3/section3.11.md)
31+
- [Section 3.12: Any](/book_pages/chapter3/section3.12.md)
32+
- [Section 3.13: Void](/book_pages/chapter3/section3.13.md)
33+
</details>
34+
35+
* Chapter 4: Arrays
36+
37+
- [Section 4.1: Finding Object in Array](/book_pages/chapter4/section4.1.md)
38+
39+
* Chapter 5: Enums
40+
41+
- [Section 5.1: Enums with explicit values](/book_pages/chapter5/section5.1.md)
42+
- [Section 5.2: How to get all enum values](/book_pages/chapter5/section5.2.md)
43+
- [Section 5.3: Extending enums without custom enum implementation](/book_pages/chapter5/section5.3.md)
44+
- [Section 5.4: Custom enum implementation: extends for enums](/book_pages/chapter5/section5.4.md)
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
TypeScript is a typed superset of JavaScript that compiles directly to JavaScript code. TypeScript files commonly use the `.ts` extension. Many IDEs support TypeScript without any other setup required, but TypeScript can also be compiled with the `TypeScript Node.JS` package from the command line.
1+
# Section 1.1: Installation and setup
2+
3+
TypeScript is a typed superset of JavaScript that compiles directly to JavaScript
4+
code. TypeScript files commonly use the `.ts` extension. Many IDEs support TypeScript
5+
without any other setup required, but TypeScript can also be compiled with the
6+
`TypeScript Node.JS` package from the command line.
27

38
### Install the npm package globally
49
You can install TypeScript globally to have access to it from any directory.
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
TypeScript is a typed superset of JavaScript, which means that all JavaScript code is valid TypeScript code. TypeScript adds a lot of new features on top of that.
1+
# Section 1.2: Basic syntax
22

3-
TypeScript makes JavaScript more like a strongly-typed, object-oriented language akin to C# and Java. This means that TypeScript code tends to be easier to use for large projects and that code tends to be easier to understand and maintain. The strong typing also means that the language can (and is) precompiled and that variables cannot be assigned values that are out of their declared range. For instance, when a TypeScript variable is declared as a number, you cannot assign a text value to it.
3+
TypeScript is a typed superset of JavaScript, which means that all JavaScript code is
4+
valid TypeScript code. TypeScript adds a lot of new features on top of that.
45

5-
This strong typing and object orientation makes TypeScript easier to debug and maintain, and those were two of the weakest points of standard JavaScript.
6+
TypeScript makes JavaScript more like a strongly-typed, object-oriented language akin
7+
to C# and Java. This means that TypeScript code tends to be easier to use for large
8+
projects and that code tends to be easier to understand and maintain. The strong
9+
typing also means that the language can (and is) precompiled and that variables cannot
10+
be assigned values that are out of their declared range. For instance, when a
11+
TypeScript variable is declared as a number, you cannot assign a text value to it.
612

7-
You can add type declarations to variables, function parameters and function return types. The type is written after a colon following the variable name, like this: var num: number = 5; The compiler will then check the types (where possible) during compilation and report type errors.
8-
```
13+
This strong typing and object orientation makes TypeScript easier to debug and
14+
maintain, and those were two of the weakest points of standard JavaScript.
15+
16+
You can add type declarations to variables, function parameters and function return
17+
types. The type is written after a colon following the variable name, like this: var
18+
num: number = 5; The compiler will then check the types (where possible) during
19+
compilation and report type errors.
20+
```ts
921
var num: number = 5;
1022
num = "this is a string";
1123
// error: Type 'string' is not assignable to type 'number'.
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Section 1.3: Hello World
2+
3+
```ts
14
class myContainer {
25
public myStr: string;
36
constructor(message: string) {
@@ -9,4 +12,5 @@ class myContainer {
912
};
1013

1114
let createObj = new myContainer("Hi Morol!");
12-
console.log(createObj.getData());
15+
console.log(createObj.getData());
16+
```
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
ts-node is an npm package which allows the user to run typescript files directly, without the need for precompilation using tsc . It also provides REPL.
1+
# Section 1.4: Running TypeScript using ts-node
2+
3+
ts-node is an npm package which allows the user to run typescript files directly,
4+
without the need for precompilation using tsc . It also provides REPL.
25

36
### Install ts-node globally using
47
- `npm install -g ts-node`
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
# Section 1.5: TypeScript REPL in Node.js
2+
13
### For use TypeScript REPL in Node.js you can use tsun package
24
- Install it globally with
35
- `npm install -g tsun`
46

57
and run in your terminal or command prompt with tsun command
68

79
### Usage example:
8-
```
10+
```ts
911
$ tsun
10-
TSUN : TypeScript Upgraded Node
12+
// TSUN : TypeScript Upgraded Node
1113

12-
type in TypeScript expression to evaluate
13-
type :help for commands in repl
14+
// type in TypeScript expression to evaluate
15+
// type :help for commands in repl
1416

1517
$ function multiply(x, y) {
1618
return x * y;

book_pages/chapter2/section2.1.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Section 2.1: Safety
2+
3+
If you find the arguments for type systems persuasive in general, then you'll be happy
4+
with TypeScript. It brings many of the advantages of type system (safety, readability,
5+
improved tooling) to the JavaScript ecosystem. It also suffers from some of the
6+
drawbacks of type systems (added complexity and incompleteness).
7+
8+
```ts
9+
function double(num: number): number {
10+
return num * 5;
11+
}
12+
13+
console.log(double('6'));
14+
// myTs.ts:5:20 - error TS2345: Argument of type '"6"' is not assignable
15+
// to parameter of type 'number'.
16+
17+
console.log(double(6)); // 30
18+
```

book_pages/chapter2/section2.2.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Section 2.2: Readability
2+
3+
### TypeScript enables editors to provide contextual documentation:
4+
5+
```ts
6+
'morol'.slice();
7+
8+
slice(start?: number, end?: number): string
9+
```
10+
The index to the beginning of the specified portion of stringObj.
11+
Returns a section of a string.
12+
13+
You'll never forget whether `String.prototype.slice`takes `(start, stop)` or `(start, length)` again!
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
/*
1+
# Section 2.3: Tooling
22

33
TypeScript allows editors to perform automated refactors which are aware of the rules
44
of the languages.
55

6-
*/
7-
6+
```ts
87
let ans = 'morol';
98
{
109
let ans = (num: number) => {
@@ -16,8 +15,7 @@ let ans = 'morol';
1615
}
1716

1817
console.log(ans); // morol
18+
```
1919

20-
/*
21-
Here, for instance, Visual Studio Code is able to rename references to the inner ans without
22-
altering the outer ans. This would be difficult to do with a simple find/replace.
23-
*/
20+
Here, for instance, Visual Studio Code is able to rename references to the inner ans
21+
without altering the outer ans. This would be difficult to do with a simple find/replace.
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/*
2-
String literal types allow you to specify the exact value a string can have.
3-
*/
1+
# Section 3.1: String Literal Types
42

3+
### String literal types allow you to specify the exact value a string can have.
4+
5+
```ts
56
let myFavoritePet: "dog";
67
// console.log(myFavoritePet); // undefined
78

@@ -174,4 +175,5 @@ Cat-Rocky eats.
174175
Cat-Rocky walks.
175176
Cat-Rocky sleeps.
176177
-----------------
177-
*/
178+
*/
179+
```

0 commit comments

Comments
 (0)