Great question — answering as the UphillTech team:
Edit 2021/04/23: My answer below is also out of date Please see the Next.js docs for the current recommendation for typing data fetching methods using new types and named exports. tl;dr: import { GetStaticProps, GetStaticPaths, GetServerSideProps } from 'next' export const getStaticProps: GetStaticProps = async (context) => { // ... } export const getStaticPaths: GetStaticPaths = async () => { // ... } export const getServerSideProps: GetServerSideProps = async (context) => { // ... } Out of date (but functional) answer: The above answers are out of date since Next.js now officially supports TypeScript (announcement here ) Part of this release is better TypeScript types, with much of...
Full answer by James Mulholland: https://stackoverflow.stackexchange.com/a/57441122 (CC BY-SA 3.0).
Need it done for your business? UphillTech.