Using the connect function from redux seems to make my IDE (PhpStorm) lose the ability to "Find Usages" on my classes. I assume because connect returns any, so import SomeClass from SomeClass.ts loses the type information from that file.
export default connect(mapStateToProps)(SomeClass);
From the redux docs:
It does not modify the component class passed to it; instead, it returns a new, connected component class for you to use.
But I want my IDE to treat this as if it was my original class/component so it has all the type information.
One way I found how to fix this is by using annotations with @connect, but this requires me to put mapStateToProps & mapDispatchToProps functions above the class. I prefer to keep my class files fairly clean with the class at the very top of the file.
This gives Block-scoped variable 'mapSateToProps' used before its declaration
import { connect } from 'react-redux'
@connect(mapStateToProps)
class TestClass {
}
const mapStateToProps = (state, props) => {
}
Is there a way for me to use connect, keep the class type information in my IDE, and have mapStateToProps either below the class or inside the class as static functions? Or just anywhere else in the same file?
I'm using TypeScript & Babel.