Late to the party, but hopefully this will help someone.
I had the same problem with my component library that I was building with rollup.
I was using @babel/plugin-proposal-class-properties, and writing the classes like this:
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
export default class Alert extends PureComponent {
static propTypes = {
type: PropTypes.oneOf(['success', 'info', 'warning', 'danger']),
title: PropTypes.string,
}
render() {
const { type, children } = this.props
return (
<div>
<h3>{title}</h3>
{children &&
<div className="alert-content">
{children}
</div>
}
</div>
)
}
}
In my compiled file, this used defineProperty like this to define the propTypes:
_defineProperty(Alert, "propTypes", {
type: PropTypes.oneOf(['success', 'info', 'warning', 'danger']),
title: PropTypes.string
});
By setting the option loose: true on the babel-plugin, I managed to turn it into this, and the intellisense worked in IntelliJ:
Alert.propTypes = {
type: PropTypes.oneOf(['success', 'info', 'warning', 'danger']),
title: PropTypes.string
};
My .babelrc
{
"plugins": [
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
}