I am often running into a situation where I store an object in React state, such as a User:

```
...
user: undefined,
setUser: (user) => set((state) => ({ user: { ...user, ...state.user } as User })),

```

I define the TypeScript type as

```
export type User = {
  verified: boolean;
  firstName: string;
  lastName: string;
  userType: 'user' | 'admin';
};

```

So, at the moment TypeScript will complain that `user`, which I instantiate as a `User` type is `undefined`, while it cannot be. FINE! So I add `| undefined` at the end of the `User` type definition. So that will take care of this specific file, but then I start getting a million and one other warnings all over, because, for example, I call `user.firstName`, but now that the user can be undefined, I really should call user?.firstName.
Adding conditions, such as `if(user)` does not seem to satisfy TS. So I end up spending three hours fixing stuff for TS, only to find out that my code now breaks because of this recent change.
It feels very much like trying to put down fires that I started myself when I used TypeScript. Frustrating.

Can someone who know TS well please offer some guidance? How would you approach this? Is there a way to handle such "undefined" cases?