-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
TypeScript Version: 3.8.3
Search Terms:
module import export circular
Background
I use to write module like this:
// module.js
export { foo, bar, baz, };
export * as default from './module.js'; // path of current file itself.
Then we can import the module with both to ways:
import { foo, } from './module.js';
import Module from './module.js';
Module.foo === foo; // true
That's work fine with JavaScript but not TypeScript.
Code
// module.ts
export * as default './module.ts';
Expected behavior: works like JavaScript.
Actual behavior:
error TS1359: Identifier expected. 'default' is a reserved word that cannot be used here.
export * as default from './module.ts';
~~~~~~~
So I modify my code to:
// module.ts
import * as Module './module.ts';
export default Module;
This works fine with JavaScript too, but not TypeScript again.
Expected behavior: works like JavaScript.
Actual behavior:
error TS2303: Circular definition of import alias 'Module'.
import * as Module from './test.ts';
~~~~~~~~~~~
I modify my code again to:
// module.ts
import * as Module './module.ts';
export default (Module);
It finally works, both JavaScript and TypeScript.
rbardini
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone