typescript
import_error
ai_generated
true
error TS2305: Module 'X' has no exported member 'Y'
ID: typescript/ts2305-module-no-exported-member
92%Fix Rate
92%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 5 | active | — | — | — |
Root Cause
Named import doesn't exist in the module. Different from TS2694 (namespace).
genericWorkarounds
-
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
-
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
-
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:
-
Use @ts-ignore to suppress
80% fail
Hides the error but runtime import will fail or be undefined
-
Use require() to bypass type checking
75% fail
Loses all type safety for this import
Error Chain
Frequently confused with: