Next.js, strict Typescript and missing / hard to find RenderPageResult type


I have strict TypeScript setup. (Due to 'no implicit any return type' error/warning) I needed return type of one function in a custom Document component to be like:

<pre class="lang-js prettyprint-override"> ctx.renderPage = (): RenderPageResult | Promise<RenderPageResult> => originalRenderPage({ enhanceApp: App => (props): ReactElement => sheets.collect(<App {...props} />), });

but couldn't figure out how to get a hold of RenderPageResult.

So I've added following to the next-env.d.ts file:

<pre class="lang-js prettyprint-override">/// <reference types="next/dist/next-server/lib/utils" />

And imported RenderPageResult like this into the Document component:

<pre class="lang-js prettyprint-override">import { RenderPageResult } from 'next/dist/next-server/lib/utils';

<em>Is this correct way going about it?</em>

<em>Is there a better/correct way of doing it?</em>


<hr />


Project uses "next": "^9.1.4", which is pretty much the latest release at the time of writing.


Question originally posted here: https://spectrum.chat/next-js/general/next-js-strict-typescript-and-missing-hard-to-find-renderpageresult-type~6cf4b4a8-769f-4a99-a72e-8ee2f8ad17db


<ol><li>the next-env.d.ts file update mentioned above seems to add zero value (and based on TS docs probs is complete misunderstanding of the declaration files on my part).</li> </ol>



  • Is it safe, to share an array between threads?
  • can I read/write the routing table in C without using system() command?
  • Retrieving size of datatype from std::type_info
  • Does a WPF Application Actually Need Application.Run?
  • Why doesn't there exists a subi opcode for MIPS?
  • QTableView, setting a cell's font and background colour
  • Setting the cursor position in PyGTK (for a Gedit plugin)
  • Understanding HttpServletRequest and cookies in JSF
  • Muxing a H.264 Annex B & AAC stream using libavformat with vcopy/acopy
  • How to get data from activation link with Java Servlet
  • Combine rows with same id and delete duplicated rows
  • Merge of sorted lists with sized types
  • Was default_marker removed from mapbox-gl.js
  • Tomcat Replacing VM arguments
  • Querying a collection of embeddable elements using eclipselink
  • AngularJS TypeError: Converting circular structure to JSON at Object.stringify (native)
  • How to set title name of the pdf. While viewing the Document(New Tab)
  • Storyboard iOS MBProgressHUD
  • How to add CKEditor RTE to typo3 Backend Module with the API?
  • Problems installing Common Lisp Sketch into Windows 10
  • GitLab runner on Windows and dealing with & %ERRORLEVEL%
  • How do I remove line feed characters when selecting data from SQL Server?
  • Javapackager tool from command-line on OSX?
  • How do I detect if an email client is configured on an Android device?
  • Call a specific instance of a service in Azure Service Fabric
  • Bootstrap 3 Validation
  • How to use mixed C++ & .Net dll in node.js? (Error: abort() has been called)
  • C++ How to get process ID from filename of DLL(windows)?
  • Ways of filling 10 places with number from [1..10] such that digit at ith place has value atmost 1 m
  • jQuery - Prevent activation on first click
  • How to create mirrored image effect with CSS single element
  • Use awk to convert GPS Position to Latitude & Longitude
  • Hibernate Caused by: org.hibernate.AnnotationException: Unknown mappedBy
  • Authorize Attribute Authentication with Postman in Web Api
  • Does hibernate load two seprate copies of same instance if they are loaded twice from database?
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • Multiplying polynomials/simplifying like terms
  • using maven pom while creating jar:test-jar some times it says JAR will be empty - no content was ma
  • read part of h5 dataset python
  • convert json to excel in java