From 96ae348648a2b19cd4018c858d780731e463ea40 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Thu, 28 Apr 2016 21:58:51 -0700 Subject: [PATCH] chore(build): fix formatting and tests Closes #8098 --- gulpfile.js | 4 ++-- .../forms/directives/radio_control_value_accessor.ts | 2 +- modules/angular2/src/compiler/static_reflector.ts | 7 ++----- modules/angular2/test/compiler/static_reflector_spec.ts | 8 ++++---- modules/playground/src/hello_world/index.ts | 6 ++---- .../src/web_workers/kitchen_sink/index_common.ts | 2 -- tools/compiler_cli/src/reflector_host.ts | 4 ++-- tools/metadata/test/evaluator.spec.ts | 8 +++++--- tools/public_api_guard/public_api_spec.ts | 3 ++- 9 files changed, 20 insertions(+), 24 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 2475b6255d..93cb0b70c7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -483,8 +483,8 @@ function runTsc(project, done) { } gulp.task('test.js', function(done) { - runSequence('test.unit.tools/ci', 'test.transpiler.unittest', 'test.unit.js/ci', - 'test.unit.cjs/ci', 'test.compiler_cli', 'test.typings', 'check-public-api', + runSequence('test.compiler_cli', 'test.unit.tools/ci', 'test.transpiler.unittest', + 'test.unit.js/ci', 'test.unit.cjs/ci', 'test.typings', 'check-public-api', sequenceComplete(done)); }); diff --git a/modules/angular2/src/common/forms/directives/radio_control_value_accessor.ts b/modules/angular2/src/common/forms/directives/radio_control_value_accessor.ts index 51eaf74367..d9e39c4a75 100644 --- a/modules/angular2/src/common/forms/directives/radio_control_value_accessor.ts +++ b/modules/angular2/src/common/forms/directives/radio_control_value_accessor.ts @@ -20,7 +20,7 @@ import {NgControl} from 'angular2/src/common/forms/directives/ng_control'; import {CONST_EXPR, looseIdentical, isPresent} from 'angular2/src/facade/lang'; import {ListWrapper} from 'angular2/src/facade/collection'; -export const RADIO_VALUE_ACCESSOR = CONST_EXPR(new Provider( +export const RADIO_VALUE_ACCESSOR = CONST_EXPR(new Provider( NG_VALUE_ACCESSOR, {useExisting: forwardRef(() => RadioControlValueAccessor), multi: true})); diff --git a/modules/angular2/src/compiler/static_reflector.ts b/modules/angular2/src/compiler/static_reflector.ts index 1e97b81ece..09e59619c2 100644 --- a/modules/angular2/src/compiler/static_reflector.ts +++ b/modules/angular2/src/compiler/static_reflector.ts @@ -70,7 +70,7 @@ export interface StaticReflectorHost { * * This token is unique for a moduleId and name and can be used as a hash table key. */ -export class StaticSymbol { +export class StaticSymbol implements ModuleContext { constructor(public moduleId: string, public filePath: string, public name: string) {} } @@ -336,7 +336,7 @@ export class StaticReflector implements ReflectorReader { if (isClassMetadata(declarationValue)) { result = staticSymbol; } else { - const newModuleContext = + let newModuleContext = new ModuleContext(staticSymbol.moduleId, staticSymbol.filePath); result = _this.simplify(newModuleContext, declarationValue, crossModules); } @@ -382,9 +382,6 @@ export class StaticReflector implements ReflectorReader { } private getTypeMetadata(type: StaticSymbol): {[key: string]: any} { - if (!(type instanceof StaticSymbol)) { - throw new Error('not static type'); - } let moduleMetadata = this.getModuleMetadata(type.filePath); let result = moduleMetadata['metadata'][type.name]; if (!isPresent(result)) { diff --git a/modules/angular2/test/compiler/static_reflector_spec.ts b/modules/angular2/test/compiler/static_reflector_spec.ts index c1e0f8884f..5bfca15b5e 100644 --- a/modules/angular2/test/compiler/static_reflector_spec.ts +++ b/modules/angular2/test/compiler/static_reflector_spec.ts @@ -234,13 +234,13 @@ export function main() { }); it('should simplify a module reference across modules', () => { - expect(crossModuleSimplify({moduleId: '', filePath: '/src/cases'}, + expect(crossModuleSimplify(new ModuleContext('', '/src/cases'), ({__symbolic: "reference", module: "./extern", name: "s"}))) .toEqual("s"); }); it('should simplify a module reference without crossing modules', () => { - expect(singleModuleSimplify({moduleId: '', filePath: '/src/cases'}, + expect(singleModuleSimplify(new ModuleContext('', '/src/cases'), ({__symbolic: "reference", module: "./extern", name: "s"}))) .toEqual(host.getStaticSymbol('', '/src/extern.d.ts', 's')); }); @@ -261,7 +261,7 @@ class MockReflectorHost implements StaticReflectorHost { } // In tests, assume that symbols are not re-exported - findDeclaration(modulePath: string, symbolName: string, containingFile: string): StaticSymbol { + findDeclaration(modulePath: string, symbolName: string, containingFile?: string): StaticSymbol { function splitPath(path: string): string[] { return path.split(/\/|\\/g); } function resolvePath(pathParts: string[]): string { @@ -294,7 +294,7 @@ class MockReflectorHost implements StaticReflectorHost { if (modulePath.indexOf('.') === 0) { return this.getStaticSymbol(`mod/${symbolName}`, pathTo(containingFile, modulePath) + '.d.ts', - symbolName); + symbolName); } return this.getStaticSymbol(`mod/${symbolName}`, '/tmp/' + modulePath + '.d.ts', symbolName); } diff --git a/modules/playground/src/hello_world/index.ts b/modules/playground/src/hello_world/index.ts index 37aef121f1..a21a4e2bcf 100644 --- a/modules/playground/src/hello_world/index.ts +++ b/modules/playground/src/hello_world/index.ts @@ -14,14 +14,14 @@ export function main() { // A service available to the Injector, used by the HelloCmp component. @Injectable() -class GreetingService { +export class GreetingService { greeting: string = 'hello'; } // Directives are light-weight. They don't allow new // expression contexts (use @Component for those needs). @Directive({selector: '[red]'}) -class RedDec { +export class RedDec { // ElementRef is always injectable and it wraps the element on which the // directive was found by the compiler. constructor(el: ElementRef, renderer: Renderer) { @@ -34,8 +34,6 @@ class RedDec { // ShadowDom.(http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/) // - Directive - add behavior to existing elements. -// @Component is AtScript syntax to annotate the HelloCmp class as an Angular -// 2.0 component. @Component({ // The Selector prop tells Angular on which elements to instantiate this // class. The syntax supported is a basic subset of CSS selectors, for example diff --git a/modules/playground/src/web_workers/kitchen_sink/index_common.ts b/modules/playground/src/web_workers/kitchen_sink/index_common.ts index 06d59d3081..b2009ea0b5 100644 --- a/modules/playground/src/web_workers/kitchen_sink/index_common.ts +++ b/modules/playground/src/web_workers/kitchen_sink/index_common.ts @@ -24,8 +24,6 @@ class RedDec { // ShadowDom.(http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/) // - Directive - add behavior to existing elements. -// @Component is AtScript syntax to annotate the HelloCmp class as an Angular -// 2.0 component. @Component({ // The Selector prop tells Angular on which elements to instantiate this // class. The syntax supported is a basic subset of CSS selectors, for example diff --git a/tools/compiler_cli/src/reflector_host.ts b/tools/compiler_cli/src/reflector_host.ts index ac7aa47c4d..6f80f7e073 100644 --- a/tools/compiler_cli/src/reflector_host.ts +++ b/tools/compiler_cli/src/reflector_host.ts @@ -68,8 +68,8 @@ export class NodeReflectorHost implements StaticReflectorHost { if (!symbol) { throw new Error(`can't find symbol ${symbolName} exported from module ${filePath}`); } - while (symbol && - symbol.flags & ts.SymbolFlags.Alias) { // This is an alias, follow what it aliases + if (symbol && + symbol.flags & ts.SymbolFlags.Alias) { // This is an alias, follow what it aliases symbol = tc.getAliasedSymbol(symbol); } const declaration = symbol.getDeclarations()[0]; diff --git a/tools/metadata/test/evaluator.spec.ts b/tools/metadata/test/evaluator.spec.ts index 272645e7e0..e809aab3b1 100644 --- a/tools/metadata/test/evaluator.spec.ts +++ b/tools/metadata/test/evaluator.spec.ts @@ -117,18 +117,20 @@ describe('Evaluator', () => { expect(evaluator.evaluateNode(findVar(forwardRef, 'bFalse').initializer)).toEqual(false); }); - it('should return new expressions', () => { + fit('should return new expressions', () => { + evaluator = + new Evaluator(typeChecker, symbols, [{from: './classes', namedImports: [{name: 'Value'}]}]); var newExpression = program.getSourceFile('newExpression.ts'); expect(evaluator.evaluateNode(findVar(newExpression, 'someValue').initializer)) .toEqual({ __symbolic: "new", - expression: {__symbolic: "reference", name: "Value", module: "classes.ts"}, + expression: {__symbolic: "reference", name: "Value", module: "./classes"}, arguments: ["name", 12] }); expect(evaluator.evaluateNode(findVar(newExpression, 'complex').initializer)) .toEqual({ __symbolic: "new", - expression: {__symbolic: "reference", name: "Value", module: "classes.ts"}, + expression: {__symbolic: "reference", name: "Value", module: "./classes"}, arguments: ["name", 12] }); }); diff --git a/tools/public_api_guard/public_api_spec.ts b/tools/public_api_guard/public_api_spec.ts index 85fa2dbbfe..1c622ad797 100644 --- a/tools/public_api_guard/public_api_spec.ts +++ b/tools/public_api_guard/public_api_spec.ts @@ -1031,7 +1031,7 @@ const COMPILER = [ 'CompileDirectiveMetadata.type:CompileTypeMetadata', 'CompileDirectiveMetadata.viewQueries:CompileQueryMetadata[]', 'CompileTemplateMetadata', - 'CompileTemplateMetadata.constructor({encapsulation,template,templateUrl,styles,styleUrls,ngContentSelectors}:{encapsulation?:ViewEncapsulation, template?:string, templateUrl?:string, styles?:string[], styleUrls?:string[], ngContentSelectors?:string[]})', + 'CompileTemplateMetadata.constructor({encapsulation,template,templateUrl,styles,styleUrls,ngContentSelectors,baseUrl}:{encapsulation?:ViewEncapsulation, template?:string, templateUrl?:string, styles?:string[], styleUrls?:string[], ngContentSelectors?:string[], baseUrl?:string})', 'CompileTemplateMetadata.encapsulation:ViewEncapsulation', 'CompileTemplateMetadata.fromJson(data:{[key:string]:any}):CompileTemplateMetadata', 'CompileTemplateMetadata.ngContentSelectors:string[]', @@ -1040,6 +1040,7 @@ const COMPILER = [ 'CompileTemplateMetadata.template:string', 'CompileTemplateMetadata.templateUrl:string', 'CompileTemplateMetadata.toJson():{[key:string]:any}', + 'CompileTemplateMetadata.baseUrl:string', 'CompileTypeMetadata', 'CompileTypeMetadata.diDeps:CompileDiDependencyMetadata[]', 'CompileTypeMetadata.fromJson(data:{[key:string]:any}):CompileTypeMetadata',