So I have the following code with typescript-eslint on with its recommended settings. I have read: Using getInitialProps in Next.js with TypeScript
const X: NextPage = props => {/*...*/}
X.getInitialProps = async (ctx): Promise<unknown> => {/*...*/}
X.getInitialProps
emitted this error:
ESLint: Avoid referencing unbound methods which may cause unintentional scoping of
this
.(@typescript-eslint/unbound-method)
I believe this problem may be extended to, how to properly type static methods.
For those who aren't familiar with Next.js, NextPage
has the (simplified) definition of:
export type NextPage<C, IP = {}, P = {}> = ComponentType<P> & { // ComponentType is a React type
getInitialProps?(context: C): IP
}
The GitHub repo of typescript-eslint has recently merged a pull request that fixes the issue https://github.com/typescript-eslint/typescript-eslint/pull/1736