Skip to content

Commit

Permalink
feat: throw when ClassStatic is seen on class features plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Oct 6, 2020
1 parent 271a56b commit adc83d8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/babel-helper-create-class-features-plugin/src/index.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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}"`);
},
Expand Down

0 comments on commit adc83d8

Please sign in to comment.