chore: update to @types (#1872)

* chore: update examples to @types
* fix toh-6 aot and add types link
This commit is contained in:
Filipe Silva 2016-10-21 01:01:16 +01:00 committed by Ward Bell
parent 75f37b76eb
commit 0d49fecd30
41 changed files with 85 additions and 199 deletions

1
.gitignore vendored
View File

@ -2,7 +2,6 @@ node_modules
_temp _temp
bower_components bower_components
jspm_packages jspm_packages
typings
**/packages **/packages
build build
pubspec.lock pubspec.lock

View File

@ -89,7 +89,7 @@ take the following extra steps to prepare the environment:
1. cd back up to `angular.io` root: `cd ../../..` 1. cd back up to `angular.io` root: `cd ../../..`
1. run `gulp add-example-boilerplate` (elevate to admin on Windows) 1. run `gulp add-example-boilerplate` (elevate to admin on Windows)
to copy canonical files to the sample directories and create symlinks there for node_modules and typings. to copy canonical files to the sample directories and create symlinks there for node_modules.
Now cd into any particular sample's language directory (e.g., `public/docs/_examples/quickstart/ts`) and try: Now cd into any particular sample's language directory (e.g., `public/docs/_examples/quickstart/ts`) and try:
- `npm start` to simultaneously compile-with-watch and serve-in-browser-with-watch - `npm start` to simultaneously compile-with-watch and serve-in-browser-with-watch

View File

@ -85,7 +85,7 @@ var _apiShredOptionsForDart = {
logLevel: _dgeniLogLevel logLevel: _dgeniLogLevel
}; };
var _excludePatterns = ['**/node_modules/**', '**/typings/**', '**/packages/**']; var _excludePatterns = ['**/node_modules/**', '**/packages/**'];
var _excludeMatchers = _excludePatterns.map(function(excludePattern){ var _excludeMatchers = _excludePatterns.map(function(excludePattern){
return new Minimatch(excludePattern) return new Minimatch(excludePattern)
@ -461,13 +461,6 @@ gulp.task('add-example-boilerplate', function(done) {
fsUtils.addSymlink(realPath, linkPath); fsUtils.addSymlink(realPath, linkPath);
}); });
realPath = path.join(EXAMPLES_PATH, '/typings');
var typingsPaths = excludeDartPaths(getTypingsPaths(EXAMPLES_PATH));
typingsPaths.forEach(function(linkPath) {
gutil.log("symlinking " + linkPath + ' -> ' + realPath)
fsUtils.addSymlink(realPath, linkPath);
});
return buildStyles(copyExampleBoilerplate, done); return buildStyles(copyExampleBoilerplate, done);
}); });
@ -530,11 +523,6 @@ gulp.task('remove-example-boilerplate', function() {
fsUtils.removeSymlink(linkPath); fsUtils.removeSymlink(linkPath);
}); });
var typingsPaths = getTypingsPaths(EXAMPLES_PATH);
typingsPaths.forEach(function(linkPath) {
fsUtils.removeSymlink(linkPath);
});
deleteExampleBoilerPlate(); deleteExampleBoilerPlate();
}); });
@ -818,7 +806,7 @@ gulp.task('_harp-compile', function() {
gulp.task('_shred-devguide-examples', ['_shred-clean-devguide', '_copy-example-boilerplate'], function() { gulp.task('_shred-devguide-examples', ['_shred-clean-devguide', '_copy-example-boilerplate'], function() {
// Split big shredding task into partials 2016-06-14 // Split big shredding task into partials 2016-06-14
var examplePaths = globby.sync(EXAMPLES_PATH+'/*/', {ignore: ['/node_modules', 'typings/']}); var examplePaths = globby.sync(EXAMPLES_PATH+'/*/', {ignore: ['/node_modules']});
var promise = Promise.resolve(true); var promise = Promise.resolve(true);
examplePaths.forEach(function (examplePath) { examplePaths.forEach(function (examplePath) {
promise = promise.then(() => docShredder.shredSingleExampleDir(_devguideShredOptions, examplePath)); promise = promise.then(() => docShredder.shredSingleExampleDir(_devguideShredOptions, examplePath));
@ -877,8 +865,6 @@ gulp.task('lint', function() {
'!./public/docs/_examples/**/ts-snippets/*.ts', '!./public/docs/_examples/**/ts-snippets/*.ts',
'!./public/docs/_examples/style-guide/ts/**/*.avoid.ts', '!./public/docs/_examples/style-guide/ts/**/*.avoid.ts',
'!./public/docs/_examples/**/node_modules/**/*', '!./public/docs/_examples/**/node_modules/**/*',
'!./public/docs/_examples/**/typings/**/*',
'!./public/docs/_examples/**/typings-ng1/**/*',
'!./public/docs/_examples/**/build/**/*', '!./public/docs/_examples/**/build/**/*',
// temporary until codelyzer is fixed mgechev/codelyzer#60 // temporary until codelyzer is fixed mgechev/codelyzer#60
'!./public/docs/_examples/animations/ts/app/hero.service.ts' '!./public/docs/_examples/animations/ts/app/hero.service.ts'
@ -1140,13 +1126,6 @@ function getNodeModulesPaths(basePath) {
return paths; return paths;
} }
function getTypingsPaths(basePath) {
var paths = getExamplePaths(basePath).map(function(examplePath) {
return path.join(examplePath, "/typings");
});
return paths;
}
function getExamplePaths(basePath, includeBase) { function getExamplePaths(basePath, includeBase) {
// includeBase defaults to false // includeBase defaults to false
return getPaths(basePath, _exampleConfigFilename, includeBase); return getPaths(basePath, _exampleConfigFilename, includeBase);
@ -1281,7 +1260,7 @@ function devGuideExamplesWatch(shredOptions, postShredAction, focus) {
// removed this version because gulp.watch has the same glob issue that dgeni has. // removed this version because gulp.watch has the same glob issue that dgeni has.
// var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*'); // var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*');
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) { // gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
var ignoreThese = [ '**/node_modules/**', '**/_fragments/**', '**/dist/**', '**/typings/**', var ignoreThese = [ '**/node_modules/**', '**/_fragments/**', '**/dist/**',
'**/dart/.pub/**', '**/dart/build/**', '**/dart/packages/**']; '**/dart/.pub/**', '**/dart/build/**', '**/dart/packages/**'];
ignoreThese = ignoreThese.concat(_exampleBoilerplateFiles.map((file) => `public/docs/_examples/*/*/${file}`)); ignoreThese = ignoreThese.concat(_exampleBoilerplateFiles.map((file) => `public/docs/_examples/*/*/${file}`));
var files = globby.sync( [includePattern], { ignore: ignoreThese }); var files = globby.sync( [includePattern], { ignore: ignoreThese });

View File

@ -7,7 +7,6 @@ package.json
systemjs.config.js systemjs.config.js
tsconfig.json tsconfig.json
tslint.json tslint.json
typings.json
wallaby.js wallaby.js
_test-output _test-output

View File

@ -10,7 +10,6 @@
"http-server:cli": "http-server dist/", "http-server:cli": "http-server dist/",
"lite": "lite-server", "lite": "lite-server",
"lite:aot": "lite-server -c aot/bs-config.json", "lite:aot": "lite-server -c aot/bs-config.json",
"postinstall": "typings install",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"", "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"tsc": "tsc", "tsc": "tsc",
"tsc:w": "tsc -w", "tsc:w": "tsc -w",

View File

@ -9,7 +9,9 @@
"removeComments": false, "removeComments": false,
"noImplicitAny": true, "noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true, "suppressImplicitAnyIndexErrors": true,
"types": [] "typeRoots": [
"../../node_modules/@types/"
]
}, },
"exclude": [ "exclude": [
"node_modules/*", "node_modules/*",

View File

@ -8,14 +8,12 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"removeComments": false, "removeComments": false,
"noImplicitAny": true, "noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true, "suppressImplicitAnyIndexErrors": true
"types": []
}, },
"files": [ "files": [
"app/app.module.ts", "app/app.module.ts",
"app/main.ts", "app/main.ts"
"./typings/index.d.ts"
], ],
"angularCompilerOptions": { "angularCompilerOptions": {

View File

@ -8,7 +8,10 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"removeComments": false, "removeComments": false,
"noImplicitAny": true, "noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true "suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"node_modules/@types"
]
}, },
"compileOnSave": true "compileOnSave": true
} }

View File

@ -18,7 +18,6 @@
/libpeerconnection.log /libpeerconnection.log
npm-debug.log npm-debug.log
testem.log testem.log
/typings
# e2e # e2e
/e2e/*.js /e2e/*.js

View File

@ -1 +0,0 @@
/// <reference path="../typings/index.d.ts" />

View File

@ -3,8 +3,6 @@
"version": "1.0.0", "version": "1.0.0",
"description": "Master package.json, the superset of all dependencies for all of the _example package.json files. See _boilerplate/package.json for example npm scripts.", "description": "Master package.json, the superset of all dependencies for all of the _example package.json files. See _boilerplate/package.json for example npm scripts.",
"scripts": { "scripts": {
"postinstall": "typings install",
"typings": "typings",
"protractor": "protractor", "protractor": "protractor",
"webdriver:update": "webdriver-manager update" "webdriver:update": "webdriver-manager update"
}, },
@ -42,8 +40,16 @@
"zone.js": "^0.6.25" "zone.js": "^0.6.25"
}, },
"devDependencies": { "devDependencies": {
"@types/angular": "^1.5.15", "@types/angular": "^1.5.16",
"@types/jasmine": "^2.2.34", "@types/angular-animate": "^1.5.5",
"@types/angular-cookies": "^1.4.2",
"@types/angular-mocks": "^1.5.5",
"@types/angular-resource": "^1.5.6",
"@types/angular-route": "^1.3.2",
"@types/angular-sanitize": "^1.3.3",
"@types/core-js": "^0.9.34",
"@types/jasmine": "^2.5.35",
"@types/node": "^6.0.45",
"@types/selenium-webdriver": "^2.53.32", "@types/selenium-webdriver": "^2.53.32",
"angular2-template-loader": "^0.4.0", "angular2-template-loader": "^0.4.0",
"awesome-typescript-loader": "^2.2.4", "awesome-typescript-loader": "^2.2.4",
@ -76,11 +82,9 @@
"rollup-plugin-commonjs": "^4.1.0", "rollup-plugin-commonjs": "^4.1.0",
"source-map-explorer": "^1.3.2", "source-map-explorer": "^1.3.2",
"style-loader": "^0.13.1", "style-loader": "^0.13.1",
"ts-loader": "^0.8.2",
"ts-node": "^1.3.0", "ts-node": "^1.3.0",
"tslint": "^3.15.1", "tslint": "^3.15.1",
"typescript": "^2.0.3", "typescript": "^2.0.3",
"typings": "^1.4.0",
"webpack": "^1.13.0", "webpack": "^1.13.0",
"webpack-dev-server": "^1.14.1", "webpack-dev-server": "^1.14.1",
"webpack-merge": "^0.14.0" "webpack-merge": "^0.14.0"

View File

@ -4,10 +4,8 @@
"scripts": { "scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ", "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"lite": "lite-server", "lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc", "tsc": "tsc",
"tsc:w": "tsc -w", "tsc:w": "tsc -w"
"typings": "typings"
}, },
"licenses": [ "licenses": [
{ {
@ -35,9 +33,10 @@
"zone.js": "^0.6.25" "zone.js": "^0.6.25"
}, },
"devDependencies": { "devDependencies": {
"@types/core-js": "^0.9.34",
"@types/node": "^6.0.45",
"concurrently": "^3.0.0", "concurrently": "^3.0.0",
"lite-server": "^2.2.2", "lite-server": "^2.2.2",
"typescript": "^2.0.3", "typescript": "^2.0.3"
"typings":"^1.4.0"
} }
} }

View File

@ -1,7 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160909174046"
}
}

View File

@ -9,13 +9,14 @@
"removeComments": false, "removeComments": false,
"noImplicitAny": true, "noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true, "suppressImplicitAnyIndexErrors": true,
"types": [] "typeRoots": [
"../../node_modules/@types/"
]
}, },
"files": [ "files": [
"app/app.module.ts", "app/app.module.ts",
"app/main-aot.ts", "app/main-aot.ts"
"typings/index.d.ts"
], ],
"angularCompilerOptions": { "angularCompilerOptions": {

View File

@ -1,5 +1,6 @@
// #docregion import-adapter // #docregion import-adapter
import { UpgradeAdapter } from '@angular/upgrade'; import { UpgradeAdapter } from '@angular/upgrade';
declare var angular: any;
import { AppModule } from './app.module'; import { AppModule } from './app.module';
// #enddocregion import-adapter // #enddocregion import-adapter

View File

@ -1,5 +1,6 @@
// #docregion // #docregion
import { Phone, PhoneData } from '../core/phone/phone.service'; import { Phone, PhoneData } from '../core/phone/phone.service';
declare var angular: any;
class PhoneDetailController { class PhoneDetailController {
phone: PhoneData; phone: PhoneData;

View File

@ -1,5 +1,6 @@
// #docregion // #docregion
import { Phone, PhoneData } from '../core/phone/phone.service'; import { Phone, PhoneData } from '../core/phone/phone.service';
declare var angular: any;
class PhoneListController { class PhoneListController {
phones: PhoneData[]; phones: PhoneData[];

View File

@ -5,8 +5,7 @@
"scripts": { "scripts": {
"start": "webpack-dev-server --inline --progress --port 8080", "start": "webpack-dev-server --inline --progress --port 8080",
"test": "karma start", "test": "karma start",
"build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail", "build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail"
"postinstall": "typings install"
}, },
"licenses": [ "licenses": [
{ {
@ -28,6 +27,9 @@
"zone.js": "^0.6.25" "zone.js": "^0.6.25"
}, },
"devDependencies": { "devDependencies": {
"@types/core-js": "^0.9.34",
"@types/node": "^6.0.45",
"@types/jasmine": "^2.5.35",
"angular2-template-loader": "^0.4.0", "angular2-template-loader": "^0.4.0",
"awesome-typescript-loader": "^2.2.4", "awesome-typescript-loader": "^2.2.4",
"css-loader": "^0.23.1", "css-loader": "^0.23.1",
@ -47,7 +49,6 @@
"rimraf": "^2.5.2", "rimraf": "^2.5.2",
"style-loader": "^0.13.1", "style-loader": "^0.13.1",
"typescript": "^2.0.2", "typescript": "^2.0.2",
"typings": "^1.3.2",
"webpack": "^1.13.0", "webpack": "^1.13.0",
"webpack-dev-server": "^1.14.1", "webpack-dev-server": "^1.14.1",
"webpack-merge": "^0.14.0" "webpack-merge": "^0.14.0"

View File

@ -1,7 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160909174046"
}
}

View File

@ -624,11 +624,9 @@ figure.image-display
.file hero-form.component.js .file hero-form.component.js
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
Heres the final version of the source: Heres the final version of the source:

View File

@ -581,13 +581,11 @@ block project-file-structure
.file app.module.ts .file app.module.ts
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
Here are the file contents: Here are the file contents:
@ -599,7 +597,6 @@ block project-files
quickstart/ts/index.html, quickstart/ts/index.html,
quickstart/ts/package.1.json, quickstart/ts/package.1.json,
quickstart/ts/tsconfig.1.json, quickstart/ts/tsconfig.1.json,
quickstart/ts/typings.1.json,
quickstart/ts/styles.css, quickstart/ts/styles.css,
quickstart/ts/systemjs.config.1.js` quickstart/ts/systemjs.config.1.js`
, ,
@ -610,7 +607,6 @@ block project-files
index.html, index.html,
package.json, package.json,
tsconfig.json, tsconfig.json,
typings.json,
styles.css (excerpt), styles.css (excerpt),
systemjs.config.js`) systemjs.config.js`)

View File

@ -64,13 +64,11 @@ block intro-file-tree
.file main.ts .file main.ts
.file mock-heroes.ts .file mock-heroes.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
block keep-app-running block keep-app-running
:marked :marked
@ -883,13 +881,11 @@ block file-tree-end
.file main.ts .file main.ts
.file mock-heroes.ts .file mock-heroes.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
.l-main-section .l-main-section
:marked :marked

View File

@ -559,13 +559,11 @@ block filetree
.file main.ts .file main.ts
.file in-memory-data.service.ts (new) .file in-memory-data.service.ts (new)
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
.l-main-section .l-main-section
:marked :marked

View File

@ -88,7 +88,6 @@ h2#copy Step 4: Copy the QuickStart files into the ASP.NET project folder
* index.html * index.html
* package.json * package.json
* tsconfig.json * tsconfig.json
* typings.json
.l-main-section .l-main-section
h2#restore Step 5: Restore the required packages h2#restore Step 5: Restore the required packages

View File

@ -706,11 +706,9 @@ figure.image-display
.file hero-form.component.ts .file hero-form.component.ts
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
Heres the final version of the source: Heres the final version of the source:

View File

@ -152,10 +152,10 @@ a(id="dev-dependencies")
with excellent support for Angular apps that use routing. with excellent support for Angular apps that use routing.
***[typescript](https://www.npmjs.com/package/typescript)*** - ***[typescript](https://www.npmjs.com/package/typescript)*** -
The TypeScript language server, including the *tsc* TypeScript compiler. the TypeScript language server, including the *tsc* TypeScript compiler.
***[typings](https://www.npmjs.com/package/typings)*** - A manager for TypeScript definition files. ***@types/\**** - TypeScript definition files.
Read more about it in the [TypeScript Configuration](typescript-configuration.html#typings) page. Learn more about it in the [TypeScript Configuration](typescript-configuration.html#typings) chapter.
.l-main-section .l-main-section
a(id="why-peer-dependencies") a(id="why-peer-dependencies")

View File

@ -546,12 +546,10 @@ h3#router-directives <i>Router Directives</i>
.file hero-list.component.ts .file hero-list.component.ts
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
Here are the files discussed in this milestone Here are the files discussed in this milestone
@ -1233,12 +1231,10 @@ h3#merge-hero-routes Import hero module into AppModule
.file crisis-list.component.ts .file crisis-list.component.ts
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
<a id="heroes-app-code"></a> <a id="heroes-app-code"></a>
### The Heroes App code ### The Heroes App code

View File

@ -78,16 +78,13 @@ a(id="typings")
Many libraries&mdash;jQuery, Jasmine, and Lodash among them&mdash;do *not* include `d.ts` files in their npm packages. Many libraries&mdash;jQuery, Jasmine, and Lodash among them&mdash;do *not* include `d.ts` files in their npm packages.
Fortunately, either their authors or community contributors have created separate `d.ts` files for these libraries and Fortunately, either their authors or community contributors have created separate `d.ts` files for these libraries and
published them in well-known locations. published them in well-known locations.
The *typings* tool can find and fetch these files for you.
After installing the [typings](https://github.com/typings/typings/blob/master/README.md) tool We can install these typings via `npm` using the
with npm (it's listed among the *devDependencies* in the `package.json`), add an npm script (`postinstall`) [`@types/*` scoped package](http://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html)
to run that tool automatically, after *npm* installation finishes. and Typescript (starting at 2.0) will automatically recognize them.
+makeJson('quickstart/ts/package.1.json', {paths: 'scripts.postinstall'}, 'package.json (postinstall)')(format=".")
:marked For instance, to install typings for `jasmine` we could do `npm install @types/jasmine --save-dev`.
This *typings* tool command, `typings install`, installs the `d.ts` files into the **typings** folder.
You created a `typings.json` file in the [QuickStart](../quickstart.html):
+makeJson('quickstart/ts/typings.1.json', null, 'typings.json')(format=".")
:marked :marked
QuickStart identified three *typings* (`d.ts`) files: QuickStart identified three *typings* (`d.ts`) files:
@ -96,27 +93,7 @@ a(id="typings")
* [jasmine](http://jasmine.github.io/) typings for the Jasmine test framework * [jasmine](http://jasmine.github.io/) typings for the Jasmine test framework
* [node](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts) for code that references objects in the *nodejs* environment; * [node](https://www.npmjs.com/package/@types/node) for code that references objects in the *nodejs* environment;
You can view an example in the [webpack](./webpack.html) page. You can view an example in the [webpack](./webpack.html) page.
QuickStart doesn't require these typings but many of the samples do. QuickStart doesn't require these typings but many of the samples do.
You can also run the *typings* tool yourself.
If the `postInstall` command fails to (re)install the typings files, run the following command to do so.
code-example(format="").
npm run typings install
:marked
Run this command to list the installed typings files:
code-example(format="").
npm run typings list
:marked
The following command installs or updates the typings file for the Jasmine test library from the *DefinitelyTyped* repository,
and updates the `typings.json` file so you receive it automatically the next time you install typings.
code-example(format="").
npm run typings -- install dt~jasmine --save --global
.l-sub-section
:marked
The [&ndash;&ndash; option](https://docs.npmjs.com/cli/run-script) tells npm to pass all arguments to the right of `--` to the *typings* command.
Read about the features of the *typings* tool at its [site on github](https://github.com/typings/typings/blob/master/README.md).

View File

@ -875,34 +875,26 @@ figure
of NPM. We'll install all new dependencies using NPM, and will eventually be of NPM. We'll install all new dependencies using NPM, and will eventually be
able to remove Bower from the project. able to remove Bower from the project.
Let's begin by installing TypeScript to the project. While we're at it, let's also Let's begin by installing TypeScript to the project.
install the [Typings type definition manager](https://github.com/typings/typings).
It will allow us to install type definitions for libraries that don't come with
prepackaged types.
code-example(format=""). code-example(format="").
npm i typescript typings --save-dev npm i typescript --save-dev
:marked :marked
Let's also add run scripts for the `tsc` TypeScript compiler and the `typings` Let's also add run scripts for the `tsc` TypeScript compiler to `package.json`:
tool to `package.json`:
+makeJson('upgrade-phonecat-1-typescript/ts/package.json', {paths: 'scripts.tsc, scripts.tsc:w, scripts.typings'}, 'package.json') +makeJson('upgrade-phonecat-1-typescript/ts/package.json', {paths: 'scripts.tsc, scripts.tsc:w'}, 'package.json')
:marked :marked
We can now use Typings to install type definitions for the existing libraries that We can now install type definitions for the existing libraries that
we're using: Angular 1 and the Jasmine unit test framework. we're using but that don't come with prepackaged types: Angular 1 and the
Jasmine unit test framework.
code-example(format=""). code-example(format="").
npm run typings install dt~jquery dt~angular dt~angular-route \ npm install @types/jasmine @types/angular @types/angular-animate @types/angular-cookies @types/angular-mocks @types/angular-resource @types/angular-route @types/angular-sanitize --save-dev
dt~angular-resource dt~angular-mocks dt~angular-animate \
dt~jasmine -- --save --global
:marked :marked
This will add these typings into a `typings.json` configuration file as well as
download them into the `typings directory`.
We should also configure the TypeScript compiler so that it can understand our We should also configure the TypeScript compiler so that it can understand our
project. We'll add a `tsconfig.json` file to the project directory, just like we do project. We'll add a `tsconfig.json` file to the project directory, just like we do
in the [Quickstart](../quickstart.html). It instructs the TypeScript compiler how in the [Quickstart](../quickstart.html). It instructs the TypeScript compiler how
@ -968,8 +960,8 @@ code-example(format="").
.l-sub-section .l-sub-section
:marked :marked
The [Angular 1.x type definitions](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/angularjs) The [Angular 1.x type definitions](https://www.npmjs.com/package/@types/angular)
we installed with Typings are not officially maintained by the Angular team, we installed are not officially maintained by the Angular team,
but are quite comprehensive. It is possible to make an Angular 1.x application but are quite comprehensive. It is possible to make an Angular 1.x application
fully type-annotated with the help of these definitions. fully type-annotated with the help of these definitions.
@ -1037,14 +1029,12 @@ code-example(format="").
[Quickstart](../quickstart.html) guide and get the following configurations from there: [Quickstart](../quickstart.html) guide and get the following configurations from there:
* Add Angular 2 and the other new dependencies to `package.json` * Add Angular 2 and the other new dependencies to `package.json`
* Add the new typings into `typings.json`
* The SystemJS configuration file `systemjs.config.js` to the project root directory. * The SystemJS configuration file `systemjs.config.js` to the project root directory.
Once these are done, run: Once these are done, run:
code-example(format=""). code-example(format="").
npm install npm install
npm run typings install
:marked :marked
We can soon load Angular 2 dependencies into the application via `index.html`, We can soon load Angular 2 dependencies into the application via `index.html`,
@ -1110,6 +1100,18 @@ code-example(format="").
+makeExample('upgrade-phonecat-2-hybrid/ts/app/main.ts', 'import-adapter', 'app/main.ts') +makeExample('upgrade-phonecat-2-hybrid/ts/app/main.ts', 'import-adapter', 'app/main.ts')
.l-sub-section
:marked
### Why declare _angular_ as _any_?
A strongly typed `angular` reference to Angular 1 would be great.
But we can't import its <a href="https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#support-for-umd-module-definitions" target="_blank">UMD typings</a>
library, `@types/angular`, without also importing Angular 1 itself via `import * as angular from 'angular'`.
Angular 1 is currently loaded by a script tag in `index.html` and
switching to an ES6 import at this time is not worth the considerable effort.
Instead we declare `angular` as an untyped `any` to avoid typing errors.
:marked :marked
We can then make an adapter by instantiating the class: We can then make an adapter by instantiating the class:
@ -1216,7 +1218,6 @@ code-example(format="").
+makeExample('upgrade-phonecat-2-hybrid/ts/app/phone-detail/phone-detail.component.ng1.ts', null, 'app/phone-detail/phone-detail.component.ts') +makeExample('upgrade-phonecat-2-hybrid/ts/app/phone-detail/phone-detail.component.ng1.ts', null, 'app/phone-detail/phone-detail.component.ts')
:marked :marked
What we have here are two Angular 1 components using an Angular 2 service! What we have here are two Angular 1 components using an Angular 2 service!
The components don't need to be aware of this, though the fact that the The components don't need to be aware of this, though the fact that the
@ -1497,12 +1498,7 @@ code-example(format="").
we still need are for Jasmine and Angular 2 polyfills. we still need are for Jasmine and Angular 2 polyfills.
code-example(format=""). code-example(format="").
npm run typings uninstall jquery -- --save --global npm uninstall @types/angular --save-dev
npm run typings uninstall angular -- --save --global
npm run typings uninstall angular-route -- --save --global
npm run typings uninstall angular-resource -- --save --global
npm run typings uninstall angular-mocks -- --save --global
npm run typings uninstall angular-animate -- --save --global
:marked :marked
Finally, from `index.html`, remove all references to Finally, from `index.html`, remove all references to

View File

@ -115,7 +115,7 @@ a(id="loaders")
:marked :marked
... it applies the `test` RegEx patterns. When a pattern matches the filename, Webpack processes the file with the associated loader. ... it applies the `test` RegEx patterns. When a pattern matches the filename, Webpack processes the file with the associated loader.
The first `import` file matches the `.ts` pattern so Webpack processes it with the `ts` (TypeScript) loader. The first `import` file matches the `.ts` pattern so Webpack processes it with the `awesome-typescript-loader`.
The imported file doesn't match the second pattern so its loader is ignored. The imported file doesn't match the second pattern so its loader is ignored.
The second `import` matches the second `.css` pattern for which we have *two* loaders chained by the (!) character. The second `import` matches the second `.css` pattern for which we have *two* loaders chained by the (!) character.
@ -152,14 +152,12 @@ code-example(format="").
+makeTabs( +makeTabs(
`webpack/ts/package.webpack.json, `webpack/ts/package.webpack.json,
webpack/ts/typings.1.json,
webpack/ts/tsconfig.1.json, webpack/ts/tsconfig.1.json,
webpack/ts/webpack.config.js, webpack/ts/webpack.config.js,
webpack/ts/karma.webpack.conf.js, webpack/ts/karma.webpack.conf.js,
webpack/ts/config/helpers.js`, webpack/ts/config/helpers.js`,
null, null,
`package.json, `package.json,
typings.json,
tsconfig.json, tsconfig.json,
webpack.config.js, webpack.config.js,
karma.conf.js, karma.conf.js,
@ -172,7 +170,7 @@ code-example(format="").
Learn about the `package.json` in the [npm packages](../guide/npm-packages.html) chapter. Learn about the `package.json` in the [npm packages](../guide/npm-packages.html) chapter.
We require packages for Webpack use in addition to the ones listed in that chapter. We require packages for Webpack use in addition to the ones listed in that chapter.
Learn about `tsconfig.json` and `typings.json` in the [Typescript configuration](../guide/typescript-configuration.html) chapter. Learn about `tsconfig.json` in the [Typescript configuration](../guide/typescript-configuration.html) chapter.
:marked :marked
Open a terminal/console window and install the *npm* packages with `npm install`. Open a terminal/console window and install the *npm* packages with `npm install`.
@ -232,7 +230,7 @@ a(id="common-configuration")
+makeExample('webpack/ts/config/webpack.common.js', 'loaders', 'config/webpack.common.js')(format=".") +makeExample('webpack/ts/config/webpack.common.js', 'loaders', 'config/webpack.common.js')(format=".")
:marked :marked
* ts - a loader to transpile our Typescript code to ES5, guided by the `tsconfig.json` file * awesome-typescript-loader - a loader to transpile our Typescript code to ES5, guided by the `tsconfig.json` file
* angular2-template-loader - loads angular components' template and styles * angular2-template-loader - loads angular components' template and styles
* html - for component templates * html - for component templates
* images/fonts - Images and fonts are bundled as well. * images/fonts - Images and fonts are bundled as well.

View File

@ -95,9 +95,6 @@ block package-and-config-files
li. li.
#[b tsconfig.json] defines how the TypeScript compiler generates JavaScript from the project's #[b tsconfig.json] defines how the TypeScript compiler generates JavaScript from the project's
files. files.
li.
#[b typings.json] provides additional definition files for libraries that the TypeScript
compiler doesn't natively recognize.
li. li.
#[b systemjs.config.js] provides information to a module loader about where to find #[b systemjs.config.js] provides information to a module loader about where to find
application modules, and registers all the necessary packages. It also application modules, and registers all the necessary packages. It also
@ -111,12 +108,10 @@ block package-and-config-files
+makeTabs(` +makeTabs(`
quickstart/ts/package.1.json, quickstart/ts/package.1.json,
quickstart/ts/tsconfig.1.json, quickstart/ts/tsconfig.1.json,
quickstart/ts/typings.1.json,
quickstart/ts/systemjs.config.1.js quickstart/ts/systemjs.config.1.js
`, '', ` `, '', `
package.json, package.json,
tsconfig.json, tsconfig.json,
typings.json,
systemjs.config.js systemjs.config.js
`) `)
@ -153,18 +148,9 @@ block install-packages
.file angular-quickstart .file angular-quickstart
.children .children
.file node_modules ... .file node_modules ...
.file typings ...
.file package.json .file package.json
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked
If the `typings` folder doesn't show up after running `npm install`, you'll need to install it manually with the command:
code-example(language="sh" class="code-shell").
npm run typings install
:marked :marked
You're now ready to write some code! You're now ready to write some code!
@ -206,7 +192,6 @@ block install-packages
[`HttpModule`](../latest/api/http/index/HttpModule-class.html). These are introduced in the [`HttpModule`](../latest/api/http/index/HttpModule-class.html). These are introduced in the
[Tour of Heroes Tutorial](./tutorial/). [Tour of Heroes Tutorial](./tutorial/).
.l-main-section .l-main-section
h1#root-component Step !{step++}: Create a component and add it to your application h1#root-component Step !{step++}: Create a component and add it to your application
:marked :marked
@ -370,13 +355,11 @@ block project-file-structure
.file app.module.ts .file app.module.ts
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
To see the file contents, open the <live-example></live-example>. To see the file contents, open the <live-example></live-example>.

View File

@ -23,13 +23,11 @@ include ../_quickstart_repo
.file app.module.ts .file app.module.ts
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
## Keep the app transpiling and running ## Keep the app transpiling and running
We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing

View File

@ -28,13 +28,11 @@ include ../_util-fns
.file app.module.ts .file app.module.ts
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
### Keep the app transpiling and running ### Keep the app transpiling and running
We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing

View File

@ -20,13 +20,11 @@ include ../_util-fns
.file app.module.ts .file app.module.ts
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
### Keep the app transpiling and running ### Keep the app transpiling and running
We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing
@ -213,11 +211,9 @@ code-example(format=".")
.file hero-detail.component.ts .file hero-detail.component.ts
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
Here are the code files we discussed in this chapter. Here are the code files we discussed in this chapter.

View File

@ -34,13 +34,11 @@ include ../_util-fns
.file hero-detail.component.ts .file hero-detail.component.ts
.file main.ts .file main.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
### Keep the app transpiling and running ### Keep the app transpiling and running
@ -316,13 +314,11 @@ a#child-component
.file main.ts .file main.ts
.file mock-heroes.ts .file mock-heroes.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
:marked :marked
Here are the code files we discussed in this chapter. Here are the code files we discussed in this chapter.

View File

@ -64,13 +64,11 @@ block intro-file-tree
.file main.ts .file main.ts
.file mock-heroes.ts .file mock-heroes.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
block keep-app-running block keep-app-running
:marked :marked
@ -925,13 +923,11 @@ block file-tree-end
.file main.ts .file main.ts
.file mock-heroes.ts .file mock-heroes.ts
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
.l-main-section .l-main-section
:marked :marked

View File

@ -564,13 +564,11 @@ block filetree
.file main.ts .file main.ts
.file in-memory-data.service.ts (new) .file in-memory-data.service.ts (new)
.file node_modules ... .file node_modules ...
.file typings ...
.file index.html .file index.html
.file package.json .file package.json
.file styles.css .file styles.css
.file systemjs.config.js .file systemjs.config.js
.file tsconfig.json .file tsconfig.json
.file typings.json
.l-main-section .l-main-section
:marked :marked

View File

@ -4,7 +4,7 @@ var del = require('del');
var Dgeni = require('dgeni'); var Dgeni = require('dgeni');
var _ = require('lodash'); var _ = require('lodash');
var globby = require('globby'); var globby = require('globby');
var ignoreDirs = ['**/node_modules/**', '**/dist/**', '**/typings/**']; var ignoreDirs = ['**/node_modules/**', '**/dist/**'];
var _getLogLevel = function (options) { return options.logLevel || 'info'; } var _getLogLevel = function (options) { return options.logLevel || 'info'; }
@ -138,7 +138,7 @@ function createShredExamplePackage(shredOptions) {
readFilesProcessor.sourceFiles = [ { readFilesProcessor.sourceFiles = [ {
// Process all candidate files in `src` and its subfolders ... // Process all candidate files in `src` and its subfolders ...
include: includeFiles , include: includeFiles ,
exclude: [ '**/node_modules/**', '**/dist/**', '**/typings/**', '**/packages/**', '**/dart/build/**'], exclude: [ '**/node_modules/**', '**/dist/**', '**/packages/**', '**/dart/build/**'],
// When calculating the relative path to these files use this as the base path. // When calculating the relative path to these files use this as the base path.
// So `src/foo/bar.js` will have relative path of `foo/bar.js` // So `src/foo/bar.js` will have relative path of `foo/bar.js`
basePath: options.examplesDir basePath: options.examplesDir
@ -190,7 +190,7 @@ function createShredJadePackage(shredOptions) {
readFilesProcessor.sourceFiles = [ { readFilesProcessor.sourceFiles = [ {
// Process all candidate files in `src` and its subfolders ... // Process all candidate files in `src` and its subfolders ...
include: includeFiles , include: includeFiles ,
exclude: [ '**/node_modules/**', '**/typings/**', '**/packages/**', '**/dart/build/**', '**/_code-examples.jade'], exclude: [ '**/node_modules/**', '**/packages/**', '**/dart/build/**', '**/_code-examples.jade'],
// When calculating the relative path to these files use this as the base path. // When calculating the relative path to these files use this as the base path.
// So `src/foo/bar.js` will have relative path of `foo/bar.js` // So `src/foo/bar.js` will have relative path of `foo/bar.js`
basePath: options.jadeDir basePath: options.jadeDir
@ -244,7 +244,7 @@ var createShredMapPackage = function(mapOptions) {
readFilesProcessor.sourceFiles = [ { readFilesProcessor.sourceFiles = [ {
// Process all candidate files in `src` and its subfolders ... // Process all candidate files in `src` and its subfolders ...
include: includeFiles, include: includeFiles,
exclude: ['**/node_modules/**', '**/typings/**', '**/packages/**', '**/dart/build/**'], exclude: ['**/node_modules/**', '**/packages/**', '**/dart/build/**'],
// When calculating the relative path to these files use this as the base path. // When calculating the relative path to these files use this as the base path.
// So `src/foo/bar.js` will have relative path of `foo/bar.js` // So `src/foo/bar.js` will have relative path of `foo/bar.js`
basePath: options.jadeDir basePath: options.jadeDir

View File

@ -255,10 +255,8 @@ class PlunkerBuilder {
} }
}); });
// var defaultExcludes = [ '!**/node_modules/**','!**/typings/**','!**/tsconfig.json', '!**/*plnkr.json', '!**/*plnkr.html', '!**/*plnkr.no-link.html' ]; // var defaultExcludes = [ '!**/node_modules/**','!**/tsconfig.json', '!**/*plnkr.json', '!**/*plnkr.html', '!**/*plnkr.no-link.html' ];
var defaultExcludes = [ var defaultExcludes = [
'!**/typings/**',
'!**/typings.json',
'!**/tsconfig.json', '!**/tsconfig.json',
'!**/*plnkr.*', '!**/*plnkr.*',
'!**/package.json', '!**/package.json',