From bc467f595badf1a4057a9cf7a118440727e2c5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 6 Oct 2020 16:52:55 -0400 Subject: [PATCH] feat: throw when ClassStatic is seen on class features plugins --- .../src/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/babel-helper-create-class-features-plugin/src/index.js b/packages/babel-helper-create-class-features-plugin/src/index.js index d23c12cefdc1..e1d2222e8d24 100644 --- a/packages/babel-helper-create-class-features-plugin/src/index.js +++ b/packages/babel-helper-create-class-features-plugin/src/index.js @@ -120,6 +120,18 @@ export function createClassFeaturePlugin({ } if (!isDecorated) isDecorated = hasOwnDecorators(path.node); + + if (path.isStaticBlock()) { + throw path.buildCodeFrameError(`Incorrect plugin orders, \`@babel/plugin-proposal-class-static-block\` should be placed before class features plugins +{ + "plugins": [ + "@babel/plugin-proposal-class-static-block", + "@babel/plugin-proposal-private-property-in-object", + "@babel/plugin-proposal-private-methods", + "@babel/plugin-proposal-class-properties", + ] +}`); + } } if (!props.length && !isDecorated) return; @@ -188,7 +200,12 @@ export function createClassFeaturePlugin({ }, PrivateName(path) { - if (this.file.get(versionKey) !== version) return; + if ( + this.file.get(versionKey) !== version || + path.parentPath.isPrivate({ key: path.node }) + ) { + return; + } throw path.buildCodeFrameError(`Unknown PrivateName "${path}"`); },