diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 00bf031c18321..448922e5db380 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -547,6 +547,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { var unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable }; var reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); + var alreadyBound: Set; /* eslint-enable no-var */ return bindSourceFile; @@ -567,6 +568,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { inStrictMode = bindInStrictMode(file, opts); classifiableNames = new Set(); symbolCount = 0; + alreadyBound = new Set(); Symbol = objectAllocator.getSymbolConstructor(); @@ -604,6 +606,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { hasExplicitReturn = false; inAssignmentPattern = false; emitFlags = NodeFlags.None; + alreadyBound = undefined!; } function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean { @@ -2027,7 +2030,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { } function bindJSDocClassTag(node: JSDocClassTag) { - bindEachChild(node); + // bindEachChild(node); const host = getHostSignatureFromJSDoc(node); if (host && host.kind !== SyntaxKind.MethodDeclaration) { addDeclarationToSymbol(host.symbol, host, SymbolFlags.Class); @@ -2640,6 +2643,10 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { if (!node) { return; } + + Debug.assert(!alreadyBound.has(node), "This node has already been bound."); + alreadyBound.add(node); + setParent(node, parent); if (tracing) (node as TracingNode).tracingPath = file.path; const saveInStrictMode = inStrictMode;