question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TS] `DocumentFiles` is not exported from `_document.tsx`

See original GitHub issue

Feature request

Is your feature request related to a problem? Please describe.

I’m trying to use DocumentFiles like:

getCssLinks({ allFiles }: DocumentFiles) {
	const { assetPrefix } = this.context
	if (!allFiles || allFiles.length === 0) return null

	return allFiles
		.filter((file: any) => /\.css$/.test(file))
		.map((file: any) => (
			<style
				key={file}
				nonce={this.props.nonce}
				data-href={`${assetPrefix}/_next/${file}`}
				dangerouslySetInnerHTML={{
					__html: fs.readFileSync(path.join(process.cwd(), '.next', file), 'utf-8'),
				}}
			/>
		))
}

Describe the solution you’d like

Just have to export DocumentFiles from https://github.com/vercel/next.js/blob/canary/packages/next/pages/_document.tsx#L47

Describe alternatives you’ve considered

I use any like so:

getCssLinks({ allFiles }: { allFiles: any }) {
	...
}

Additional context

I’ve written about it here → https://github.com/vercel/next-plugins/issues/238#issuecomment-699890100

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
timneutkenscommented, Sep 28, 2020

DocumentFiles is not a public property. Overriding built-in components is not recommended and is likely to break between upgrading Next.js versions.

0reactions
balazsorban44commented, Jan 29, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to properly type the _document.tsx file from Next.js?
This is what I've ended up doing to type the getInitialProps and render methods: import React, { ReactElement } from "react"; ...
Read more >
Advanced Features: Custom `Document` - Next.js
A custom Document can update the <html> and <body> tags used to render a Page. This file is only rendered on the server,...
Read more >
Next.js: packages/next/pages/_document.tsx - Fossies
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TSX (TypeScript with React) source...
Read more >
react-apollo-loader - npm
A webpack loader to make those who use [React Apollo](https://github.com/apollographql/react-apollo#readme) and [GraphQL Code ...
Read more >
Tsx file
But now I'm getting an Error that it does not recognize import App from ". ... IntelliJ IDEA recognizes .ts and .tsx files...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found