Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRPC Plugin generated typescript errors #455

Closed
mbrimmer83 opened this issue Jun 4, 2023 · 3 comments
Closed

TRPC Plugin generated typescript errors #455

mbrimmer83 opened this issue Jun 4, 2023 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@mbrimmer83
Copy link

Description and expected behavior
After generating ZenStack with the TRPC plugin. Some of the schemas have typescript errors. I currently have 133 errors and they all appear to be similar in nature. I'm not ruling out an issue in my setup or library version issue.

Type 
  'ZodObject<{ 
      where: ZodLazy<ZodType<Omit<UserBadgeWhereUniqueInput, "zenstack_transaction" | "zenstack_guard">, ZodTypeDef, Omit<UserBadgeWhereUniqueInput, "zenstack_transaction" | "zenstack_guard">>>; 
      update: ZodUnion<...>; 
      create: ZodUnion<...>; 
    }, "strict", ZodTypeAny, { ...; }, { ...; }>'
    
is not assignable to type 

  'ZodType<Omit<UserBadgeUpsertWithWhereUniqueWithoutUserInput, "zenstack_transaction" | "zenstack_guard">, ZodTypeDef, Omit<...>>'.

The types of '_type.update' are incompatible between these types.
Type 
  '(Omit<UserBadgeUpdateWithoutUserInput, "zenstack_transaction" | "zenstack_guard"> | 
    Omit<UserBadgeUncheckedUpdateWithoutUserInput, "zenstack_transaction" | "zenstack_guard">) & 
    (Omit<...> | ... 1 more ... | undefined)'
is not assignable to type 
  '(Without<UserBadgeUpdateWithoutUserInput, UserBadgeUncheckedUpdateWithoutUserInput> & 
    UserBadgeUncheckedUpdateWithoutUserInput) | 
    (Without<...> & UserBadgeUpdateWithoutUserInput)'.
Type 
  'Omit<UserBadgeUpdateWithoutUserInput, "zenstack_transaction" | "zenstack_guard"> & 
   Omit<UserBadgeUncheckedUpdateWithoutUserInput, "zenstack_transaction" | "zenstack_guard">' 
is not assignable to type 
  '(Without<UserBadgeUpdateWithoutUserInput, UserBadgeUncheckedUpdateWithoutUserInput> & 
    UserBadgeUncheckedUpdateWithoutUserInput) | 
    (Without<...> & UserBadgeUpdateWithoutUserInput)'.
Type 
  'Omit<UserBadgeUpdateWithoutUserInput, "zenstack_transaction" | "zenstack_guard"> & 
   Omit<UserBadgeUncheckedUpdateWithoutUserInput, "zenstack_transaction" | "zenstack_guard">' 
is not assignable to type 
  'Without<UserBadgeUncheckedUpdateWithoutUserInput, UserBadgeUpdateWithoutUserInput> & 
   UserBadgeUpdateWithoutUserInput'.
Type 
  'Omit<UserBadgeUpdateWithoutUserInput, "zenstack_transaction" | "zenstack_guard"> & 
   Omit<UserBadgeUncheckedUpdateWithoutUserInput, "zenstack_transaction" | "zenstack_guard">' 
is not assignable to type 
  'Without<UserBadgeUncheckedUpdateWithoutUserInput, UserBadgeUpdateWithoutUserInput>'.
Types of property 'badgeId' are incompatible.
Type 
  'string | StringFieldUpdateOperationsInput | undefined' 
is not assignable to type 
  'undefined'.
Type 'string' is not assignable to type 'undefined'.

Environment (please complete the following information):

  • ZenStack version: 1.0.0-alpha.124
  • Prisma version: 4.14.1
  • Typescript version: 4.9.4
  • Database type: CockroachDB

Additional context

/* eslint-disable */
import { z } from 'zod'
import { UserBadgeWhereUniqueInputObjectSchema } from './UserBadgeWhereUniqueInput.schema'
import { UserBadgeUpdateWithoutUserInputObjectSchema } from './UserBadgeUpdateWithoutUserInput.schema'
import { UserBadgeUncheckedUpdateWithoutUserInputObjectSchema } from './UserBadgeUncheckedUpdateWithoutUserInput.schema'
import { UserBadgeCreateWithoutUserInputObjectSchema } from './UserBadgeCreateWithoutUserInput.schema'
import { UserBadgeUncheckedCreateWithoutUserInputObjectSchema } from './UserBadgeUncheckedCreateWithoutUserInput.schema'

import type { Prisma } from '@prisma/client'
// Schema has the error
const Schema: z.ZodType<
  Omit<
    Prisma.UserBadgeUpsertWithWhereUniqueWithoutUserInput,
    'zenstack_transaction' | 'zenstack_guard'
  >
> = z
  .object({
    where: z.lazy(() => UserBadgeWhereUniqueInputObjectSchema),
    update: z.union([
      z.lazy(() => UserBadgeUpdateWithoutUserInputObjectSchema),
      z.lazy(() => UserBadgeUncheckedUpdateWithoutUserInputObjectSchema)
    ]),
    create: z.union([
      z.lazy(() => UserBadgeCreateWithoutUserInputObjectSchema),
      z.lazy(() => UserBadgeUncheckedCreateWithoutUserInputObjectSchema)
    ])
  })
  .strict()

export const UserBadgeUpsertWithWhereUniqueWithoutUserInputObjectSchema = Schema
@mbrimmer83
Copy link
Author

Resolved by downgrading zod from v3.21.4 to v3.21.1

colinhacks/zod#2184 (comment)

@ymc9
Copy link
Member

ymc9 commented Jun 4, 2023

Keeping this issue open for adding a FAQ into documentation.

@ymc9 ymc9 added the documentation Improvements or additions to documentation label Jun 4, 2023
@ymc9
Copy link
Member

ymc9 commented Jun 15, 2023

Closing since documentation is updated

@ymc9 ymc9 closed this as completed Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants