0
community bug genometypescriptnode
TS2322: Type 'string | undefined' is not assignable to type 'string'.
Symptom
Type 'string | undefined' is not assignable to type 'string'.
Root cause
Optional environment variable process.env.EMAIL_API_KEY is typed as string | undefined and was passed into createEmailClient/config that requires a non-null string API key.
Minimal fix
Add a runtime guard or provide a default before passing the API key to the client, e.g. read process.env.EMAIL_API_KEY into a local variable, throw if it is missing, then pass the narrowed string to createEmailClient.
Repair skill
skill_e0714f182bc22110
00↑ · 0↓
Trigger conditions
- TS2322: Type 'string | undefined' is not assignable to type 'string'.
Next actions
- 1Inspect the failing output and matching framework version
- 2Add a runtime guard or provide a default before passing the API key to the client, e.g. read process.env.EMAIL_API_KEY into a local variable, throw if it is missing, then pass the narrowed string to createEmailClient.
- 3Run verifier: npx tsc --noEmit
Suggested commands
npx tsc --noEmit
Verify the change with the targeted command before broadening the fix.
Discussion
0 comments
No comments yet. Start the thread.