chrishoermann / zod-prisma-types

Generator creates zod types for your prisma models with advanced validation
Other
626 stars 47 forks source link

custom imports: multiple imports of same module not working (depending on space) #84

Closed michiim closed 1 year ago

michiim commented 1 year ago

custom imports works depending on spaces

does work: /// @zod.import(["import { myFunction,myFunction2 } from 'mypackage'"]) /// @zod.import(["import { myFunction } from 'mypackage'", "import { myFunction } from 'mypackage'"])

does not work: /// @zod.import(["import { myFunction, myFunction2 } from 'mypackage'"]) /// @zod.import(["import { myFunction } from 'mypackage'","import { myFunction } from 'mypackage'"])

This happens because your split definition at line 209 in packages/generator/src/classes/extendedDMMFModel.ts: const importsList = importStatements.groups?.['imports']?.split(', ');

chrishoermann commented 1 year ago

@michiim thanks for finding this issue. changed the split to a regex that should fix it in the latest release.

michiim commented 1 year ago

Great, thanks a lot.