Skip to content

Commit 9b4b9e7

Browse files
committed
build(): Add a dartanalyzer run to Travis. It is required.
1 parent 93fc4ff commit 9b4b9e7

File tree

9 files changed

+37
-26
lines changed

9 files changed

+37
-26
lines changed

docs/dart/writing-compatible-typescript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ Here's a list of gotchas to keep in mind when writing TypeScript code that will
4141
* **Default values need to be constants.** This mean that code like `function myFunction(arg1: string = callToSomething()) {}` will not compile.
4242
* **The const keyword must have a const value.** Because of that, we cannot do `const x = a + b;` even if the value of `x`, `a` and `b` will not change.
4343
* **Lambdas need to abide to the type required.** Meaning that if a function requires a function that takes one argument, the lambda cannot be `() => {}`. Use `_` for temporary parameters. This is notable in Promises.
44+
* **Dynamic return values fat arrows can't return non-primitive types without casting.** For example, a fat arrow that return a promise (or Future) generates a warning if using directly, like so: `promiseA.then(() => promiseB)`. In this case simply using a block works as expected; `promiseA.then(() => { return promiseB; })`.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"strip-ansi": "^3.0.0",
5252
"symlink-or-copy": "^1.0.1",
5353
"ts-node": "^0.5.5",
54-
"ts2dart": "^0.7.24",
54+
"ts2dart": "^0.7.25",
5555
"tslint": "^3.2.2",
5656
"typescript": "^1.7.5",
5757
"which": "^1.2.4"

scripts/ci/build-and-test.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ is_dart && pub install
1818

1919
wait_for_tunnel
2020
if is_dart; then
21-
# npm run dartanalyzer
22-
echo 'TODO(hans): Implement dartanalyzer'
21+
npm run dartanalyzer
2322
else
2423
karma start test/karma.conf.js --single-run --no-auto-watch --reporters='dots'
2524
fi

scripts/ci/dart_analyzer.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ import {detect} from '../../tools/build/dart';
55
const command = detect()['ANALYZER'];
66

77
analyze('dist/dart', command, true)
8-
.then(() => {
8+
.then((err) => {
9+
if (err) {
10+
throw err;
11+
}
912
console.log('Done.');
10-
}, (err) => {
13+
})
14+
.catch((err) => {
1115
console.error('Error:', err);
16+
process.exit(1);
1217
});

src/components/progress-circle/progress_circle.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import {beforeEach, ddescribe, expect, inject, it, TestComponentBuilder} from 'angular2/testing';
1+
import {inject, TestComponentBuilder} from 'angular2/testing';
2+
import {
3+
it,
4+
iit,
5+
describe,
6+
ddescribe,
7+
expect,
8+
beforeEach,
9+
} from '../../core/facade/testing';
210
import {Component, DebugElement} from 'angular2/core';
311
import {By} from 'angular2/platform/browser'
412
import {MdProgressCircle} from './progress_circle';

src/components/progress-circle/progress_circle.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ViewEncapsulation,
99
} from 'angular2/core';
1010
import {isPresent, CONST} from 'angular2/src/facade/lang';
11+
import {Math} from 'angular2/src/facade/math';
1112
import {OneOf} from '../../core/annotations/one-of';
1213

1314

@@ -42,26 +43,20 @@ export class MdProgressCircle {
4243
* Input:number, defaults to 0.
4344
* value_ is bound to the host as the attribute aria-valuenow.
4445
*/
46+
@HostBinding('attr.aria-valuenow')
4547
@Input('value')
4648
value_: number = 0;
47-
@HostBinding('attr.aria-valuenow')
48-
get _value() {
49-
return this.value_;
50-
}
5149

5250
/**
5351
* Mode of the progress circle
5452
*
5553
* Input must be one of the values from ProgressMode, defaults to 'determinate'.
5654
* mode is bound to the host as the attribute host.
5755
*/
56+
@HostBinding('attr.mode')
5857
@Input()
5958
@OneOf([ProgressMode.DETERMINATE, ProgressMode.INDETERMINATE])
6059
mode: string;
61-
@HostBinding('attr.mode')
62-
get _mode() {
63-
return this.mode;
64-
}
6560

6661

6762
/**
@@ -119,5 +114,8 @@ export class MdProgressCircle {
119114
changeDetection: ChangeDetectionStrategy.OnPush,
120115
})
121116
export class MdSpinner extends MdProgressCircle {
122-
mode: string = ProgressMode.INDETERMINATE;
117+
constructor() {
118+
super();
119+
this.mode = ProgressMode.INDETERMINATE;
120+
}
123121
}

src/components/sidenav/sidenav.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ export function main() {
138138
.then((_: any) => {
139139
expect(called).toBe(false);
140140
})
141-
.then((_: any) => promise)
142-
.then((_: any) => expect(called).toBe(true))
141+
.then((_: any) => { return promise; })
142+
.then((_: any) => { expect(called).toBe(true); })
143143
.then((_: any) => {
144144
// Close it now.
145145
called = false;
@@ -151,8 +151,8 @@ export function main() {
151151
.then((_: any) => {
152152
expect(called).toBe(false);
153153
})
154-
.then((_: any) => promise)
155-
.then((_: any) => expect(called).toBe(true))
154+
.then((_: any) => { return promise; })
155+
.then((_: any) => { expect(called).toBe(true); })
156156
.then((_: any) => { done(); });
157157
}, 8000);
158158

src/demo-app/demo-app.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {CardDemo} from './card/card-demo';
33
import {ButtonDemo} from './button/button-demo';
44
import {SidenavDemo} from './sidenav/sidenav-demo';
55
import {ProgressCircleDemo} from './progress-circle/progress-circle-demo';
6-
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
6+
import {Route, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
77
import {Dir} from '../directives/dir/dir';
88
import {MdButton} from '../components/button/button';
99

@@ -22,10 +22,10 @@ export class Home {}
2222
pipes: []
2323
})
2424
@RouteConfig([
25-
{path: '/', name: 'Home', component: Home, useAsDefault: true},
26-
{path: '/button', name: 'ButtonDemo', component: ButtonDemo},
27-
{path: '/card', name: 'CardDemo', component: CardDemo},
28-
{path: '/sidenav', name: 'SidenavDemo', component: SidenavDemo},
29-
{path: '/progress-circle', name: 'ProgressCircleDemo', component: ProgressCircleDemo},
25+
new Route({path: '/', name: 'Home', component: Home, useAsDefault: true}),
26+
new Route({path: '/button', name: 'ButtonDemo', component: ButtonDemo}),
27+
new Route({path: '/card', name: 'CardDemo', component: CardDemo}),
28+
new Route({path: '/sidenav', name: 'SidenavDemo', component: SidenavDemo}),
29+
new Route({path: '/progress-circle', name: 'ProgressCircleDemo', component: ProgressCircleDemo}),
3030
])
3131
export class DemoApp { }

tools/build/dart_analyzer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const tempFile = '_analyzer.dart';
2323
* @param command The command to use for dartanalyzer.
2424
* @param use_ddc Enable strong static type checking (see https://goo.gl/DqcBsw).
2525
*/
26-
export function analyze(dir: string, command: string, use_ddc: boolean = false): Promise<void> {
26+
export function analyze(dir: string, command: string, use_ddc: boolean = false): Promise<any> {
2727
var travisFoldEnd = travisFoldStart(`dartanalyzer-${use_ddc ? 'ddc' : ''}-${dir}`);
2828

2929
var pubspecContents = fs.readFileSync(path.join(dir, 'pubspec.yaml'));

0 commit comments

Comments
 (0)