Replies: 12 comments 9 replies
-
Same error on my end. Seemed to begin once I upgraded to Next 9.5.3. |
Beta Was this translation helpful? Give feedback.
-
I'm experiencing the same error upon a new project via |
Beta Was this translation helpful? Give feedback.
-
Unable to replicate using Yarn v1. Not very experienced with Yarn v2, but that appears to be the problem... Yarn v2 doesn't install a tsconfig.json
package.json
|
Beta Was this translation helpful? Give feedback.
-
This has just started magically working for me |
Beta Was this translation helpful? Give feedback.
-
I forgot to install ts in my project, so after installing and restarting vscode the error is gone |
Beta Was this translation helpful? Give feedback.
-
I got the same error using Next 11.1.2 |
Beta Was this translation helpful? Give feedback.
-
Run yarn add typescript @types/react @types/node it should fix |
Beta Was this translation helpful? Give feedback.
-
add
|
Beta Was this translation helpful? Give feedback.
-
I finally tracked this down to |
Beta Was this translation helpful? Give feedback.
-
I did the steps below and fixed the issue
Then the issue is gone. |
Beta Was this translation helpful? Give feedback.
-
I have this: /* eslint-disable @typescript-eslint/no-explicit-any */
import Document, {
Html,
Head,
Main,
NextScript,
DocumentContext,
} from 'next/document'
import FONTS from '~/configurations/fonts'
import { ServerStyleSheet } from 'styled-components'
const fontsPaths = Object.keys(FONTS).map(name => FONTS[name][0])
export async function getInitialProps(ctx: DocumentContext) {
const sheet = new ServerStyleSheet()
const originalRenderPage = ctx.renderPage
try {
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: App => (props: React.ComponentProps<any>) =>
sheet.collectStyles(<App {...props} />),
})
const initialProps = await Document.getInitialProps(ctx)
return {
...initialProps,
styles: [initialProps.styles, sheet.getStyleElement()],
}
} finally {
sheet.seal()
}
}
export default function MyDocument() {
return (
<Html lang="en">
<Head>
{fontsPaths.map(font => (
<link
key={font}
href={font}
as="font"
crossOrigin=""
/>
))}
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
} And am getting this on
Has anything else been figured out here? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Bug report
Describe the bug
@Timer Using typescript, yarn 2, and a monorepo, when I create a
_document.tsx
file, I see the following errors:To Reproduce
I'm not sure how to reproduce this error... I understand that this is needed, but maybe I can get some guidance on where to begin. I copied the
with-typescript
example and added my exact set up to it. After doing so, I do not see this error. So I'm a bit confused as to why it's showing up in my other repo when I add the_document.tsx
file.If I switch the file extension to
.js
, then my app builds no problem and my linter doesn't identify any issues with the file.Code Snippets
_document.tsx
tsconfig.json
console.log of the Head component
System information
Beta Was this translation helpful? Give feedback.
All reactions