X Tutup
Skip to content

Commit db87bae

Browse files
committed
fix(ddc): router, compiler, web worker fixes for DDC
Also enable DDC checks across all non-web worker playground apps. We are now down to 2 DDC errors across all of them. The remaining two need to be fixed in package:analyzer, not in angular. BREAKING CHANGE: - there's a chance of breakage as router's Instruction constructor signature changed. Closes angular#6693
1 parent c4c43f5 commit db87bae

File tree

10 files changed

+65
-44
lines changed

10 files changed

+65
-44
lines changed

modules/angular2/src/compiler/template_normalizer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ class TemplatePreparseVisitor implements HtmlAstVisitor {
112112
case PreparsedElementType.STYLESHEET:
113113
this.styleUrls.push(preparsedElement.hrefAttr);
114114
break;
115+
default:
116+
// DDC reports this as error. See:
117+
// https://github.com/dart-lang/dev_compiler/issues/428
118+
break;
115119
}
116120
if (preparsedElement.nonBindable) {
117121
this.ngNonBindableStackCount++;

modules/angular2/src/router/instruction.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,8 @@ export var BLANK_ROUTE_DATA = new RouteData();
107107
* ```
108108
*/
109109
export abstract class Instruction {
110-
public component: ComponentInstruction;
111-
public child: Instruction;
112-
public auxInstruction: {[key: string]: Instruction} = {};
110+
constructor(public component: ComponentInstruction, public child: Instruction,
111+
public auxInstruction: {[key: string]: Instruction}) {}
113112

114113
get urlPath(): string { return isPresent(this.component) ? this.component.urlPath : ''; }
115114

@@ -210,9 +209,9 @@ export abstract class Instruction {
210209
* a resolved instruction has an outlet instruction for itself, but maybe not for...
211210
*/
212211
export class ResolvedInstruction extends Instruction {
213-
constructor(public component: ComponentInstruction, public child: Instruction,
214-
public auxInstruction: {[key: string]: Instruction}) {
215-
super();
212+
constructor(component: ComponentInstruction, child: Instruction,
213+
auxInstruction: {[key: string]: Instruction}) {
214+
super(component, child, auxInstruction);
216215
}
217216

218217
resolveComponent(): Promise<ComponentInstruction> {
@@ -225,7 +224,9 @@ export class ResolvedInstruction extends Instruction {
225224
* Represents a resolved default route
226225
*/
227226
export class DefaultInstruction extends Instruction {
228-
constructor(public component: ComponentInstruction, public child: DefaultInstruction) { super(); }
227+
constructor(component: ComponentInstruction, child: DefaultInstruction) {
228+
super(component, child, {});
229+
}
229230

230231
resolveComponent(): Promise<ComponentInstruction> {
231232
return PromiseWrapper.resolve(this.component);
@@ -244,7 +245,7 @@ export class DefaultInstruction extends Instruction {
244245
export class UnresolvedInstruction extends Instruction {
245246
constructor(private _resolver: () => Promise<Instruction>, private _urlPath: string = '',
246247
private _urlParams: string[] = CONST_EXPR([])) {
247-
super();
248+
super(null, null, {});
248249
}
249250

250251
get urlPath(): string {

modules/angular2/src/router/router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ export class Router {
202202
return this._settleInstruction(instruction)
203203
.then((_) => this._routerCanReuse(instruction))
204204
.then((_) => this._canActivate(instruction))
205-
.then((result) => {
205+
.then((result: boolean) => {
206206
if (!result) {
207207
return false;
208208
}
209209
return this._routerCanDeactivate(instruction)
210-
.then((result) => {
210+
.then((result: boolean) => {
211211
if (result) {
212212
return this.commit(instruction, _skipLocationChange)
213213
.then((_) => {

modules/angular2/src/web_workers/shared/generic_message_bus.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,32 @@ import 'package:angular2/src/facade/lang.dart';
99
import 'package:angular2/src/facade/exceptions.dart';
1010

1111
class GenericMessageBus implements MessageBus {
12-
MessageBusSink sink;
13-
MessageBusSource source;
12+
final MessageBusSink _sink;
13+
final MessageBusSource _source;
14+
15+
MessageBusSink get sink => _sink;
16+
MessageBusSource get source => _source;
1417

1518
GenericMessageBus(MessageBusSink sink, MessageBusSource source)
16-
: sink = sink,
17-
source = source;
19+
: _sink = sink,
20+
_source = source;
1821

1922
void attachToZone(NgZone zone) {
20-
sink.attachToZone(zone);
21-
source.attachToZone(zone);
23+
_sink.attachToZone(zone);
24+
_source.attachToZone(zone);
2225
}
2326

2427
void initChannel(String channel, [bool runInZone = true]) {
25-
sink.initChannel(channel, runInZone);
26-
source.initChannel(channel, runInZone);
28+
_sink.initChannel(channel, runInZone);
29+
_source.initChannel(channel, runInZone);
2730
}
2831

2932
EventEmitter from(String channel) {
30-
return source.from(channel);
33+
return _source.from(channel);
3134
}
3235

3336
EventEmitter to(String channel) {
34-
return sink.to(channel);
37+
return _sink.to(channel);
3538
}
3639
}
3740

modules/playground/src/hash_routing/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import {
99
LocationStrategy
1010
} from 'angular2/router';
1111

12-
import {reflector} from 'angular2/src/core/reflection/reflection';
13-
import {ReflectionCapabilities} from 'angular2/src/core/reflection/reflection_capabilities';
1412

1513
@Component({selector: 'hello-cmp', template: `hello`})
1614
class HelloCmp {
@@ -46,7 +44,6 @@ class AppCmp {
4644

4745

4846
export function main() {
49-
reflector.reflectionCapabilities = new ReflectionCapabilities();
5047
bootstrap(AppCmp,
5148
[ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: HashLocationStrategy})]);
5249
}

modules/playground/src/material/button/demo_app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h1>Button demo</h1>
3434
</p>
3535

3636
<section>
37-
<form (submit)="submit('form submit')">
37+
<form (submit)="submit('form submit', $event)">
3838
<button mdButton>SUBMIT</button>
3939
<button>Native button</button>
4040
</form>

modules/playground/src/observable_models/common.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class RawEntity extends Object
7272
}
7373

7474
@override
75-
operator [](String key) {
75+
operator [](untypedKey) {
76+
var key = untypedKey as String;
7677
if (!key.contains('.')) {
7778
return _data[key];
7879
}
@@ -102,7 +103,8 @@ class RawEntity extends Object
102103
set(String name, dynamic value) { this[name] = value; }
103104

104105
@override
105-
remove(String key) {
106+
remove(untypedKey) {
107+
var key = untypedKey as String;
106108
if (!key.contains('.')) {
107109
return _data.remove(key);
108110
}

modules/playground/src/relative_assets/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import {bootstrap} from 'angular2/bootstrap';
2-
import {reflector} from 'angular2/src/core/reflection/reflection';
3-
import {ReflectionCapabilities} from 'angular2/src/core/reflection/reflection_capabilities';
42

53
import {Renderer, ElementRef, Component, Directive, Injectable} from 'angular2/core';
64
import {MyCmp} from './my_cmp/my_cmp';
75

86
export function main() {
9-
reflector.reflectionCapabilities = new ReflectionCapabilities();
107
bootstrap(RelativeApp);
118
}
129

modules/playground/src/routing/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import {provide} from 'angular2/core';
33
import {bootstrap} from 'angular2/bootstrap';
44
import {ROUTER_PROVIDERS, HashLocationStrategy, LocationStrategy} from 'angular2/router';
55

6-
import {reflector} from 'angular2/src/core/reflection/reflection';
7-
import {ReflectionCapabilities} from 'angular2/src/core/reflection/reflection_capabilities';
8-
96
export function main() {
10-
reflector.reflectionCapabilities = new ReflectionCapabilities();
117
bootstrap(InboxApp,
128
[ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: HashLocationStrategy})]);
139
}

scripts/ci/build_dart_experimental.sh

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ source $SCRIPT_DIR/env_dart.sh
1111
cd $SCRIPT_DIR/../..
1212

1313
# Variables
14-
DDC_WARNING_CAP="180"
14+
DDC_TOTAL_WARNING_CAP="1000"
15+
DDC_TOTAL_ERROR_CAP="2"
1516
DDC_DIR=`pwd`/tmp/dev_compiler
1617
DDC_VERSION="0.1.14"
1718

@@ -25,6 +26,7 @@ git clone https://github.com/dart-lang/dev_compiler.git tmp/dev_compiler
2526

2627
# Convert TypeScript to Dart
2728
./node_modules/.bin/gulp build/packages.dart
29+
./node_modules/.bin/gulp build.dart.material.css
2830
./node_modules/.bin/gulp build/pubspec.dart
2931
node ./scripts/ci/dart_experimental/pubspec_for_ddc.js \
3032
--pubspec-file=dist/dart/playground/pubspec.yaml
@@ -36,7 +38,32 @@ cd build/web
3638
LOG_FILE="analyzer.log"
3739
set +e
3840
$DART_SDK/bin/dart $DDC_DIR/bin/dartdevc.dart \
39-
--dart-sdk=$DART_SDK_LIB_SEARCH_PATH -o out src/hello_world/index.dart \
41+
--dart-sdk=$DART_SDK_LIB_SEARCH_PATH -o out \
42+
src/animate/index.dart \
43+
src/async/index.dart \
44+
src/gestures/index.dart \
45+
src/hash_routing/index.dart \
46+
src/hello_world/index.dart \
47+
src/key_events/index.dart \
48+
src/material/button/index.dart \
49+
src/material/checkbox/index.dart \
50+
src/material/dialog/index.dart \
51+
src/material/grid_list/index.dart \
52+
src/material/input/index.dart \
53+
src/material/progress-linear/index.dart \
54+
src/material/radio/index.dart \
55+
src/material/switcher/index.dart \
56+
src/model_driven_forms/index.dart \
57+
src/observable_models/index.dart \
58+
src/order_management/index.dart \
59+
src/person_management/index.dart \
60+
src/relative_assets/index.dart \
61+
src/routing/index.dart \
62+
src/sourcemap/index.dart \
63+
src/svg/index.dart \
64+
src/template_driven_forms/index.dart \
65+
src/todo/index.dart \
66+
src/zippy_component/index.dart \
4067
>$LOG_FILE
4168
EXIT_CODE=`echo $?`
4269
set -e
@@ -53,22 +80,16 @@ fi
5380
cat $LOG_FILE
5481
WARNING_COUNT=`cat $LOG_FILE | wc -l | sed -e 's/^[[:space:]]*//'`
5582

56-
if [[ "$WARNING_COUNT" -gt "$DDC_WARNING_CAP" ]]
83+
if [[ "$WARNING_COUNT" -gt "$DDC_TOTAL_WARNING_CAP" ]]
5784
then
5885
echo "Too many warnings: $WARNING_COUNT"
5986
exit 1
6087
else
6188
echo "Warning count ok"
6289
fi
6390

64-
function countWarnings {
65-
local GREP_PATTERN=$1
66-
local COUNT=`cat $LOG_FILE | grep -E '$GREP_PATTERN' | wc -l | sed -e 's/^[[:space:]]*//'`
67-
echo $COUNT
68-
}
69-
70-
SEVERE_ANGULAR_COUNT=$(countWarnings '^severe.*package:angular2')
71-
if [[ "$SEVERE_ANGULAR_COUNT" -gt "0" ]]
91+
ERROR_COUNT=`cat $LOG_FILE | grep -E '^severe.*' | wc -l | sed -e 's/^[[:space:]]*//'`
92+
if [[ "$ERROR_COUNT" -gt "$DDC_TOTAL_ERROR_CAP" ]]
7293
then
7394
echo "Found severe errors in angular2 package"
7495
exit 1

0 commit comments

Comments
 (0)
X Tutup