File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
tools/@angular/tsc-wrapped Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -581,6 +581,16 @@ function validateMetadata(
581581 Object . getOwnPropertyNames ( classData . members )
582582 . forEach ( name => classData . members [ name ] . forEach ( ( m ) => validateMember ( classData , m ) ) ) ;
583583 }
584+ if ( classData . statics ) {
585+ Object . getOwnPropertyNames ( classData . statics ) . forEach ( name => {
586+ const staticMember = classData . statics [ name ] ;
587+ if ( isFunctionMetadata ( staticMember ) ) {
588+ validateExpression ( staticMember . value ) ;
589+ } else {
590+ validateExpression ( staticMember ) ;
591+ }
592+ } ) ;
593+ }
584594 }
585595
586596 function validateFunction ( functionDeclaration : FunctionMetadata ) {
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ describe('Collector', () => {
2828 '/promise.ts' ,
2929 '/unsupported-1.ts' ,
3030 '/unsupported-2.ts' ,
31+ '/unsupported-3.ts' ,
3132 'class-arity.ts' ,
3233 'import-star.ts' ,
3334 'exported-classes.ts' ,
@@ -621,10 +622,16 @@ describe('Collector', () => {
621622 } ) ;
622623
623624 it ( 'should throw for references to unexpected types' , ( ) => {
624- const unsupported1 = program . getSourceFile ( '/unsupported-2.ts' ) ;
625- expect ( ( ) => collector . getMetadata ( unsupported1 , true ) )
625+ const unsupported2 = program . getSourceFile ( '/unsupported-2.ts' ) ;
626+ expect ( ( ) => collector . getMetadata ( unsupported2 , true ) )
626627 . toThrowError ( / R e f e r e n c e t o n o n - e x p o r t e d c l a s s / ) ;
627628 } ) ;
629+
630+ it ( 'should throw for errors in a static method' , ( ) => {
631+ const unsupported3 = program . getSourceFile ( '/unsupported-3.ts' ) ;
632+ expect ( ( ) => collector . getMetadata ( unsupported3 , true ) )
633+ . toThrowError ( / R e f e r e n c e t o a n o n - e x p o r t e d c l a s s / ) ;
634+ } ) ;
628635 } ) ;
629636
630637 describe ( 'with invalid input' , ( ) => {
@@ -911,6 +918,15 @@ const FILES: Directory = {
911918 constructor(private f: Foo) {}
912919 }
913920 ` ,
921+ 'unsupported-3.ts' : `
922+ class Foo {}
923+
924+ export class SomeClass {
925+ static someStatic() {
926+ return Foo;
927+ }
928+ }
929+ ` ,
914930 'import-star.ts' : `
915931 import {Injectable} from 'angular2/core';
916932 import * as common from 'angular2/common';
You can’t perform that action at this time.
0 commit comments