TS2305
TypeScript Programming Language
Severity: ModerateWhat Does This Error Mean?
TypeScript error TS2305 means you are trying to import something from a module, but that module does not export anything by that name. The full message is: 'Module X has no exported member Y.' This is caused by a typo in the import name, importing something that does not exist, or the module changed its exports in a version update. The fix is to correct the import name to match what the module actually exports.
Affected Models
- TypeScript 4.x
- TypeScript 5.x
- VS Code
- WebStorm
- Any TypeScript project
Common Causes
- The imported name is misspelled — a capital letter difference or typo makes it not match the export
- The module changed its exports in a version update and the old import name no longer exists
- The item is exported from a different file or sub-path within the package, not the root import
- The item is a type-only export that requires import type syntax in TypeScript's isolatedModules mode
- You are importing a default export using named import syntax (or vice versa)
How to Fix It
-
Check the exact spelling and capitalization of the imported name. TypeScript exports are case-sensitive. 'useState' and 'UseState' are different things.
In VS Code, hovering over the import shows available exports from that module via IntelliSense. Use Ctrl+Space for auto-completion suggestions.
-
Check what the module actually exports. Open the module's type definition file (.d.ts) or look at the package's documentation. In VS Code, Ctrl+Click the module name to navigate to its type definitions.
The .d.ts file lists every export. If the name you want is not there, either it does not exist or it comes from a different import path.
-
Check if the package was updated and renamed its exports. Look at the package's changelog (CHANGELOG.md or GitHub releases) for breaking changes in the version you installed.
NPM package major version updates frequently rename or restructure exports. Running 'npm outdated' shows if you jumped a major version.
-
Check if the item is exported from a sub-path of the package. Some packages export from the root (import { x } from 'package') while components are in sub-paths (import { x } from 'package/component').
For example, React Router exports Route from 'react-router-dom' but some utilities from 'react-router-dom/server'.
-
If importing a type, use 'import type { MyType } from ...' syntax. Some TypeScript configurations (isolatedModules: true) require type-only imports to be explicitly marked as types.
import type is always safe to use for TypeScript types and interfaces — it guarantees the import is erased at compile time.
When to Call a Professional
TS2305 is a TypeScript compile-time error that you resolve entirely in your code. No external service is needed. Check the package's documentation or the module's type definition file to find the correct export name.
Frequently Asked Questions
Why does TS2305 only appear after updating a package?
Package updates, especially major versions, frequently change or remove exports. A function or type that existed in version 4.x might be renamed, moved to a different path, or removed entirely in version 5.x. Always check the package's migration guide or changelog after a major version update. TypeScript catches these breaking changes at compile time rather than at runtime, which is one of TypeScript's key advantages.
How do I see all available exports from a module in VS Code?
Type the module name in an import statement and use Ctrl+Space to trigger IntelliSense autocomplete. VS Code reads the module's .d.ts type definitions and shows all named exports. You can also navigate to the module's types by holding Ctrl and clicking the module name in an existing import. This opens the .d.ts file where all exports are defined.
What is the difference between TS2305 and TS2304?
TS2305 says the module exists but does not export the specific name you requested — the module path is correct but the export name is wrong. TS2304 says TypeScript cannot find the name at all in any scope — it is not imported and not defined anywhere. TS2305 is specifically about module exports; TS2304 is about any identifier that TypeScript cannot resolve.