__importDefault method may return an object with undefined default property
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Description
In my project, I use tslib as the helper library.
Today, I come across a mistake like this:

the error line code that generated by tsc is:
typedocApp = new typedoc_1.default.Application();
and typedoc_1 is defined like this:
var typedoc_1 = tslib_1.__importDefault(require("typedoc"));
So, I readed the code of __importDefault method in tslib:
__importDefault = function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
If a mod has __esModule property but does not have default property, such as typedoc, the error described above will be fired.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the __importDefault helper implementation and reproduce the reported case with a module that has __esModule but no default property. Trace the generated import usage shown in the issue and add or update coverage for that case; done means the helper no longer produces the reported undefined default behavior without breaking ordinary CommonJS interop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100