title: Variable not found when using if/else condition but found when using ternary operator
body: <p>I have a code below using if/else condition to evaluate what value to assign <strong>addedDocument</strong> based on whether <strong>customId</strong> is not Null.</p>
  <p>Why is it that <strong>addedDocument</strong> cannot be found as seen in the picture below?</p>
  <pre><code>if (customId) {
    const addedDocument = await setDoc(doc(ref), {
      ...documentData,
      createdAt,
    });
  } else {
    const addedDocument = await addDoc(ref, { ...documentData, createdAt });
  }
  
  dispatchIfNotCancelled({
    type: 'ADDED_DOCUMENT',
    payload: addedDocument,
  });
  </code></pre>
  <p><a href="https://i.stack.imgur.com/m5Clo.png" rel="nofollow noreferrer">if/else operator causing variable to not be found</a></p>
  <p>But can be found when using a ternary operator? As seen in the picture below</p>
  <pre><code>const addedDocument = customId
    ? await setDoc(doc(ref, customId), { ...documentData, createdAt })
    : await addDoc(ref, { ...documentData, createdAt });
  
  dispatchIfNotCancelled({
    type: 'ADDED_DOCUMENT',
    payload: addedDocument,
  });
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Dvqhf.png" rel="nofollow noreferrer">Ternary operator having no error</a></p>