Fix TypeScript compatibility with PayloadCMS generated types

Resolves: TS2344: Type Email does not satisfy the constraint BaseEmailData
- Add null support to BaseEmailData interface for all optional fields
- Update parseAndValidateEmails to handle null values
- Update sendEmail validation to properly check for null values
- Maintain compatibility with PayloadCMS generated types that include null

Generated Email types like cc?: string[] | null | undefined now work correctly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-13 21:03:21 +02:00
parent 1af54c6573
commit e1800f5a6e
2 changed files with 14 additions and 13 deletions

View File

@@ -5,8 +5,8 @@ import { TemplateVariables } from '../types/index.js'
* Parse and validate email addresses
* @internal
*/
export const parseAndValidateEmails = (emails: string | string[] | undefined): string[] | undefined => {
if (!emails) return undefined
export const parseAndValidateEmails = (emails: string | string[] | null | undefined): string[] | undefined => {
if (!emails || emails === null) return undefined
let emailList: string[]
if (Array.isArray(emails)) {