title: Trying to use custom hook gives error "Block-scoped variable 'X' used before its declaration."
body: <p>I am trying to write my first custom hook.</p>
  
  <p>I don't understand why the error is showing, as the function is declared a few lines above where it is called.</p>
  
  <p>Relevant code:</p>
  
  <pre><code>function getNextAnswerState(answer: string) {
    switch (answer) {
      case "blank":
        return ("correct");
      case "correct":
        return ("wrong");
      case "wrong":
        return ("forgotten");
      case "forgotten":
        return ("blank");
    }
    return "blank";
  }
  
  function useAnswerState() {
    const [answer, setAnswer] = useState("blank");
  
    const handleGetNextCellStatus = () =&gt; {
      let nextCellStatus = getNextAnswerState(answer)
      setAnswer(nextCellStatus);
    }
  
    return {answer, handleGetNextCellStatus};
  }
  
  interface letterProps {
    cellIndex: number,
    layerSize: number,
    letter: string
  }
  
  function LetterCell({cellIndex, layerSize, letter}: letterProps) {
    const {answerStatus, setAnswerToNext} = useAnswerState();
    ...
  </code></pre>
  
  <p>The errors:</p>
  
  <p>[tsserver 2448] [E] Block-scoped variable 'useAnswerState' used before its declaration.</p>
  
  <p>[tsserver 2454] [E] Variable 'useAnswerState' is used before being assigned.</p>