From 7064b298d70490b8c129e736e322e0b356e8fb24 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Sat, 18 Nov 2017 21:54:24 +0100 Subject: [PATCH] Make SpreadProperty and RestProperty a deprecatedAlias (#6853) instead of hardcoding backwards compatiblity. This way we get deprecation warnings and also builders will work. --- packages/babel-types/src/definitions/core.js | 1 + packages/babel-types/src/definitions/es2015.js | 1 + packages/babel-types/src/index.js | 8 -------- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/babel-types/src/definitions/core.js b/packages/babel-types/src/definitions/core.js index 9897dec2e0..597aad960b 100644 --- a/packages/babel-types/src/definitions/core.js +++ b/packages/babel-types/src/definitions/core.js @@ -661,6 +661,7 @@ defineType("RestElement", { visitor: ["argument", "typeAnnotation"], builder: ["argument"], aliases: ["LVal", "PatternLike"], + deprecatedAlias: "RestProperty", fields: { ...patternLikeCommon, argument: { diff --git a/packages/babel-types/src/definitions/es2015.js b/packages/babel-types/src/definitions/es2015.js index 728fd69c34..f45f09db4d 100644 --- a/packages/babel-types/src/definitions/es2015.js +++ b/packages/babel-types/src/definitions/es2015.js @@ -466,6 +466,7 @@ defineType("ObjectPattern", { defineType("SpreadElement", { visitor: ["argument"], aliases: ["UnaryLike"], + deprecatedAlias: "SpreadProperty", fields: { argument: { validate: assertNodeType("Expression"), diff --git a/packages/babel-types/src/index.js b/packages/babel-types/src/index.js index bdffa7c96c..9288ea4515 100644 --- a/packages/babel-types/src/index.js +++ b/packages/babel-types/src/index.js @@ -77,14 +77,6 @@ for (const type in t.VISITOR_KEYS) { registerType(type); } -// Compat helpers so code for Babel 6.x is more likely to work on Babel 7.x. -export function isRestProperty(...args) { - return t.isRestElement(...args); -} -export function isSpreadProperty(...args) { - return t.isSpreadElement(...args); -} - /** * Flip `ALIAS_KEYS` for faster access in the reverse direction. */