Skip to content

Commit 9214cf7

Browse files
committed
feat(build): implement type definition manager for TypeScript
1 parent 64be6f1 commit 9214cf7

File tree

8 files changed

+33
-7
lines changed

8 files changed

+33
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/docs
44
/build
55
/coverage
6+
/typings
67
/.karma
78
/.protractor
89

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ language:
33
node_js:
44
- '5'
55
before_install:
6+
# Setup `Chrome` instance.
67
- export CHROME_BIN=chromium-browser
78
- export DISPLAY=:99.0
89
- sh -e /etc/init.d/xvfb start
10+
911
- npm install gulpjs/gulp-cli#4.0 -g
12+
- npm install typings -g
1013
install:
1114
- npm install
1215
before_script:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Light-weight and easy to use seed project for Angular 2 apps.
1111
- [Gulp 4](http://gulpjs.com/)
1212
- [Angular 2](https://angular.io/)
1313
- [TypeScript](http://www.typescriptlang.org/)
14+
- [Typings](https://github.com/typings/typings)
1415
- [Sass](http://sass-lang.com/)
1516
- [Karma](http://karma-runner.github.io/)
1617
- [Protractor](http://www.protractortest.org/)
@@ -20,7 +21,7 @@ Light-weight and easy to use seed project for Angular 2 apps.
2021
- **Development** and **production** environment targets.
2122
- **Unit** and **E2E** test samples.
2223
- **Code coverage** report with TypeScript mapping.
23-
- **TypeScript** linting, sourcemaps and transpilation (ES5).
24+
- **TypeScript** definition manager, linting, sourcemaps and transpilation (ES5).
2425
- **Sass** linting, sourcemaps and transpilation.
2526
- **TypeDoc** documentation generator.
2627
- **Change Log** generated based on Git metadata.

gulpfile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function scss() {
8787
}
8888

8989
function typedoc() {
90-
return gulp.src('src/scripts/**/*.ts')
90+
return gulp.src(['src/scripts/**/*.ts', 'typings/main.d.ts'])
9191
.pipe(plugins.typedoc({
9292
module: 'commonjs',
9393
target: 'es5',
@@ -102,7 +102,7 @@ var tsProject = plugins.typescript.createProject('tsconfig.json', {
102102
});
103103

104104
function ts() {
105-
var tsResult = gulp.src('src/scripts/**/*.ts')
105+
var tsResult = gulp.src(['src/scripts/**/*.ts', 'typings/main.d.ts'])
106106
.pipe(plugins.tslint())
107107
.pipe(plugins.tslint.report('verbose'))
108108
.pipe(plugins.preprocess({ context: env }))
@@ -164,7 +164,7 @@ function karmaTs(root) {
164164

165165
var caller = arguments.callee.caller.name;
166166

167-
var tsResult = gulp.src(path.join(root, '/**/*.ts'))
167+
var tsResult = gulp.src([path.join(root, '/**/*.ts'), 'typings/main.d.ts'])
168168
.pipe(plugins.preprocess({ context: env }))
169169
.pipe(plugins.inlineNg2Template({ useRelativePaths: true }))
170170
.pipe(plugins.sourcemaps.init())
@@ -210,7 +210,7 @@ var protractorTsProject = plugins.typescript.createProject('tsconfig.json', {
210210
});
211211

212212
function protractorTsSpec() {
213-
var tsResult = gulp.src('test/e2e/**/*.ts')
213+
var tsResult = gulp.src(['test/e2e/**/*.ts', 'typings/main.d.ts'])
214214
.pipe(plugins.typescript(protractorTsProject));
215215

216216
return tsResult.js

gulpfile.paths.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ let baseLibs = [
77
'node_modules/angular2/bundles/angular2-polyfills.js',
88
'node_modules/angular2/bundles/angular2.dev.js',
99
'node_modules/angular2/bundles/router.dev.js',
10-
'node_modules/angular2/bundles/http.dev.js'
10+
'node_modules/angular2/bundles/http.dev.js',
11+
'node_modules/lodash/index.js'
1112
];
1213

1314
module.exports = {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"version": "1.0.1",
99
"description": "Angular 2 Seed Project – TypeScript, Gulp, Karma, Protractor, Sass.",
1010
"scripts": {
11+
"postinstall": "typings install",
1112
"start": "gulp build serve",
1213
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -w"
1314
},
@@ -17,6 +18,7 @@
1718
"bootstrap": "4.0.0-alpha.2",
1819
"es6-promise": "3.0.2",
1920
"es6-shim": "0.33.3",
21+
"lodash": "3.10.1",
2022
"reflect-metadata": "0.1.2",
2123
"rxjs": "5.0.0-beta.0",
2224
"systemjs": "0.19.6",

src/scripts/about/about.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,15 @@ import {Component, View} from 'angular2/core';
66
@View({
77
templateUrl: './about.template.html'
88
})
9-
export class AboutComponent {}
9+
export class AboutComponent {
10+
constructor() {
11+
/**
12+
* This snippet shows how third-party libraries ie. Lodash can be consumed
13+
* using Typings - the type definition manager.
14+
*/
15+
let filtered: Array<number>;
16+
filtered = _.filter([0, 1, 2, 3], (number: number) => (number % 2 === 0));
17+
18+
console.log('filtered', filtered);
19+
}
20+
}

typings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dependencies": {},
3+
"devDependencies": {},
4+
"ambientDependencies": {
5+
"lodash": "github:DefinitelyTyped/DefinitelyTyped/lodash/lodash.d.ts#1469ae2d0c260c082517bfb971be8c14e2389fe5"
6+
}
7+
}

0 commit comments

Comments
 (0)