Nipun Ravisara
Nipun Ravisara

Reputation: 4471

TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string'

I have defined types as below

interface LoginFormValues {
  email?: string;
  password?: string;
} 

but eslint gives an error like this

enter image description here

Upvotes: 0

Views: 806

Answers (1)

Nick
Nick

Reputation: 16586

It looks like email cannot be undefined, which seems reasonable. It is also likely password can't be undefined either. Your type definition should probably be:

interface LoginFormValues {
  email: string;
  password: string;
} 

Upvotes: 1

Related Questions