Skip to content

Commit

Permalink
chore(build): support setter-only dproperties
Browse files Browse the repository at this point in the history
This change to React wrapper Babel plugin makes it support setter-only
declared properties or one whose setter is defined first.

Refs carbon-design-system#230.
  • Loading branch information
asudoh committed Dec 17, 2019
1 parent 7b24c00 commit 7cc2ae5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion babel-plugin-create-react-custom-element-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ module.exports = function generateCreateReactCustomElementType(api) {

const metadata = getPropertyMetadata(path);
if (metadata) {
if (!parentPath.isClassProperty() && (!parentPath.isClassMethod() || parentPath.node.kind !== 'get')) {
if (
!parentPath.isClassProperty() &&
(!parentPath.isClassMethod() || (parentPath.node.kind !== 'get' && parentPath.node.kind !== 'set'))
) {
throw parentPath.buildCodeFrameError('`@property()` must target class properties.');
}
declaredProps[parent.key.name] = metadata;
Expand Down

0 comments on commit 7cc2ae5

Please sign in to comment.