<commit_before>import path from 'path'

import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
import { WEBPACK_LAYERS } from '../../../lib/constants'

const PLUGIN_NAME = 'FlightTypesPlugin'

interface Options {
  dir: string
  appDir: string
  dev: boolean
  isEdgeServer: boolean
}

function createTypeGuardFile(
  fullPath: string,
  relativePath: string,
  options: {
    type: 'layout' | 'page'
  }
) {
  return `// File: ${fullPath}
import * as entry from '${relativePath}'
type TEntry = typeof entry

check<IEntry, TEntry>(entry)

type PageParams = Record<string, string>
interface PageProps {
  params?: PageParams
  searchParams?: Record<string, string | string[]>
}
interface LayoutProps {
  children: React.ReactNode
  params?: PageParams
}

type PageComponent = (props: PageProps) => React.ReactNode | Promise<React.ReactNode>
type LayoutComponent = (props: LayoutProps) => React.ReactNode | Promise<React.ReactNode>

interface IEntry {
  ${
    options.type === 'layout'
      ? `default: LayoutComponent`
      : `default: PageComponent`
  }
  config?: {}
  generateStaticParams?: (params?: PageParams) => Promise<any[]>
  revalidate?: RevalidateRange<TEntry> | false
  dynamic?: 'auto' | 'force-dynamic' | 'error' | 'force-static'<commit_msg>Fix build type error of page params (#42019)<commit_after>import path from 'path'

import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
import { WEBPACK_LAYERS } from '../../../lib/constants'

const PLUGIN_NAME = 'FlightTypesPlugin'

interface Options {
  dir: string
  appDir: string
  dev: boolean
  isEdgeServer: boolean
}

function createTypeGuardFile(
  fullPath: string,
  relativePath: string,
  options: {
    type: 'layout' | 'page'
  }
) {
  return `// File: ${fullPath}
import * as entry from '${relativePath}'
type TEntry = typeof entry

check<IEntry, TEntry>(entry)

type PageParams = Record<string, string>
interface PageProps {
  params: any
  searchParams?: any
}
interface LayoutProps {
  children: React.ReactNode
  params: any
}

type PageComponent = (props: PageProps) => React.ReactNode | Promise<React.ReactNode>
type LayoutComponent = (props: LayoutProps) => React.ReactNode | Promise<React.ReactNode>

interface IEntry {
  ${
    options.type === 'layout'
      ? `default: LayoutComponent`
      : `default: PageComponent`
  }
  config?: {}
  generateStaticParams?: (params?: PageParams) => Promise<any[]>
  revalidate?: RevalidateRange<TEntry> | false
  dynamic?: 'auto' | 'force-dynamic' | 'error' | 'force-static'
{'fraction_non_alphanumeric': 0.13235875148162782, 'fraction_numerical': 0.0019755037534571317, 'mean_word_length': 4.468682505399568, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6077315', 'n_tokens_mistral': 789, 'n_tokens_neox': 803, 'n_words': 206}