Skip to content

Commit

Permalink
feat(build): implement type definition manager for TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodenadai committed Jan 6, 2016
1 parent 64be6f1 commit 9214cf7
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/docs
/build
/coverage
/typings
/.karma
/.protractor

Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ language:
node_js:
- '5'
before_install:
# Setup `Chrome` instance.
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

- npm install gulpjs/gulp-cli#4.0 -g
- npm install typings -g
install:
- npm install
before_script:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Light-weight and easy to use seed project for Angular 2 apps.
- [Gulp 4](http://gulpjs.com/)
- [Angular 2](https://angular.io/)
- [TypeScript](http://www.typescriptlang.org/)
- [Typings](https://github.com/typings/typings)
- [Sass](http://sass-lang.com/)
- [Karma](http://karma-runner.github.io/)
- [Protractor](http://www.protractortest.org/)
Expand All @@ -20,7 +21,7 @@ Light-weight and easy to use seed project for Angular 2 apps.
- **Development** and **production** environment targets.
- **Unit** and **E2E** test samples.
- **Code coverage** report with TypeScript mapping.
- **TypeScript** linting, sourcemaps and transpilation (ES5).
- **TypeScript** definition manager, linting, sourcemaps and transpilation (ES5).
- **Sass** linting, sourcemaps and transpilation.
- **TypeDoc** documentation generator.
- **Change Log** generated based on Git metadata.
Expand Down
8 changes: 4 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function scss() {
}

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

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

var caller = arguments.callee.caller.name;

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

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

return tsResult.js
Expand Down
3 changes: 2 additions & 1 deletion gulpfile.paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ let baseLibs = [
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/angular2.dev.js',
'node_modules/angular2/bundles/router.dev.js',
'node_modules/angular2/bundles/http.dev.js'
'node_modules/angular2/bundles/http.dev.js',
'node_modules/lodash/index.js'
];

module.exports = {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"version": "1.0.1",
"description": "Angular 2 Seed Project – TypeScript, Gulp, Karma, Protractor, Sass.",
"scripts": {
"postinstall": "typings install",
"start": "gulp build serve",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -w"
},
Expand All @@ -17,6 +18,7 @@
"bootstrap": "4.0.0-alpha.2",
"es6-promise": "3.0.2",
"es6-shim": "0.33.3",
"lodash": "3.10.1",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"systemjs": "0.19.6",
Expand Down
13 changes: 12 additions & 1 deletion src/scripts/about/about.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ import {Component, View} from 'angular2/core';
@View({
templateUrl: './about.template.html'
})
export class AboutComponent {}
export class AboutComponent {
constructor() {
/**
* This snippet shows how third-party libraries ie. Lodash can be consumed
* using Typings - the type definition manager.
*/
let filtered: Array<number>;
filtered = _.filter([0, 1, 2, 3], (number: number) => (number % 2 === 0));

console.log('filtered', filtered);
}
}
7 changes: 7 additions & 0 deletions typings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {},
"devDependencies": {},
"ambientDependencies": {
"lodash": "github:DefinitelyTyped/DefinitelyTyped/lodash/lodash.d.ts#1469ae2d0c260c082517bfb971be8c14e2389fe5"
}
}

0 comments on commit 9214cf7

Please sign in to comment.