Skip to content

Commit 87fdfc8

Browse files
committed
Merge pull request #6581 from RyanCavanaugh/jsDocFinal
JSDoc
2 parents 4e29069 + 00398d6 commit 87fdfc8

33 files changed

+908
-233
lines changed

src/compiler/binder.ts

+23-4
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,15 @@ namespace ts {
251251
case SyntaxKind.FunctionDeclaration:
252252
case SyntaxKind.ClassDeclaration:
253253
return node.flags & NodeFlags.Default ? "default" : undefined;
254+
case SyntaxKind.JSDocFunctionType:
255+
return isJSDocConstructSignature(node) ? "__new" : "__call";
256+
case SyntaxKind.Parameter:
257+
// Parameters with names are handled at the top of this function. Parameters
258+
// without names can only come from JSDocFunctionTypes.
259+
Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType);
260+
let functionType = <JSDocFunctionType>node.parent;
261+
let index = indexOf(functionType.parameters, node);
262+
return "p" + index;
254263
}
255264
}
256265

@@ -421,7 +430,6 @@ namespace ts {
421430

422431
addToContainerChain(container);
423432
}
424-
425433
else if (containerFlags & ContainerFlags.IsBlockScopedContainer) {
426434
blockScopeContainer = node;
427435
blockScopeContainer.locals = undefined;
@@ -459,6 +467,10 @@ namespace ts {
459467
labelStack = labelIndexMap = implicitLabels = undefined;
460468
}
461469

470+
if (isInJavaScriptFile(node) && node.jsDocComment) {
471+
bind(node.jsDocComment);
472+
}
473+
462474
bindReachableStatement(node);
463475

464476
if (currentReachabilityState === Reachability.Reachable && isFunctionLikeKind(kind) && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
@@ -722,8 +734,9 @@ namespace ts {
722734
case SyntaxKind.ClassDeclaration:
723735
case SyntaxKind.InterfaceDeclaration:
724736
case SyntaxKind.EnumDeclaration:
725-
case SyntaxKind.TypeLiteral:
726737
case SyntaxKind.ObjectLiteralExpression:
738+
case SyntaxKind.TypeLiteral:
739+
case SyntaxKind.JSDocRecordType:
727740
return ContainerFlags.IsContainer;
728741

729742
case SyntaxKind.CallSignature:
@@ -809,6 +822,7 @@ namespace ts {
809822
case SyntaxKind.TypeLiteral:
810823
case SyntaxKind.ObjectLiteralExpression:
811824
case SyntaxKind.InterfaceDeclaration:
825+
case SyntaxKind.JSDocRecordType:
812826
// Interface/Object-types always have their children added to the 'members' of
813827
// their container. They are only accessible through an instance of their
814828
// container, and are never in scope otherwise (even inside the body of the
@@ -829,6 +843,7 @@ namespace ts {
829843
case SyntaxKind.FunctionDeclaration:
830844
case SyntaxKind.FunctionExpression:
831845
case SyntaxKind.ArrowFunction:
846+
case SyntaxKind.JSDocFunctionType:
832847
case SyntaxKind.TypeAliasDeclaration:
833848
// All the children of these container types are never visible through another
834849
// symbol (i.e. through another symbol's 'exports' or 'members'). Instead,
@@ -910,7 +925,7 @@ namespace ts {
910925
}
911926
}
912927

913-
function bindFunctionOrConstructorType(node: SignatureDeclaration) {
928+
function bindFunctionOrConstructorType(node: SignatureDeclaration): void {
914929
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
915930
// to the one we would get for: { <...>(...): T }
916931
//
@@ -985,7 +1000,7 @@ namespace ts {
9851000
declareModuleMember(node, symbolFlags, symbolExcludes);
9861001
break;
9871002
}
988-
// fall through.
1003+
// fall through.
9891004
default:
9901005
if (!blockScopeContainer.locals) {
9911006
blockScopeContainer.locals = {};
@@ -1264,12 +1279,14 @@ namespace ts {
12641279
return bindVariableDeclarationOrBindingElement(<VariableDeclaration | BindingElement>node);
12651280
case SyntaxKind.PropertyDeclaration:
12661281
case SyntaxKind.PropertySignature:
1282+
case SyntaxKind.JSDocRecordMember:
12671283
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes);
12681284
case SyntaxKind.PropertyAssignment:
12691285
case SyntaxKind.ShorthandPropertyAssignment:
12701286
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
12711287
case SyntaxKind.EnumMember:
12721288
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes);
1289+
12731290
case SyntaxKind.CallSignature:
12741291
case SyntaxKind.ConstructSignature:
12751292
case SyntaxKind.IndexSignature:
@@ -1292,8 +1309,10 @@ namespace ts {
12921309
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes);
12931310
case SyntaxKind.FunctionType:
12941311
case SyntaxKind.ConstructorType:
1312+
case SyntaxKind.JSDocFunctionType:
12951313
return bindFunctionOrConstructorType(<SignatureDeclaration>node);
12961314
case SyntaxKind.TypeLiteral:
1315+
case SyntaxKind.JSDocRecordType:
12971316
return bindAnonymousDeclaration(<TypeLiteralNode>node, SymbolFlags.TypeLiteral, "__type");
12981317
case SyntaxKind.ObjectLiteralExpression:
12991318
return bindObjectLiteralExpression(<ObjectLiteralExpression>node);

0 commit comments

Comments
 (0)