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

Duplicate identifier 'CheckSelect' #9669

Closed
rickyhopkins opened this issue Oct 8, 2021 · 5 comments · Fixed by #20215
Closed

Duplicate identifier 'CheckSelect' #9669

rickyhopkins opened this issue Oct 8, 2021 · 5 comments · Fixed by #20215
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: client types Types in Prisma Client topic: type-clash
Milestone

Comments

@rickyhopkins
Copy link

Bug description

I have a model in my prisma schema called Check which looks like it causes prisma to generate conflicting types.

In .prisma/client/index.ts I am getting a typescript warning as there are 2 CheckSelect types:

  type CheckSelect<T, S, U> = T extends SelectAndInclude
    ? 'Please either choose `select` or `include`'
    : T extends HasSelect
    ? U
    : T extends HasInclude
    ? U
    : S
  export type CheckSelect = {
    id?: boolean
    name?: boolean
    checkType?: boolean
  }

image

How to reproduce

  1. Add a Check model to prisma.schema
  2. run prisma generate
  3. See error

I dont think there is anything complicated going on here.

Expected behavior

I would expect prisma to either warn me that I cannot create a model called Check or handle the conflict in another way.

Prisma information

I think this can be replicated with something as simple as this:

model Check {
  id          String        @id @default(uuid())
}

Environment & setup

  • OS: Windows
  • Database: PostgreSQL
  • Node.js version: 14

Prisma Version

prisma                  : 3.0.2
@prisma/client          : 3.0.2
Current platform        : windows
Query Engine (Node-API) : libquery-engine 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash    : 2452cc6313d52b8b9a96999ac0e974d0aedf88db
Studio                  : 0.423.0
@rickyhopkins rickyhopkins added the kind/bug A reported bug. label Oct 8, 2021
@janpio janpio added team/client Issue for team Client. topic: type-clash topic: client types Types in Prisma Client bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Oct 8, 2021
@janpio
Copy link
Member

janpio commented Oct 8, 2021

Can confirm:

  type CheckSelect<T, S, U> = T extends SelectAndInclude
    ? 'Please either choose `select` or `include`'
    : T extends HasSelect
    ? U
    : T extends HasInclude
    ? U
    : S

and

  export type CheckSelect = {
    id?: boolean
  }

@SuryaElavazhagan
Copy link
Contributor

I think we can prefix all auto generated interfaces with Prisma__ to avoid future type clashes

SevInf added a commit that referenced this issue Jul 13, 2023
After looking through the issues, we had a couple of more clashes that
needed additional work:

1. `Check` and `Has` collide with built-in `CheckSelect`/`HasSelect`
   types. Those types are not public and not used since prisma 4.16.0,
   so I just removed them from generated file.
2. `Promise` is more complicated and required aliasing built-in type.

Fix #17542
Fix #9669
Close #12469
SevInf added a commit that referenced this issue Jul 18, 2023
…#20215)

* fix(client): Allow to use `Check`, `Has` and `Promise` as model names

After looking through the issues, we had a couple of more clashes that
needed additional work:

1. `Check` and `Has` collide with built-in `CheckSelect`/`HasSelect`
   types. Those types are not public and not used since prisma 4.16.0,
   so I just removed them from generated file.
2. `Promise` is more complicated and required aliasing built-in type.

Fix #17542
Fix #9669
Close #12469

* Ensure type alias is still displayed as `Promise` in editor

* Try different method

---------

Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
@Jolg42 Jolg42 added this to the 5.1.0 milestone Jul 18, 2023
@SevInf
Copy link
Contributor

SevInf commented Jul 18, 2023

This is fixed and the fix will be published as a part of 5.1 release. You can also check out 5.1.0-dev.25 dev snapshot - we do not recommend using dev snapshots in production, but it should be enough to verify the fix.

@subhendupsingh
Copy link

subhendupsingh commented Jul 21, 2023

Tried the 5.1.0-dev.25, still getting the duplicate identifier error

node_modules/.prisma/client/index.d.ts:46587:15 - error TS2300: Duplicate identifier 'MediaCreateWithoutOrganizationInput'.

46587   export type MediaCreateWithoutOrganizationInput = {

@janpio janpio reopened this Jul 22, 2023
@SevInf
Copy link
Contributor

SevInf commented Jul 24, 2023

@subhendupsingh this issue is specifically about being able to name model Check. You error, even though also talks about duplicate identifier, is a different one. There were a bunch of other type clash fixes done recently, you can try to check 5.1.0-dev.61 version, which has all previously reported type conflicts fixed. If it still happens for you on that version, please, open a new issue and attach your schema.
Thank you!.

@SevInf SevInf closed this as completed Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: client types Types in Prisma Client topic: type-clash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants