I've been grappling with this problem for an extended period, and despite numerous attempts, I haven't been able to resolve it.
My issue revolves around a basic page named one.tsx
. Its structure is as follows:
The linting error that's plaguing me reads:
Missing return type on function.eslint(@typescript-eslint/explicit-function-return-type)
This is how my tsconfig.json file looks:
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": false,
"checkJs": false,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
... (omitted for brevity)
... (other sections omitted)
Here is the console error message:
frontend | [ event ] build page: /one
frontend | [ warn ] ./pages/one.tsx
frontend | ...
To mitigate the issue, I manually specified a return type, like so:
TestServer.getInitialProps = async (): Promise<Props> => {
Despite having the next-env.d.ts file in place and being able to navigate to the NextPage type definition in VSCode, eslint-typescript fails to recognize it. What could be causing this discrepancy?
Your insights are greatly appreciated.