From 3073f58bce6cf5364902960aeb09ee98f2d46822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 28 Jul 2021 16:07:02 -0400 Subject: [PATCH] breaking: remove Node#__clone in Babel 8 --- packages/babel-parser/src/parser/node.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/babel-parser/src/parser/node.js b/packages/babel-parser/src/parser/node.js index 495996fa5824..df41ff3fec7d 100644 --- a/packages/babel-parser/src/parser/node.js +++ b/packages/babel-parser/src/parser/node.js @@ -26,9 +26,12 @@ class Node implements NodeBase { trailingComments: Array; innerComments: Array; extra: { [key: string]: any }; +} +const NodePrototype = Node.prototype; - // todo(Babel 8): remove this method in Babel 8 - __clone(): this { +if (!process.env.BABEL_8_BREAKING) { + // $FlowIgnore + NodePrototype.__clone = function (): Node { // $FlowIgnore const newNode: any = new Node(); const keys = Object.keys(this); @@ -40,15 +43,13 @@ class Node implements NodeBase { key !== "trailingComments" && key !== "innerComments" ) { - // $FlowIgnore newNode[key] = this[key]; } } return newNode; - } + }; } -const NodePrototype = Node.prototype; function clonePlaceholder(node: any): any { return cloneIdentifier(node);