question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`error TS2300: Duplicate identifier` when referencing the same enum twice in a model

See original GitHub issue

We get a TS error due to duplicated named imports.

This schema:

enum MyEnum {
  A
  B
}

enum MyOtherEnum {
  A
  B
}

model MyModel {
  id String @id
  a MyEnum[]
  b MyOtherEnum?
  c MyEnum[]
  d MyOtherEnum?
}

Generates the following which results in the TS error

import {MyEnum, MyOtherEnum, MyEnum, MyOtherEnum} from '@prisma/client'
% npm ls zod-prisma
@gaia-family/monorepo@0.1.0 /Users/chrispearce/Projects/monorepo
└── zod-prisma@0.5.4

Desired:

Imported identifier should only be written once.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:6

github_iconTop GitHub Comments

4reactions
SamSokolincommented, Jul 26, 2022

@CarterGrimmeisen any chance you can release this fix to npm? Looks like https://github.com/CarterGrimmeisen/zod-prisma/commit/f3c27fb2a056763a4e11dbe6371505ebbdf9d69e fixes the issue but the most recent version on npm is from 6 months ago. Appreciate your work on this project, this is awesome!

4reactions
MatthiasDunkercommented, May 22, 2022

I made a pull request for this. Had the same issue.

https://github.com/CarterGrimmeisen/zod-prisma/pull/122

Read more comments on GitHub >

github_iconTop Results From Across the Web

Confusing "duplicate identifier" Typescript error message
When I ran npm start , I got a bunch of duplicate identifier errors. ... Using webpack I came across same error, just...
Read more >
Enum-based constants can be used as computed property ...
Enum values are known in compile-time, so it's possible to reject duplicate values. Actual behavior: The Duplicate identifier '80'.ts(2300) ...
Read more >
How to fix the "duplicate identifier" error in TypeScript
Duplicate identifier. You are defining, with other words referencing, the same identifier (class, method, property) twice in your code. The ...
Read more >
Fix TS2300 Duplicate identifier error in TypeScript with React
Have you updated your "react" and "@types/react" dependencies and now see error TS2300 and TS2717? Let me help you understand and fix these ......
Read more >
TypeScript errors and how to fix them
error TS2300 : Duplicate identifier 'name'. Broken Code ❌. Objects don't support multiple properties with the same name: 1
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found