Next.js Discord

Discord Forum

I have errors on my .next/types folder...

Answered
Satin Angora posted this in #help-forum
Open in Discord
Satin AngoraOP
I am getting these errors on my .next folder;
From .next/types/app/[lang]/page.ts:
[{
    "resource": "/c:/Users/YMura/Belgeler/React Projects/Durmaz Express Websitesi/durmaz-express-website/.next/types/app/[lang]/page.ts",
    "owner": "typescript",
    "code": "2344",
    "severity": 8,
    "message": "Type 'OmitWithTag<i18nProps, keyof PageProps, \"default\">' does not satisfy the constraint '{ [x: string]: never; }'.\n  Property 'lang' is incompatible with index signature.\n    Type 'string' is not assignable to type 'never'.\n      Type 'string' is not assignable to type 'never'.",
    "source": "ts",
    "startLineNumber": 26,
    "startColumn": 13,
    "endLineNumber": 26,
    "endColumn": 68
},{
    "resource": "/c:/Users/YMura/Belgeler/React Projects/Durmaz Express Websitesi/durmaz-express-website/.next/types/app/[lang]/page.ts",
    "owner": "typescript",
    "code": "2559",
    "severity": 8,
    "message": "Type 'i18nProps' has no properties in common with type 'PageProps'.",
    "source": "ts",
    "startLineNumber": 26,
    "startColumn": 29,
    "endLineNumber": 26,
    "endColumn": 56
}]
and from .next/types/app/[lang]/layout.ts:
[{
    "resource": "/c:/Users/YMura/Belgeler/React Projects/Durmaz Express Websitesi/durmaz-express-website/.next/types/app/[lang]/layout.ts",
    "owner": "typescript",
    "code": "2344",
    "severity": 8,
    "message": "Type 'ResolvingMetadata | undefined' does not satisfy the constraint 'ResolvingMetadata'.\n  Type 'undefined' is not assignable to type 'Promise<ResolvedMetadata>'.",
    "source": "ts",
    "startLineNumber": 31,
    "startColumn": 39,
    "endLineNumber": 31,
    "endColumn": 88
}]
Answered by not-milo.tsx
I phrased it wrong...
Your page is getting the locale parameter in this shape:
{
  params: {
    lang: Locale;
  }
}


But you're telling it that it should expect this instead:

{
  lang: Locale
}
View full answer

20 Replies

Satin AngoraOP
@not-milo.tsx I isolated the issue. Can you repeat your suggestion so I can mark it?
Yeah, so...

The second issue you pasted is solved by removing the question mark from parent?: ResolvingMetadata; in your generateMetadata function
For the first one I'd have to see the types you have in /[lang]/page.tsx
Satin AngoraOP
It solved the issue, TY. Let me share the file with you:
import { i18nProps } from "../../i18n-config"
import { getDictionary } from "repositories/dictionaries"

import HomeNavBar from "components/home-navbar"
import AboutSection from "./_sections/about"

// TODO: Poppins font doesn't load...
export default async function HomePage({ lang }: i18nProps) {
  const dict = await getDictionary(lang)

  return <>
    <AboutSection dictionary={dict} />
  </>
}
AboutSection component is some headers inside section elements. Nothing complicated.
How does i18nProps look like?
Satin AngoraOP
This is the whole i18n-configs file. It's short
export const i18n = {
  defaultLocale: "tr",
  locales: ["tr", "en"]
} as const

export type Locale = (typeof i18n)["locales"][number]


export interface i18nProps {
  lang: Locale
}
Instead of using i18nProps use RootProps as in layout.tsx
Every page gets a params prop and if you omit it in the type definition for your props it will throw an error cause it's recieving something unexpected
Satin AngoraOP
Sorry my battery died x.x Let me change it
The error Type i18nProps has no properties in common with type 'PageProps' has been solved, but
Type 'OmitWithTag<RootProps, keyof PageProps, "default">' does not satisfy the constraint '{ [x: string]: never; }'.
  Property 'children' is incompatible with index signature.
    Type 'ReactNode' is not assignable to type 'never'.
      Type 'undefined' is not assignable to type 'never'.Type 'OmitWithTag<RootProps, keyof PageProps, "default">' does not satisfy the constraint '{ [x: string]: never; }'.
  Property 'children' is incompatible with index signature.
    Type 'ReactNode' is not assignable to type 'never'.
      Type 'undefined' is not assignable to type 'never'.
remains. I will try to change parameter type to PageProps
Wait wrong error.
@not-milo.tsx Every page gets a params prop and if you omit it in the type definition for your props it will throw an error cause it's recieving something unexpected
I phrased it wrong...
Your page is getting the locale parameter in this shape:
{
  params: {
    lang: Locale;
  }
}


But you're telling it that it should expect this instead:

{
  lang: Locale
}
Answer
Satin AngoraOP
Oohh...
I created a new interface to match with the signature of RootProps:
interface HomeProps {
  params: { lang: string }
}


export default async function HomePage({ params }: HomeProps) {
The issue is solved now
I could also change the RootProps... Whatever 😄
TYSM for help @not-milo.tsx .
It is interesting that it doesn't break the project in dev mode...
How you name them doesn't really matter as long as they match what you actually get and pass around 👌🏻
Yeah, there are some instances where everything looks fine but doesn't work in dev and you only se the real error in production when the project gets built :lolsob: