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 #6693
This commit is contained in:
Yegor Jbanov
2016-01-25 17:57:29 -08:00
committed by Yegor
parent c4c43f5a77
commit db87baeb98
10 changed files with 65 additions and 44 deletions

View File

@ -112,6 +112,10 @@ class TemplatePreparseVisitor implements HtmlAstVisitor {
case PreparsedElementType.STYLESHEET:
this.styleUrls.push(preparsedElement.hrefAttr);
break;
default:
// DDC reports this as error. See:
// https://github.com/dart-lang/dev_compiler/issues/428
break;
}
if (preparsedElement.nonBindable) {
this.ngNonBindableStackCount++;

View File

@ -107,9 +107,8 @@ export var BLANK_ROUTE_DATA = new RouteData();
* ```
*/
export abstract class Instruction {
public component: ComponentInstruction;
public child: Instruction;
public auxInstruction: {[key: string]: Instruction} = {};
constructor(public component: ComponentInstruction, public child: Instruction,
public auxInstruction: {[key: string]: Instruction}) {}
get urlPath(): string { return isPresent(this.component) ? this.component.urlPath : ''; }
@ -210,9 +209,9 @@ export abstract class Instruction {
* a resolved instruction has an outlet instruction for itself, but maybe not for...
*/
export class ResolvedInstruction extends Instruction {
constructor(public component: ComponentInstruction, public child: Instruction,
public auxInstruction: {[key: string]: Instruction}) {
super();
constructor(component: ComponentInstruction, child: Instruction,
auxInstruction: {[key: string]: Instruction}) {
super(component, child, auxInstruction);
}
resolveComponent(): Promise<ComponentInstruction> {
@ -225,7 +224,9 @@ export class ResolvedInstruction extends Instruction {
* Represents a resolved default route
*/
export class DefaultInstruction extends Instruction {
constructor(public component: ComponentInstruction, public child: DefaultInstruction) { super(); }
constructor(component: ComponentInstruction, child: DefaultInstruction) {
super(component, child, {});
}
resolveComponent(): Promise<ComponentInstruction> {
return PromiseWrapper.resolve(this.component);
@ -244,7 +245,7 @@ export class DefaultInstruction extends Instruction {
export class UnresolvedInstruction extends Instruction {
constructor(private _resolver: () => Promise<Instruction>, private _urlPath: string = '',
private _urlParams: string[] = CONST_EXPR([])) {
super();
super(null, null, {});
}
get urlPath(): string {

View File

@ -202,12 +202,12 @@ export class Router {
return this._settleInstruction(instruction)
.then((_) => this._routerCanReuse(instruction))
.then((_) => this._canActivate(instruction))
.then((result) => {
.then((result: boolean) => {
if (!result) {
return false;
}
return this._routerCanDeactivate(instruction)
.then((result) => {
.then((result: boolean) => {
if (result) {
return this.commit(instruction, _skipLocationChange)
.then((_) => {

View File

@ -9,29 +9,32 @@ import 'package:angular2/src/facade/lang.dart';
import 'package:angular2/src/facade/exceptions.dart';
class GenericMessageBus implements MessageBus {
MessageBusSink sink;
MessageBusSource source;
final MessageBusSink _sink;
final MessageBusSource _source;
MessageBusSink get sink => _sink;
MessageBusSource get source => _source;
GenericMessageBus(MessageBusSink sink, MessageBusSource source)
: sink = sink,
source = source;
: _sink = sink,
_source = source;
void attachToZone(NgZone zone) {
sink.attachToZone(zone);
source.attachToZone(zone);
_sink.attachToZone(zone);
_source.attachToZone(zone);
}
void initChannel(String channel, [bool runInZone = true]) {
sink.initChannel(channel, runInZone);
source.initChannel(channel, runInZone);
_sink.initChannel(channel, runInZone);
_source.initChannel(channel, runInZone);
}
EventEmitter from(String channel) {
return source.from(channel);
return _source.from(channel);
}
EventEmitter to(String channel) {
return sink.to(channel);
return _sink.to(channel);
}
}