@@ -2751,7 +2751,7 @@ module ts {
2751
2751
while ( true ) {
2752
2752
node = node . parent ;
2753
2753
if ( ! node ) {
2754
- return node ;
2754
+ return undefined ;
2755
2755
}
2756
2756
switch ( node . kind ) {
2757
2757
case SyntaxKind . SourceFile :
@@ -3966,6 +3966,10 @@ module ts {
3966
3966
for ( var i = 0 , n = declarations . length ; i < n ; i ++ ) {
3967
3967
var container = getContainerNode ( declarations [ i ] ) ;
3968
3968
3969
+ if ( ! container ) {
3970
+ return undefined ;
3971
+ }
3972
+
3969
3973
if ( scope && scope !== container ) {
3970
3974
// Different declarations have different containers, bail out
3971
3975
return undefined ;
@@ -4530,8 +4534,8 @@ module ts {
4530
4534
fileName : filename ,
4531
4535
textSpan : TextSpan . fromBounds ( declaration . getStart ( ) , declaration . getEnd ( ) ) ,
4532
4536
// TODO(jfreeman): What should be the containerName when the container has a computed name?
4533
- containerName : container . name ? ( < Identifier > container . name ) . text : "" ,
4534
- containerKind : container . name ? getNodeKind ( container ) : ""
4537
+ containerName : container && container . name ? ( < Identifier > container . name ) . text : "" ,
4538
+ containerKind : container && container . name ? getNodeKind ( container ) : ""
4535
4539
} ) ;
4536
4540
}
4537
4541
}
@@ -4685,10 +4689,12 @@ module ts {
4685
4689
else {
4686
4690
return SemanticMeaning . Namespace ;
4687
4691
}
4688
- break ;
4689
4692
4690
4693
case SyntaxKind . ImportDeclaration :
4691
4694
return SemanticMeaning . Value | SemanticMeaning . Type | SemanticMeaning . Namespace ;
4695
+
4696
+ case SyntaxKind . SourceFile :
4697
+ return SemanticMeaning . Namespace | SemanticMeaning . Value ;
4692
4698
}
4693
4699
Debug . fail ( "Unknown declaration type" ) ;
4694
4700
}
0 commit comments