From a5e184118088342db9db79c49f6cb95e53f63b72 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 5 Oct 2017 15:37:47 -0700 Subject: [PATCH] Handle undefined in getSynthesizedClone --- src/compiler/factory.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 968144c0fc7..fe183c5e806 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -47,10 +47,15 @@ namespace ts { * Creates a shallow, memberwise clone of a node with no source map location. */ /* @internal */ - export function getSynthesizedClone(node: T | undefined): T { + export function getSynthesizedClone(node: T | undefined): T | undefined { // We don't use "clone" from core.ts here, as we need to preserve the prototype chain of // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). + + if (node === undefined) { + return undefined; + } + const clone = createSynthesizedNode(node.kind); clone.flags |= node.flags; setOriginalNode(clone, node);