microsoft / microsoft/TypeScript
`esModuleInterop` breaks circular imports
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.5.2
Search Terms:
Code
./tsconfig.json:
{
"compilerOptions": {
"esModuleInterop": true
},
"files": ["./src/main.ts"]
}
./src/main.ts
import { other } from './other';
console.log(other.foo1);
./src/other.ts
export const foo1 = 1;
export const foo2 = 2;
// Import *this* module as a namespace
// Unexpected error:
// Circular definition of import alias 'other'
import * as other from './other';
// Re-export the namespace as a named export
export { other };
(For context on why you might do this: it allows you to give namespace imports a common name.)
Expected behavior:
No error
Actual behavior:
Error (see code comment)
Contributor guide
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
Reproduce the diagnostic with ./tsconfig.json, src/main.ts, and src/other.ts using TypeScript 3.5.2 or the relevant current version. Start by tracing the circular import alias check for the namespace import in src/other.ts; done means the example compiles without the reported error while preserving the expected import and re-export behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100