question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eslint-config-next@12.0.5 gives "Type '() => any' is not a constructor function type" error in _Document.tsx

See original GitHub issue

What version of Next.js are you using?

12.0.5

What version of Node.js are you using?

14.18.0

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

After upgrading to both next@12.0.5 and eslint-config-next@12.0.5, my _Document.tsx now throws an eslint error Type '() => any' is not a constructor function type. I have typescript@^4.5.2 installed.

_Doucment.tsx

import Document, { Head, Html, Main, NextScript } from 'next/document'

class MyDocument extends Document {
  render() {
    return (
      <Html lang="en-US" className="h-full bg-gray-100">
        <Head />
        <body className="loading h-full">
          <Main />
          <NextScript />
        </body>
      </Html>
    )
  }
}

export default MyDocument

.eslintrc.json

{
  "extends": ["next/core-web-vitals", "prettier"],
  "rules": {
    "react/no-unescaped-entities": "off"
  }
}

Expected Behavior

This was not breaking on 12.0.4 and should not break on 12.0.5

To Reproduce

Create a Next.js project with the example code I provided above.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:18
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
TimNZcommented, Dec 4, 2021

I respect and appreciate the awesome work of the Next js team, so I am perplexed how this got through testing for release.

For now replace

import Document from 'next/document'

with

import Document from 'next/dist/pages/_document'

document.d.ts has been broken

12.0.5

import Document from './dist/shared/lib/runtime-config'
export * from './dist/pages/_document'
export default Document

12.0.4

export * from './dist/pages/_document'
export { default } from './dist/pages/_document'
6reactions
timneutkenscommented, Dec 4, 2021

Published 12.0.6: https://github.com/vercel/next.js/releases/tag/v12.0.6

It’ll take a bit for it to be available on npm 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript Error: Type 'any' is not a constructor function type
I made a mistake when importing the abstract class. I wrote: import { RESTService } from 'restService';. But had to: import { RESTService...
Read more >
TypeScript errors and how to fix them
error TS1055: Type ' AxiosPromise ' is not a valid async function return type in ES5/ES3 because it does not refer to a...
Read more >
Explain 'Not a constructor function' error in JavaScript?
The not a constructor function error occurs if we use an object or a variable as a constructor that isn't a constructor.
Read more >
"Type 'HealthOriginal' is not a constructor function type." when ...
I'm following these instructions on how to mock native-plugins. Trying this leads to the error in the title. I am using Ionic 5....
Read more >
TS2605 JSX element type 'Button' is not a constructor function ...
I recently have been playing around with JSX and everything works fine; but trying to convert to TypeScript (TSX) I run into issues....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found