typescript import_error ai_generated true

error TS2305: Module 'X' has no exported member 'Y'

ID: typescript/ts2305-module-no-exported-member

Also available as: JSON · Markdown
92%Fix Rate
92%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
5 active

Root Cause

Named import doesn't exist in the module. Different from TS2694 (namespace).

generic

Workarounds

  1. 92% success Check if the export was renamed or moved in a package update
    Check if the export was renamed or moved in a package update

    Sources: https://www.typescriptlang.org/docs/handbook/modules/reference.html

  2. 88% success Use default import if the module uses export default: import X from 'mod' not { X }
    import X from 'mod' not { X }

    Sources: https://www.typescriptlang.org/docs/handbook/modules/reference.html

  3. 85% success Check @types package version matches the library version
    npm ls @types/react react  # versions should be compatible

    Sources: https://www.typescriptlang.org/docs/handbook/2/type-declarations.html

Dead Ends

Common approaches that don't work:

  1. Use @ts-ignore to suppress 80% fail

    Hides the error but runtime import will fail or be undefined

  2. Use require() to bypass type checking 75% fail

    Loses all type safety for this import

Error Chain

Frequently confused with: