@@ -240,6 +240,15 @@ namespace ts {
240240 case SyntaxKind . FunctionDeclaration :
241241 case SyntaxKind . ClassDeclaration :
242242 return node . flags & NodeFlags . Default ? "default" : undefined ;
243+ case SyntaxKind . JSDocFunctionType :
244+ return isJSDocConstructSignature ( node ) ? "__new" : "__call" ;
245+ case SyntaxKind . Parameter :
246+ // Parameters with names are handled at the top of this function. Parameters
247+ // without names can only come from JSDocFunctionTypes.
248+ Debug . assert ( node . parent . kind === SyntaxKind . JSDocFunctionType ) ;
249+ let functionType = < JSDocFunctionType > node . parent ;
250+ let index = indexOf ( functionType . parameters , node ) ;
251+ return "p" + index ;
243252 }
244253 }
245254
@@ -405,7 +414,6 @@ namespace ts {
405414
406415 addToContainerChain ( container ) ;
407416 }
408-
409417 else if ( containerFlags & ContainerFlags . IsBlockScopedContainer ) {
410418 blockScopeContainer = node ;
411419 blockScopeContainer . locals = undefined ;
@@ -440,6 +448,10 @@ namespace ts {
440448 labelStack = labelIndexMap = implicitLabels = undefined ;
441449 }
442450
451+ if ( isInJavaScriptFile ( node ) && node . jsDocComment ) {
452+ bind ( node . jsDocComment ) ;
453+ }
454+
443455 bindReachableStatement ( node ) ;
444456
445457 if ( currentReachabilityState === Reachability . Reachable && isFunctionLikeKind ( kind ) && nodeIsPresent ( ( < FunctionLikeDeclaration > node ) . body ) ) {
@@ -688,8 +700,9 @@ namespace ts {
688700 case SyntaxKind . ClassDeclaration :
689701 case SyntaxKind . InterfaceDeclaration :
690702 case SyntaxKind . EnumDeclaration :
691- case SyntaxKind . TypeLiteral :
692703 case SyntaxKind . ObjectLiteralExpression :
704+ case SyntaxKind . TypeLiteral :
705+ case SyntaxKind . JSDocRecordType :
693706 return ContainerFlags . IsContainer ;
694707
695708 case SyntaxKind . CallSignature :
@@ -775,6 +788,7 @@ namespace ts {
775788 case SyntaxKind . TypeLiteral :
776789 case SyntaxKind . ObjectLiteralExpression :
777790 case SyntaxKind . InterfaceDeclaration :
791+ case SyntaxKind . JSDocRecordType :
778792 // Interface/Object-types always have their children added to the 'members' of
779793 // their container. They are only accessible through an instance of their
780794 // container, and are never in scope otherwise (even inside the body of the
@@ -795,6 +809,7 @@ namespace ts {
795809 case SyntaxKind . FunctionDeclaration :
796810 case SyntaxKind . FunctionExpression :
797811 case SyntaxKind . ArrowFunction :
812+ case SyntaxKind . JSDocFunctionType :
798813 case SyntaxKind . TypeAliasDeclaration :
799814 // All the children of these container types are never visible through another
800815 // symbol (i.e. through another symbol's 'exports' or 'members'). Instead,
@@ -873,7 +888,7 @@ namespace ts {
873888 }
874889 }
875890
876- function bindFunctionOrConstructorType ( node : SignatureDeclaration ) {
891+ function bindFunctionOrConstructorTypeOrJSDocFunctionType ( node : SignatureDeclaration ) : void {
877892 // For a given function symbol "<...>(...) => T" we want to generate a symbol identical
878893 // to the one we would get for: { <...>(...): T }
879894 //
@@ -948,7 +963,7 @@ namespace ts {
948963 declareModuleMember ( node , symbolFlags , symbolExcludes ) ;
949964 break ;
950965 }
951- // fall through.
966+ // fall through.
952967 default :
953968 if ( ! blockScopeContainer . locals ) {
954969 blockScopeContainer . locals = { } ;
@@ -1227,12 +1242,14 @@ namespace ts {
12271242 return bindVariableDeclarationOrBindingElement ( < VariableDeclaration | BindingElement > node ) ;
12281243 case SyntaxKind . PropertyDeclaration :
12291244 case SyntaxKind . PropertySignature :
1245+ case SyntaxKind . JSDocRecordMember :
12301246 return bindPropertyOrMethodOrAccessor ( < Declaration > node , SymbolFlags . Property | ( ( < PropertyDeclaration > node ) . questionToken ? SymbolFlags . Optional : SymbolFlags . None ) , SymbolFlags . PropertyExcludes ) ;
12311247 case SyntaxKind . PropertyAssignment :
12321248 case SyntaxKind . ShorthandPropertyAssignment :
12331249 return bindPropertyOrMethodOrAccessor ( < Declaration > node , SymbolFlags . Property , SymbolFlags . PropertyExcludes ) ;
12341250 case SyntaxKind . EnumMember :
12351251 return bindPropertyOrMethodOrAccessor ( < Declaration > node , SymbolFlags . EnumMember , SymbolFlags . EnumMemberExcludes ) ;
1252+
12361253 case SyntaxKind . CallSignature :
12371254 case SyntaxKind . ConstructSignature :
12381255 case SyntaxKind . IndexSignature :
@@ -1256,8 +1273,10 @@ namespace ts {
12561273 return bindPropertyOrMethodOrAccessor ( < Declaration > node , SymbolFlags . SetAccessor , SymbolFlags . SetAccessorExcludes ) ;
12571274 case SyntaxKind . FunctionType :
12581275 case SyntaxKind . ConstructorType :
1259- return bindFunctionOrConstructorType ( < SignatureDeclaration > node ) ;
1276+ case SyntaxKind . JSDocFunctionType :
1277+ return bindFunctionOrConstructorTypeOrJSDocFunctionType ( < SignatureDeclaration > node ) ;
12601278 case SyntaxKind . TypeLiteral :
1279+ case SyntaxKind . JSDocRecordType :
12611280 return bindAnonymousDeclaration ( < TypeLiteralNode > node , SymbolFlags . TypeLiteral , "__type" ) ;
12621281 case SyntaxKind . ObjectLiteralExpression :
12631282 return bindObjectLiteralExpression ( < ObjectLiteralExpression > node ) ;
@@ -1269,6 +1288,8 @@ namespace ts {
12691288
12701289 case SyntaxKind . CallExpression :
12711290 if ( isInJavaScriptFile ( node ) ) {
1291+ // We're only inspecting call expressions to detect CommonJS modules, so we can skip
1292+ // this check if we've already seen the module indicator
12721293 bindCallExpression ( < CallExpression > node ) ;
12731294 }
12741295 break ;
0 commit comments