Skip to content

Commit

Permalink
Fix document type import path (#32117)
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
timneutkens authored Dec 4, 2021
1 parent b6162bb commit 980e169
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/document.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Document from './dist/shared/lib/runtime-config'
import Document from './dist/pages/_document'
export * from './dist/pages/_document'
export default Document
20 changes: 20 additions & 0 deletions test/integration/typescript/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// import App from "next/app";
import type { AppProps /*, AppContext */ } from 'next/app'

function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}

// Only uncomment this method if you have blocking data requirements for
// every single page in your application. This disables the ability to
// perform automatic static optimization, causing every page in your app to
// be server-side rendered.
//
// MyApp.getInitialProps = async (appContext: AppContext) => {
// // calls page's `getInitialProps` and fills `appProps.pageProps`
// const appProps = await App.getInitialProps(appContext);

// return { ...appProps }
// }

export default MyApp
11 changes: 11 additions & 0 deletions test/integration/typescript/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Document, { DocumentContext } from 'next/document'

class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx)

return initialProps
}
}

export default MyDocument

0 comments on commit 980e169

Please sign in to comment.