Skip to content

Commit 2ce53ba

Browse files
committed
Bind callback tag
Builds but tests still don't pass
1 parent 248cd06 commit 2ce53ba

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/compiler/binder.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ namespace ts {
118118
let thisParentContainer: Node; // Container one level up
119119
let blockScopeContainer: Node;
120120
let lastContainer: Node;
121-
let delayedTypedefs: { typedef: JSDocTypedefTag, container: Node, lastContainer: Node, blockScopeContainer: Node, parent: Node }[];
121+
let delayedTypedefs: { typeAlias: JSDocTypedefTag | JSDocCallbackTag, container: Node, lastContainer: Node, blockScopeContainer: Node, parent: Node }[];
122122
let seenThisKeyword: boolean;
123123

124124
// state used by control flow analysis
@@ -273,6 +273,7 @@ namespace ts {
273273
return InternalSymbolName.Constructor;
274274
case SyntaxKind.FunctionType:
275275
case SyntaxKind.CallSignature:
276+
case SyntaxKind.JSDocSignature:
276277
return InternalSymbolName.Call;
277278
case SyntaxKind.ConstructorType:
278279
case SyntaxKind.ConstructSignature:
@@ -1452,6 +1453,7 @@ namespace ts {
14521453
case SyntaxKind.GetAccessor:
14531454
case SyntaxKind.SetAccessor:
14541455
case SyntaxKind.CallSignature:
1456+
case SyntaxKind.JSDocSignature:
14551457
case SyntaxKind.JSDocFunctionType:
14561458
case SyntaxKind.FunctionType:
14571459
case SyntaxKind.ConstructSignature:
@@ -1541,6 +1543,7 @@ namespace ts {
15411543
case SyntaxKind.ConstructorType:
15421544
case SyntaxKind.CallSignature:
15431545
case SyntaxKind.ConstructSignature:
1546+
case SyntaxKind.JSDocSignature:
15441547
case SyntaxKind.IndexSignature:
15451548
case SyntaxKind.MethodDeclaration:
15461549
case SyntaxKind.MethodSignature:
@@ -1646,7 +1649,7 @@ namespace ts {
16461649
return state;
16471650
}
16481651

1649-
function bindFunctionOrConstructorType(node: SignatureDeclaration): void {
1652+
function bindFunctionOrConstructorType(node: SignatureDeclaration | JSDocSignature): void {
16501653
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
16511654
// to the one we would get for: { <...>(...): T }
16521655
//
@@ -1757,7 +1760,7 @@ namespace ts {
17571760
const saveParent = parent;
17581761
for (const delay of delayedTypedefs) {
17591762
({ container, lastContainer, blockScopeContainer, parent } = delay);
1760-
bindBlockScopedDeclaration(delay.typedef, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
1763+
bindBlockScopedDeclaration(delay.typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
17611764
}
17621765
container = saveContainer;
17631766
lastContainer = saveLastContainer;
@@ -2100,6 +2103,7 @@ namespace ts {
21002103
case SyntaxKind.TypeParameter:
21012104
return bindTypeParameter(node as TypeParameterDeclaration);
21022105
case SyntaxKind.Parameter:
2106+
case SyntaxKind.JSDocParameterTag:
21032107
return bindParameter(<ParameterDeclaration>node);
21042108
case SyntaxKind.VariableDeclaration:
21052109
return bindVariableDeclarationOrBindingElement(<VariableDeclaration>node);
@@ -2137,8 +2141,9 @@ namespace ts {
21372141
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes);
21382142
case SyntaxKind.FunctionType:
21392143
case SyntaxKind.JSDocFunctionType:
2144+
case SyntaxKind.JSDocSignature:
21402145
case SyntaxKind.ConstructorType:
2141-
return bindFunctionOrConstructorType(<SignatureDeclaration>node);
2146+
return bindFunctionOrConstructorType(<SignatureDeclaration | JSDocSignature>node);
21422147
case SyntaxKind.TypeLiteral:
21432148
case SyntaxKind.JSDocTypeLiteral:
21442149
case SyntaxKind.MappedType:
@@ -2211,10 +2216,11 @@ namespace ts {
22112216
SymbolFlags.Property | SymbolFlags.Optional :
22122217
SymbolFlags.Property;
22132218
return declareSymbolAndAddToSymbolTable(propTag, flags, SymbolFlags.PropertyExcludes);
2214-
case SyntaxKind.JSDocTypedefTag: {
2219+
case SyntaxKind.JSDocTypedefTag:
2220+
case SyntaxKind.JSDocCallbackTag: {
22152221
const { fullName } = node as JSDocTypedefTag;
22162222
if (!fullName || fullName.kind === SyntaxKind.Identifier) {
2217-
(delayedTypedefs || (delayedTypedefs = [])).push({ typedef: node as JSDocTypedefTag, container, lastContainer, blockScopeContainer, parent });
2223+
(delayedTypedefs || (delayedTypedefs = [])).push({ typeAlias: node as JSDocTypedefTag | JSDocCallbackTag, container, lastContainer, blockScopeContainer, parent });
22182224
}
22192225
break;
22202226
}
@@ -2611,15 +2617,15 @@ namespace ts {
26112617
}
26122618
}
26132619

2614-
function bindParameter(node: ParameterDeclaration) {
2620+
function bindParameter(node: ParameterDeclaration | JSDocParameterTag) {
26152621
if (inStrictMode && !(node.flags & NodeFlags.Ambient)) {
26162622
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
26172623
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
26182624
checkStrictModeEvalOrArguments(node, node.name);
26192625
}
26202626

26212627
if (isBindingPattern(node.name)) {
2622-
bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, "__" + node.parent.parameters.indexOf(node) as __String);
2628+
bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, "__" + (node as ParameterDeclaration).parent.parameters.indexOf(node as ParameterDeclaration) as __String);
26232629
}
26242630
else {
26252631
declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes);

0 commit comments

Comments
 (0)