Skip to content

    ↑↓ move · ⏎ open · esc close

    TS2304

    Cannot find name

    Cannot find name 'Missing'.

    The compiler’s own words. Not translated — this is the string you pasted into a search box.

    The compiler looked for this name in every scope it can see and found nothing. Usually a typo, an unimported type, or a value being used where a type belongs.

    Reproduction

    type A = Missing

    The build asserts this emits exactly this code.

    Why the compiler says this

    Types and values live in separate namespaces, and this error is often the seam between them. A `const` called `config` is not a type called `config`, and asking for one where the other exists produces exactly this message — which is why the fix is sometimes not "define it" but "ask for its type instead".

    Fixes

    1. 01
      type Missing = string
      
      type A = Missing

      Define it, if it genuinely does not exist yet.

    2. 02
      const config = { retries: 3 }
      
      type A = typeof config

      Or reach across the namespaces with `typeof`. The name existed all along — as a value — and `typeof` is how you ask for the type of one.

    Takeaway

    Before defining the missing name, check whether it already exists on the other side of the type/value divide. `typeof` crosses it in one direction and `keyof` walks what you find there.

    Where to go next

    Errors