@@ -1151,72 +1151,93 @@ namespace ts {
11511151 case SyntaxKind . Identifier :
11521152 return visitTypeName ( < Identifier > node ) ;
11531153 }
1154- }
11551154
1156- function visitNodes ( nodes : NodeArray < any > ) : void {
1157- forEach ( nodes , visitNode ) ;
1158- }
1155+ return ;
11591156
1160- function visitExportDeclaration ( node : ExportDeclaration ) : void {
1161- if ( ! node . moduleSpecifier ) {
1162- forEach ( node . exportClause . elements , e => collectAliasDeclaration ( e , node ) ) ;
1157+ function visitExportDeclaration ( node : ExportDeclaration ) : void {
1158+ if ( ! node . moduleSpecifier ) {
1159+ forEach ( node . exportClause . elements , e => collectAliasDeclaration ( e , node ) ) ;
1160+ }
11631161 }
1164- }
11651162
1166- function visitImportEqualsDeclaration ( node : ImportEqualsDeclaration ) : void {
1167- if ( node . moduleReference . kind !== SyntaxKind . ExternalModuleReference ) {
1168- collectAliasDeclaration ( node , node . moduleReference ) ;
1163+ function visitImportEqualsDeclaration ( node : ImportEqualsDeclaration ) : void {
1164+ if ( node . moduleReference . kind !== SyntaxKind . ExternalModuleReference ) {
1165+ collectAliasDeclaration ( node , node . moduleReference ) ;
1166+ }
11691167 }
1170- }
11711168
1172- function visitExportAssignment ( node : ExportAssignment ) : void {
1173- if ( node . expression . kind === SyntaxKind . Identifier ) {
1174- collectAliasDeclaration ( node , node . expression ) ;
1175- }
1176- else if ( ! node . isExportEquals ) {
1177- // TODO: handel expressions
1178- // TODO: Cache the result
1179- let writer = createNewTextWriterWithSymbolWriter ( ) ;
1180- let previousErrorNode = currentErrorNode ;
1181- currentErrorNode = node . expression ;
1182- resolver . writeTypeOfExpression ( node . expression , getEnclosingDeclaration ( node ) , TypeFormatFlags . UseTypeOfFunction , writer ) ;
1183- currentErrorNode = previousErrorNode ;
1169+ function visitExportAssignment ( node : ExportAssignment ) : void {
1170+ if ( node . expression . kind === SyntaxKind . Identifier ) {
1171+ collectAliasDeclaration ( node , node . expression ) ;
1172+ }
1173+ else if ( ! node . isExportEquals ) {
1174+ // TODO: handel expressions
1175+ // TODO: Cache the result
1176+ let writer = createNewTextWriterWithSymbolWriter ( ) ;
1177+ let previousErrorNode = currentErrorNode ;
1178+ currentErrorNode = node . expression ;
1179+ resolver . writeTypeOfExpression ( node . expression , getEnclosingDeclaration ( node ) , TypeFormatFlags . UseTypeOfFunction , writer ) ;
1180+ currentErrorNode = previousErrorNode ;
1181+ }
11841182 }
1185- }
11861183
1187- function visitSignatureDeclaration ( node : SignatureDeclaration ) : void {
1188- if ( hasDynamicName ( node ) || node . flags & NodeFlags . Private ) {
1189- return ;
1190- }
1184+ function visitSignatureDeclaration ( node : SignatureDeclaration ) : void {
1185+ if ( hasDynamicName ( node ) || node . flags & NodeFlags . Private ) {
1186+ return ;
1187+ }
11911188
1192- visitNodes ( node . typeParameters ) ;
1193- visitNodes ( node . parameters ) ;
1189+ visitNodes ( node . typeParameters ) ;
1190+ visitNodes ( node . parameters ) ;
11941191
1195- if ( node . type ) {
1196- visitNode ( node . type ) ;
1197- }
1198- else if ( node . kind !== SyntaxKind . Constructor ) {
1199- // TODO: handel infered type
1200- // TODO: Cache the result
1201- let writer = createNewTextWriterWithSymbolWriter ( ) ;
1202- let previousErrorNode = currentErrorNode ;
1203- currentErrorNode = node . name || node ;
1204- resolver . writeReturnTypeOfSignatureDeclaration ( node , getEnclosingDeclaration ( node ) , TypeFormatFlags . UseTypeOfFunction , writer ) ;
1205- currentErrorNode = previousErrorNode ;
1192+ if ( node . type ) {
1193+ visitNode ( node . type ) ;
1194+ }
1195+ else if ( node . kind !== SyntaxKind . Constructor ) {
1196+ // TODO: handel infered type
1197+ // TODO: Cache the result
1198+ let writer = createNewTextWriterWithSymbolWriter ( ) ;
1199+ let previousErrorNode = currentErrorNode ;
1200+ currentErrorNode = node . name || node ;
1201+ resolver . writeReturnTypeOfSignatureDeclaration ( node , getEnclosingDeclaration ( node ) , TypeFormatFlags . UseTypeOfFunction , writer ) ;
1202+ currentErrorNode = previousErrorNode ;
1203+ }
12061204 }
1207- }
12081205
1209- function visitAccessorDeclaration ( node : AccessorDeclaration ) {
1210- if ( hasDynamicName ( node ) || node . flags & NodeFlags . Private ) {
1211- return ;
1206+ function visitAccessorDeclaration ( node : AccessorDeclaration ) {
1207+ if ( hasDynamicName ( node ) || node . flags & NodeFlags . Private ) {
1208+ return ;
1209+ }
1210+
1211+ let accessors = getAllAccessorDeclarations ( ( < ClassDeclaration > node . parent ) . members , node ) ;
1212+
1213+ if ( accessors . firstAccessor === node ) {
1214+ let type = getTypeAnnotationFromAccessor ( accessors . getAccessor , accessors . setAccessor ) ;
1215+ if ( type ) {
1216+ visitNode ( type ) ;
1217+ }
1218+ else {
1219+ // TODO: handel infered type
1220+ // TODO: Cache the result
1221+ let writer = createNewTextWriterWithSymbolWriter ( ) ;
1222+ let previousErrorNode = currentErrorNode ;
1223+ currentErrorNode = node . name ;
1224+ resolver . writeTypeOfDeclaration ( node , getEnclosingDeclaration ( node ) , TypeFormatFlags . UseTypeOfFunction , writer ) ;
1225+ currentErrorNode = previousErrorNode ;
1226+ }
1227+ }
12121228 }
12131229
1214- let accessors = getAllAccessorDeclarations ( ( < ClassDeclaration > node . parent ) . members , node ) ;
1230+ function visitPropertyDeclaration ( node : PropertyDeclaration ) : void {
1231+ if ( hasDynamicName ( node ) || node . flags & NodeFlags . Private ) {
1232+ return ;
1233+ }
12151234
1216- if ( accessors . firstAccessor === node ) {
1217- let type = getTypeAnnotationFromAccessor ( accessors . getAccessor , accessors . setAccessor ) ;
1218- if ( type ) {
1219- visitNode ( type ) ;
1235+ if ( isBindingPattern ( node . name ) ) {
1236+ return visitNode ( node . name ) ;
1237+ }
1238+
1239+ if ( node . type ) {
1240+ visitNode ( node . type ) ;
12201241 }
12211242 else {
12221243 // TODO: handel infered type
@@ -1228,59 +1249,40 @@ namespace ts {
12281249 currentErrorNode = previousErrorNode ;
12291250 }
12301251 }
1231- }
12321252
1233- function visitPropertyDeclaration ( node : PropertyDeclaration ) : void {
1234- if ( hasDynamicName ( node ) || node . flags & NodeFlags . Private ) {
1235- return ;
1253+ function visitHeritageClause ( node : HeritageClause ) {
1254+ let firstEntry = node . types && node . types [ 0 ] ;
1255+ if ( node . token === SyntaxKind . ExtendsKeyword &&
1256+ firstEntry && ! isSupportedExpressionWithTypeArguments ( firstEntry ) ) {
1257+ // An expression in an extends clause
1258+ // TODO: Cache the result
1259+ let writer = createNewTextWriterWithSymbolWriter ( ) ;
1260+ let previousErrorNode = currentErrorNode ;
1261+ currentErrorNode = firstEntry ;
1262+ resolver . writeBaseConstructorTypeOfClass ( ( < ClassLikeDeclaration > node . parent ) , getEnclosingDeclaration ( node ) , TypeFormatFlags . UseTypeOfFunction , writer ) ;
1263+ currentErrorNode = previousErrorNode ;
1264+ }
1265+ else {
1266+ // regular type references
1267+ forEach ( node . types , visitExpressionWithTypeArguments ) ;
1268+ }
12361269 }
12371270
1238- if ( isBindingPattern ( node . name ) ) {
1239- return visitNode ( node . name ) ;
1271+ function visitExpressionWithTypeArguments ( node : ExpressionWithTypeArguments ) : void {
1272+ Debug . assert ( node . expression . kind === SyntaxKind . Identifier || node . expression . kind === SyntaxKind . PropertyAccessExpression ) ;
1273+ visitNode ( node . expression ) ;
1274+ visitNodes ( node . typeArguments ) ;
12401275 }
12411276
1242- if ( node . type ) {
1243- visitNode ( node . type ) ;
1244- }
1245- else {
1246- // TODO: handel infered type
1247- // TODO: Cache the result
1248- let writer = createNewTextWriterWithSymbolWriter ( ) ;
1249- let previousErrorNode = currentErrorNode ;
1250- currentErrorNode = node . name ;
1251- resolver . writeTypeOfDeclaration ( node , getEnclosingDeclaration ( node ) , TypeFormatFlags . UseTypeOfFunction , writer ) ;
1252- currentErrorNode = previousErrorNode ;
1253- }
1254- }
1255-
1256- function visitHeritageClause ( node : HeritageClause ) {
1257- let firstEntry = node . types && node . types [ 0 ] ;
1258- if ( node . token === SyntaxKind . ExtendsKeyword &&
1259- firstEntry && ! isSupportedExpressionWithTypeArguments ( firstEntry ) ) {
1260- // An expression in an extends clause
1261- // TODO: Cache the result
1262- let writer = createNewTextWriterWithSymbolWriter ( ) ;
1263- let previousErrorNode = currentErrorNode ;
1264- currentErrorNode = firstEntry ;
1265- resolver . writeBaseConstructorTypeOfClass ( ( < ClassLikeDeclaration > node . parent ) , getEnclosingDeclaration ( node ) , TypeFormatFlags . UseTypeOfFunction , writer ) ;
1266- currentErrorNode = previousErrorNode ;
1267- }
1268- else {
1269- // regular type references
1270- forEach ( node . types , visitExpressionWithTypeArguments ) ;
1277+ function visitTypeName ( node : Identifier ) : void {
1278+ let symbol = resolver . getSymbolAtLocation ( node ) ;
1279+ if ( symbol ) {
1280+ collectDeclarations ( symbol , node ) ;
1281+ }
12711282 }
1272- }
12731283
1274- function visitExpressionWithTypeArguments ( node : ExpressionWithTypeArguments ) : void {
1275- Debug . assert ( node . expression . kind === SyntaxKind . Identifier || node . expression . kind === SyntaxKind . PropertyAccessExpression ) ;
1276- visitNode ( node . expression ) ;
1277- visitNodes ( node . typeArguments ) ;
1278- }
1279-
1280- function visitTypeName ( node : Identifier ) : void {
1281- let symbol = resolver . getSymbolAtLocation ( node ) ;
1282- if ( symbol ) {
1283- collectDeclarations ( symbol , node ) ;
1284+ function visitNodes ( nodes : NodeArray < any > ) : void {
1285+ forEach ( nodes , visitNode ) ;
12841286 }
12851287 }
12861288
@@ -1291,7 +1293,6 @@ namespace ts {
12911293 }
12921294 }
12931295
1294-
12951296 function isDeclarationExported ( node : Node ) : boolean {
12961297 if ( compilerOptions . stripInternal && isInternal ( node ) ) {
12971298 // TODO: this is the correct place for this check, enable this
@@ -1386,7 +1387,6 @@ namespace ts {
13861387 return undefined ;
13871388 }
13881389
1389-
13901390 function collectDeclarations ( symbol : Symbol , errorNode : Node ) : void {
13911391 forEach ( symbol . declarations , d => collectDeclaration ( d , errorNode ) ) ;
13921392 }
0 commit comments