title: Working with Typescript Interfaces- error: property does not exist
body: <p>I built this interface</p>
  <pre><code>export interface UserInfo {
      success?: boolean,
      user?: User,
      employer?: Employer,
      hr?: Hr
  }
  </code></pre>
  <p>Now when I do this</p>
  <pre><code>let data = await loginUser(loginData);
  console.log(data.success);
  </code></pre>
  <p>loginUser method code:</p>
  <pre><code>import {createApi, fetchBaseQuery} from &quot;@reduxjs/toolkit/query/react&quot;;
  import {BASE_API_ENDPOINT, LOGIN_API_ENDPOINT} from &quot;../../constants/apis&quot;;
  import {LoginData, UserInfo} from &quot;../../models/apis/UserData&quot;;
  
  export const loginApi = createApi({
      reducerPath: 'loginReducer',
      baseQuery: fetchBaseQuery({ baseUrl: BASE_API_ENDPOINT }),
      endpoints: (builder) =&gt; ({
          loginUser: builder.mutation&lt;UserInfo, LoginData&gt; ({
              query: (data: LoginData) =&gt; ({
                      url: LOGIN_API_ENDPOINT,
                      method: &quot;POST&quot;,
                      body: data
              }),
              transformResponse: (rawResult : UserInfo) =&gt; {
                  return rawResult
              }
          })
      })
  })
  export const { useLoginUserMutation } = loginApi;
  </code></pre>
  <p>I get this error</p>
  <blockquote>
  <p>Property 'success' does not exist on type '{ data: UserInfo; } | { error: FetchBaseQueryError | SerializedError; }'.</p>
  </blockquote>
  <p>I am a newbie with typescript, and I want to access UserInfo object from { data: UserInfo; } but I am not being able to do so. Can anyone help?</p>