Handle undefined in getSynthesizedClone
This commit is contained in:
parent
d03d237b3b
commit
a5e1841180
1 changed files with 6 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue