Skip to content

Commit 980e169

Browse files
authored
Fix document type import path (#32117)
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`
1 parent b6162bb commit 980e169

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

packages/next/document.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import Document from './dist/shared/lib/runtime-config'
1+
import Document from './dist/pages/_document'
22
export * from './dist/pages/_document'
33
export default Document
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// import App from "next/app";
2+
import type { AppProps /*, AppContext */ } from 'next/app'
3+
4+
function MyApp({ Component, pageProps }: AppProps) {
5+
return <Component {...pageProps} />
6+
}
7+
8+
// Only uncomment this method if you have blocking data requirements for
9+
// every single page in your application. This disables the ability to
10+
// perform automatic static optimization, causing every page in your app to
11+
// be server-side rendered.
12+
//
13+
// MyApp.getInitialProps = async (appContext: AppContext) => {
14+
// // calls page's `getInitialProps` and fills `appProps.pageProps`
15+
// const appProps = await App.getInitialProps(appContext);
16+
17+
// return { ...appProps }
18+
// }
19+
20+
export default MyApp
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Document, { DocumentContext } from 'next/document'
2+
3+
class MyDocument extends Document {
4+
static async getInitialProps(ctx: DocumentContext) {
5+
const initialProps = await Document.getInitialProps(ctx)
6+
7+
return initialProps
8+
}
9+
}
10+
11+
export default MyDocument

0 commit comments

Comments
 (0)