Skip to content
Discussion options

You must be logged in to vote

AI code after many attepts

import type { FileRoutesByTo } from '@/routeTree.gen'

/** Checks that schema TSchema has all keys from TShape with compatible value types */
type SchemaMatchesShape<TSchema, TShape extends Record<string, unknown>> = {
  [K in keyof TShape]: K extends keyof TSchema
    ? TSchema[K] extends TShape[K]
      ? 1
      : 0
    : 0
}[keyof TShape] extends 1
  ? true
  : false

/**
 * Extracts route paths whose fullSearchSchema matches the given shape.
 * TanStack Router stores the resolved search schema in route.types.fullSearchSchema.
 *
 * @example
 * ExtractPathsWithSearchSchema<FileRoutesByTo, { page: number }>           // required page
 * ExtractPathsWithSearch…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by FatahChan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant