fix(compiler): make code easier to type check

These changes are needed for the G3 sync as we use a different version/settings of Typescript than on Github.

closes #9701
This commit is contained in:
Tobias Bosch 2016-06-29 10:26:45 -07:00
parent e81dea695c
commit 51d4c9dcbd
3 changed files with 15 additions and 10 deletions

View File

@ -9,6 +9,7 @@
import {Injectable, ViewEncapsulation} from '@angular/core'; import {Injectable, ViewEncapsulation} from '@angular/core';
import {PromiseWrapper} from '../src/facade/async'; import {PromiseWrapper} from '../src/facade/async';
import {MapWrapper} from '../src/facade/collection';
import {BaseException} from '../src/facade/exceptions'; import {BaseException} from '../src/facade/exceptions';
import {isBlank, isPresent} from '../src/facade/lang'; import {isBlank, isPresent} from '../src/facade/lang';
@ -173,7 +174,7 @@ export class DirectiveNormalizer {
return this._loadMissingExternalStylesheets( return this._loadMissingExternalStylesheets(
stylesheet.styleUrls, loadedStylesheets); stylesheet.styleUrls, loadedStylesheets);
}))) })))
.then((_) => Array.from(loadedStylesheets.values())); .then((_) => MapWrapper.values(loadedStylesheets));
} }
normalizeStylesheet(stylesheet: CompileStylesheetMetadata): CompileStylesheetMetadata { normalizeStylesheet(stylesheet: CompileStylesheetMetadata): CompileStylesheetMetadata {

View File

@ -129,10 +129,12 @@ export class OfflineCompiler {
function _resolveViewStatements(compileResult: ViewCompileResult): o.Statement[] { function _resolveViewStatements(compileResult: ViewCompileResult): o.Statement[] {
compileResult.dependencies.forEach((dep) => { compileResult.dependencies.forEach((dep) => {
if (dep instanceof ViewFactoryDependency) { if (dep instanceof ViewFactoryDependency) {
dep.placeholder.moduleUrl = _ngfactoryModuleUrl(dep.comp); let vfd = <ViewFactoryDependency>dep;
vfd.placeholder.moduleUrl = _ngfactoryModuleUrl(vfd.comp);
} else if (dep instanceof ComponentFactoryDependency) { } else if (dep instanceof ComponentFactoryDependency) {
dep.placeholder.name = _componentFactoryName(dep.comp); let cfd = <ComponentFactoryDependency>dep;
dep.placeholder.moduleUrl = _ngfactoryModuleUrl(dep.comp); cfd.placeholder.name = _componentFactoryName(cfd.comp);
cfd.placeholder.moduleUrl = _ngfactoryModuleUrl(cfd.comp);
} }
}); });
return compileResult.statements; return compileResult.statements;

View File

@ -172,13 +172,15 @@ export class RuntimeCompiler implements ComponentResolver, Compiler {
var depTemplates = compileResult.dependencies.map((dep) => { var depTemplates = compileResult.dependencies.map((dep) => {
let depTemplate: CompiledTemplate; let depTemplate: CompiledTemplate;
if (dep instanceof ViewFactoryDependency) { if (dep instanceof ViewFactoryDependency) {
depTemplate = this._getCompiledTemplate(dep.comp.runtime); let vfd = <ViewFactoryDependency>dep;
dep.placeholder.runtime = depTemplate.proxyViewFactory; depTemplate = this._getCompiledTemplate(vfd.comp.runtime);
dep.placeholder.name = `viewFactory_${dep.comp.name}`; vfd.placeholder.runtime = depTemplate.proxyViewFactory;
vfd.placeholder.name = `viewFactory_${vfd.comp.name}`;
} else if (dep instanceof ComponentFactoryDependency) { } else if (dep instanceof ComponentFactoryDependency) {
depTemplate = this._getCompiledHostTemplate(dep.comp.runtime); let cfd = <ComponentFactoryDependency>dep;
dep.placeholder.runtime = depTemplate.proxyComponentFactory; depTemplate = this._getCompiledHostTemplate(cfd.comp.runtime);
dep.placeholder.name = `compFactory_${dep.comp.name}`; cfd.placeholder.runtime = depTemplate.proxyComponentFactory;
cfd.placeholder.name = `compFactory_${cfd.comp.name}`;
} }
return depTemplate; return depTemplate;
}); });