Next.js Discord

Discord Forum

Type '{ params: { email: string; }; }' does not satisfy the constraint 'PageProps'.

Answered
Morelet’s Crocodile posted this in #help-forum
Open in Discord
Avatar
Morelet’s CrocodileOP
I'm using next 15 and params are now async the example given is:
function Page({ params }) {
  // asynchronous access of `params.id`.
  const { id } = await params
  return <p>ID: {id}</p>
}

I'm doing:
export default async function Page({ params }: { params: { email: string } }) {
    const { email } = await params;

I'm able to run just fine but im getting a TS error on build:
next/types/app/contact-card/[email]/page.ts:34:29
Type error: Type '{ params: { email: string; }; }' does not satisfy the constraint 'PageProps'.
  Types of property 'params' are incompatible.
    Type '{ email: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]

  32 |
  33 | // Check the prop type of the entry function
> 34 | checkFields<Diff<PageProps, FirstArg<TEntry['default']>, 'default'>>()
> 

Does anyone know what types I Should use to remove this warning? Thanks.
Answered by chisto
type Props = {
params: Promise<{ email: string }>;
};

export default async function Page(props: Props) {
const { email } = await props.params;
View full answer

3 Replies

Avatar
type Props = {
params: Promise<{ email: string }>;
};

export default async function Page(props: Props) {
const { email } = await props.params;
Answer
Avatar
Morelet’s CrocodileOP
for the win thanks man
that as super fast and correct