-
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
[email protected] gives "Type '() => any' is not a constructor function type" error in _Document.tsx #32110
Comments
+1, just upgrade to 12.0.5 and got this problem. |
upgraded to 12.0.5 and facing the same issue during build time. I am using: After downgrade to [email protected] the issue is no longer exist. |
I respect and appreciate the awesome work of the Next js team, For now replace
with
document.d.ts has been broken 12.0.5
12.0.4
|
It seems the usage is different now... or at least that's how the types are defined: The error go away if I do: export default class MyDocument extends Document() {
// ...rest
} But if that's the case, it seems a breaking change. Who customize UpdateI run a build with that syntax and got an error:
So I think the interface is incorrect WorkaroundQuick and dirty: import Document, { Head, Html, Main, NextScript } from 'next/document';
const CustomDocument = Document as any
export default class MyDocument extends CustomDocument {
// ... rest
} |
There was a mistake in #32077 which imported a different module than _document in the _document .d.ts file. I found that we didn't have a test for a custom _document.tsx and _app.tsx with TypeScript, so I've added one that fails on canary and passes with this fix to ensure this does not happen in the future. Fixes #32110 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
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 🙏 |
This comment has been minimized.
This comment has been minimized.
Awesome! |
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. |
There was a mistake in vercel#32077 which imported a different module than _document in the _document .d.ts file. I found that we didn't have a test for a custom _document.tsx and _app.tsx with TypeScript, so I've added one that fails on canary and passes with this fix to ensure this does not happen in the future. Fixes vercel#32110 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
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
[email protected]
and[email protected]
, my_Document.tsx
now throws an eslint errorType '() => any' is not a constructor function type
. I havetypescript@^4.5.2
installed._Doucment.tsx
.eslintrc.json
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.
The text was updated successfully, but these errors were encountered: