title: How to type following object/type in Typescript
body: <p>I have the following:</p>
  <p>a user type which is:</p>
  <pre><code>export type User = {
    id: string | null;
    email: string | null;
    firstName: string | null;
    lastName: string | null;
    verified: boolean | null;
  };
  </code></pre>
  <p>and the following state:</p>
  <pre><code>let initialState: UserSliceState = {
    user: {
      id: null,
      firstName: null,
      lastName: null,
      email: null,
      verified: null,
    },
    error: null,
    isLoading: false,
  };
  </code></pre>
  <p>and i wanna type it but i don't know how to, i tried this:</p>
  <pre><code>type UserSliceState = {
    user: {
      [field: keyof User]: User;
    };
    error: string | null;
    isLoading: boolean;
  };
  </code></pre>
  <p>but it gives me an error on <code>[field: keyof User]</code> and i don't know if what i did is valid:
  it says <code>An index signature parameter can't be a union type, consider using a mapped object instead</code></p>
  <p>any ideeas? thanks</p>