Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 6002389

Browse files
wardbellnaomiblack
authored andcommitted
Revise for alpha 38 and to confront the surprising complexity in Getting Started in TS
1 parent 6aedf70 commit 6002389

File tree

4 files changed

+57
-78
lines changed

4 files changed

+57
-78
lines changed

public/docs/_examples/gettingstarted/ts/README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

public/docs/_examples/gettingstarted/ts/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"author": "",
1111
"license": "ISC",
1212
"dependencies": {
13-
"angular2": "^2.0.0-alpha.37",
14-
"systemjs": "^0.19.2"
13+
"angular2": "2.0.0-alpha.38",
14+
"systemjs": "0.19.2"
1515
}
1616
}

public/docs/ts/latest/guide/gettingStarted.jade

Lines changed: 55 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,27 @@ include ../../../../_includes/_util-fns
2626
:markdown
2727
## Prerequisites
2828

29-
We'll need a base of tools for all of our application development. We'll only install these once starting with
30-
[**node** and **npm**](https://docs.npmjs.com/getting-started/installing-node "Installing Node.js and updating npm").
29+
We'll need a base of tools for our application development throughout this guide:
3130

32-
Now use npm in a terminal (or Windows/Linux command line) to install the **TypeScript compiler** globally
31+
- the **TypeScript compiler**
3332

34-
pre.prettyprint.lang-bash
35-
code npm install -g typescript
36-
37-
:markdown
38-
Use npm again to install the [**tsd package manager**](https://www.npmjs.com/package/tsd "TSD Package Manager")
39-
so we can download TypeScript type definitions files ("`.d.ts`" files)
40-
from the [DefinitelyTyped](http://definitelytyped.org/) repository.
33+
- the [**tsd package manager**](https://www.npmjs.com/package/tsd "TSD Package Manager") so we can access
34+
[TypeScript type definition files](http://definitelytyped.org/ "Definitely Typed") ("`.d.ts`" files).
4135

42-
pre.prettyprint.lang-bash
43-
code npm install -g tsd
36+
- **live-server**, a *static server* that runs our app in the browser and reloads the browser when any of the files change.
4437

45-
:markdown
46-
Install a node **static server** to serve our application.
47-
We'll use **live-server** for this example because it performs a live reload by default and it's
48-
fun to watch the browser update as we make changes.
38+
**Open** a terminal (or Windows/Linux command line) and issue the following `npm` command to install them all:
4939

5040
pre.prettyprint.lang-bash
51-
code npm install -g live-server
41+
code npm install -g typescript tsd live-server
5242

5343
.l-sub-section
5444
:markdown
55-
Our success depends upon installing compatible versions of these tools.
56-
Confirm your version numbers in a terminal window with these commands:
45+
We depend upon [**node** and **npm**](https://docs.npmjs.com/getting-started/installing-node "Installing Node.js and updating npm")
46+
to install packages such as these global tools.
47+
48+
We must be sure that we're installing Angular-compatible versions of these packages.
49+
Issue the following commands in that same terminal window to confirm that we have the appropriate versions:
5750
table
5851
tr
5952
th Command
@@ -118,26 +111,21 @@ include ../../../../_includes/_util-fns
118111
:markdown
119112
## Install npm packages
120113

121-
Our application will need some 3rd party JavaScript files:
114+
We need to install two JavaScript library packages:
122115

123116
>***angular.js***, the Angular 2 library.
124117

125-
>***system.js***, a third-party open-source library that adds module loading functionality to our browser.
126-
127-
>***traceur-runtime.js*** to transpile the TypeScript-generated JavaScript into the version of Javascript
128-
our browser understands (the version known as "ES5").
118+
>***system.js***, an open-source library that provides module loading.
129119

130120
We'll install these package with `npm` and create an npm **`package.json`** configuration file
131-
that to maintain future packages as our application evolves.
121+
to maintain them as our application evolves.
132122

133123
In a terminal window, go to the **root** folder and type:
134124
```
135125
npm init -y
136-
npm install --save [email protected].37 [email protected]
126+
npm i [email protected].38 [email protected] --save --save-exact
137127
```
138128

139-
`npm` produced a `node_modules` folder that holds these packages and other packages that *they* require.
140-
141129
The essence of our `package.json` should look like this:
142130
+makeJson('gettingstarted/ts/package.json', { paths: 'name, version, dependencies '})
143131

@@ -150,7 +138,6 @@ include ../../../../_includes/_util-fns
150138
We prefer writing TypeScript apps in editors that understand TypeScript,
151139
such as [Visual Studio Code](https://code.visualstudio.com/) and
152140
[Web Storm](https://www.jetbrains.com/webstorm/features/).
153-
154141
Such editors improve the development experience by checking type information and
155142
displaying API documentation ("intellisense") based on TypeScript definition files (`.d.ts`).
156143

@@ -174,16 +161,15 @@ include ../../../../_includes/_util-fns
174161

175162
### Add the TypeScript configuration file
176163

177-
We need to tell that editor how to interpret our TypeScript
178-
which we do with a configuration file named **`tsconfig.json`**.
179-
This configuration file also simplifies the TypeScript compilation command
180-
that we'll run very soon.
164+
We'll add a configuration file named **`tsconfig.json`**
165+
to tell the editor how to interpret our TypeScript code and
166+
to simplify the TypeScript compilation command that we'll run very soon.
181167

182168
**Change to the `src` folder and create a `tsconfig.json`** file with the following content:
183169
+makeJson('gettingstarted/ts/src/tsconfig.json', null, 'tsconfig.json')
184170

185171
:markdown
186-
Our project should now look like this:
172+
Our project folder structure should now look like this:
187173
```
188174
angular2-getting-started
189175
├── node_modules
@@ -199,24 +185,20 @@ include ../../../../_includes/_util-fns
199185
:markdown
200186
## Create an `index.html`
201187

202-
While in the **`src`** directory and
203-
add a new `index.html` file with the following HTML
188+
While in the **`src`** directory we
189+
add a new `index.html` file with the following content
204190

205-
+makeExample('gettingstarted/ts/src/index.html', null, 'index.html',
206-
{pnk: [/(angular2\.dev\.js)/, /(system\.src\.js)/, /(traceur-runtime\.js)/]})
191+
+makeExample('gettingstarted/ts/src/index.html', null, 'index.html')
207192

208193
.l-sub-section
209194
:markdown
210-
Notice in the `<head>` element that we're loading the scripts we installed earlier with npm.
211-
212-
There's an element called `<my-app>` in the `<body>`. This is a placeholder for the *root* of our
213-
application. Angular will display our application content here.
195+
We're loading the library scripts in the `<head>` element from the `node_modules`
196+
that we installed earlier with npm.
214197

215-
The final inline script first configures the **`system.js`** module loader and then tells it
216-
to import the JavaScript file named `app` in the `app/` folder.
198+
In the `<body>` is the app root element called `<my-app>` where Angular displays our application content.
217199

218-
Subsequent module imports are triggered by a cascade of `import` statements
219-
beginning within `app.ts` itself.
200+
The final inline script configures the **`system.js`** module loader and tells it
201+
to import the *application file* named `app` from within the *folder* named `app/`.
220202

221203
**`app.ts`** is our main application file. We haven't written it yet. Let's do so now.
222204

@@ -277,6 +259,8 @@ include ../../../../_includes/_util-fns
277259
:markdown
278260
## Confirm the final project and file structure
279261

262+
It should look like this
263+
280264
```
281265
angular2-getting-started
282266
├── node_modules
@@ -289,11 +273,6 @@ include ../../../../_includes/_util-fns
289273
│ ├── tsconfig.json
290274
└── package.json
291275
```
292-
Seems like overkill for such a trivial application.
293-
294-
We have ambitions. We aren't learning Angular to build "Hello, World". We intend
295-
to build great apps and we anticipate adding meat to these bones
296-
in the "Tour of Heroes" tutorial coming up very soon.
297276

298277
.l-main-section
299278
:markdown
@@ -331,7 +310,7 @@ include ../../../../_includes/_util-fns
331310
application message:
332311

333312
figure.image-display
334-
img(src='/resources/images/examples/setup-example1.png' alt="Example of Todo App")
313+
img(src='/resources/images/devguide/getting-started/my-first-app.png' alt="Output of getting started app")
335314

336315
:markdown
337316
### Make some changes
@@ -342,27 +321,35 @@ include ../../../../_includes/_util-fns
342321
The TypeScript compiler running in the first terminal window is watching our source code. It recompiles and produces
343322
the revised *app.js*. The *live-server* sees that change and reloads the browser.
344323

345-
Pretty nice!
346-
347324
.l-main-section
348325
:markdown
349-
## It's all a tree
326+
## Why so complicated?
327+
To display a single line of text we
328+
329+
* installed a bunch of unfamiliar tools
330+
* loaded a couple of libraries
331+
* wrote configuration files for both `npm` and TypeScript
332+
* configured something called `system.js` in our `index.html` and
333+
told it to import our main file
334+
* are compiling TypeScript in one terminal window and running the server in another
335+
336+
Perhaps we were expecting something simpler: an Angular library,
337+
our application script, and a little HTML. This is all a bit much for a "Hello, World" app.
350338

351-
We can think of Angular apps as a tree of components.
339+
**We have greater ambitions.**
352340

353-
The `AppComponent` that we've been talking about acts as the top
354-
level container - the root of the tree - for the rest of our application.
355-
There's nothing special about the `AppComponent` name and we can use whatever makes sense to us.
341+
We won't ask Angular to build "Hello, World".
342+
We are asking it to help us build sophisticated applications with sophisticated requirements.
343+
We're making strategic technology investments to reach our goals
356344

357-
We've pinned the root component to an element in the `index.html` file where our application will
358-
render its view. The element is called `<my-app>` but there is nothing special about this
359-
name either.
345+
* writing the app in TypeScript for team
346+
productivity and maintainability.
360347

361-
The *root component* loads the initial template for the application.
362-
That template could load other components such as menu bars, views, and forms
363-
that display information and respond to user gestures.
348+
* designing with modules that we can load features dynamically
349+
using the latest JavaScript `import` and `export` verbs.
364350

365-
And these components could load yet more components until the browser page became a deep tree
366-
of nested functionality.
351+
* running compiler and live-server commands that give us immediate feedback as we make changes.
367352

368-
We'll walk through examples of these scenarios in the following pages.
353+
The good news is that the overhead of setup is (mostly) behind us.
354+
We're about to build a small application that demonstrates the great things
355+
we can build with Angular 2. Join us on the [Tour of Heroes].

0 commit comments

Comments
 (0)