Skip to content

Instantly share code, notes, and snippets.

@Steellgold
Created November 25, 2023 15:35
Show Gist options
  • Save Steellgold/8838cf0ff7080ef2acb52b079dc45de9 to your computer and use it in GitHub Desktop.
Save Steellgold/8838cf0ff7080ef2acb52b079dc45de9 to your computer and use it in GitHub Desktop.
To avoid errors (e.g: Type error: Type 'ZodObject<{ where: ZodLazy<ZodType[...])
"scripts": {
"prisma:generate": "prisma generate && node prisma-zod-ts-nocheck.js"
}
const fs = require('fs');
const path = require('path');
/**
* The file path of the generated Zod index file.
* @type {string}
*/
const filePath = path.join(__dirname, 'prisma/generated/zod/index.ts');
if (fs.existsSync(filePath)) {
let fileContent = fs.readFileSync(filePath, 'utf8');
if (!fileContent.startsWith('// @ts-nocheck')) {
fileContent = '// @ts-nocheck\n' + fileContent;
fs.writeFileSync(filePath, fileContent, 'utf8');
} else {
console.log('File already has ts-nocheck');
}
} else {
console.log('File does not exist');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment