Handle undefined in getSynthesizedClone

This commit is contained in:
Andrew Casey 2017-10-05 15:37:47 -07:00
parent d03d237b3b
commit a5e1841180

View file

@ -47,10 +47,15 @@ namespace ts {
* Creates a shallow, memberwise clone of a node with no source map location.
*/
/* @internal */
export function getSynthesizedClone<T extends Node>(node: T | undefined): T {
export function getSynthesizedClone<T extends Node>(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 = <T>createSynthesizedNode(node.kind);
clone.flags |= node.flags;
setOriginalNode(clone, node);