-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript: TypeError: Class constructor cannot be invoked without 'new'
#8973
Comments
Fixed this with the following custom
Although I'm curious if there is a better way |
I'm running into what I think is the same issue, but under a different context. What I'm seeing when I run our build is the following error: TypeError: Class constructor Document cannot be invoked without 'new'
at new RootDocument (/Users/mherodev/git/my-project/build/.next/server/static/-aK3uMUavUDrLIDzynXXq/pages/_document.js:173:256)
at c (/Users/mherodev/git/my-project/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:325)
at Ua (/Users/mherodev/git/my-project/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:39:16)
at a.render (/Users/mherodev/git/my-project/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:45:48)
at a.read (/Users/mherodev/git/my-project/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:161)
at Object.renderToStaticMarkup (/Users/mherodev/git/my-project/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:55:181)
at renderDocument (/Users/mherodev/git/my-project/node_modules/next/dist/next-server/server/render.js:90:18)
at Object.renderToHTML (/Users/mherodev/git/my-project/node_modules/next/dist/next-server/server/render.js:319:16)
at process._tickCallback (internal/process/next_tick.js:68:7) This bug is fixed by your same fix (thanks, by the way), but it's a fix that I understand is a hack as I'm going to try to put together a simple repro repo tonight. |
Here's a link to my very-likely related ticket: #9000 Note: We're not using TypeScript. |
Getting this too on v9.1.0. Though it only happens when I target |
Closing as a reproducible demo was not provided. If you can provide a project that reproduces this, we'd be happy to take a look! |
Fixed mine extending my class to Before class Home {
render(): ReactNode {
return (
<div>Hello World!</div>
)
}
} After class Home extends React.Component {
constructor(props) {
super(props);
}
render(): ReactNode {
return (
<div>Hello World!</div>
)
}
} Hope this help you! |
A helpful link for those who may be trying to fix a similar issue: |
hello all, I am having the same issues but on Nodejs, trying to connect session with mongobd database. its reads, |
did you find any solution to this? RN I am facing the same issue |
Downgrade to Mongo 3. That was the solution the current Mongodb 4. Wasn't compatible |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Getting the following error in my project:
Looking at some related issues: #7914 it seems like this is because I'm using a library that requires targeting
es6
, which is fine, but I'm having issues telling next.js to use native classes instead of transpiling down to functions.tsconfig.json
Transpiled code:
Typescript code:
Expected behavior
Use native es6 classes and avoid error.
System information
The text was updated successfully, but these errors were encountered: