title: Get one of the two types of a Typescript union type
body: <p>I have this union type:</p>
  <pre><code>export interface IUserInfosLogin {
    usernameOrEmail: string;
    password: string;
  }
  
  export interface IUserInfosRegister {
    username: string;
    email: string;
    password: string;
    passwordConfirm: string;
  }
  
  export type TUserInfos = IUserInfosLogin | IUserInfosRegister;
  </code></pre>
  <p>And I would like a <code>const [userInfos, setUserInfos] = useState&lt;TUserInfos&gt;{}</code> to take just one of these types, but when I try to access <code>userInfos</code> only <code>password</code> is available.</p>
  <p>Can someone explain it to me?</p>