Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export * from "mod" declarations are elided when "mod" has no exports #37123

Closed
weswigham opened this issue Feb 28, 2020 · 2 comments · Fixed by #37124
Closed

export * from "mod" declarations are elided when "mod" has no exports #37123

weswigham opened this issue Feb 28, 2020 · 2 comments · Fixed by #37124
Assignees
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Domain: ES Modules The issue relates to import/export style module behavior

Comments

@weswigham
Copy link
Member

TypeScript Version: 3.7.x-dev.201xxxxx

Search Terms:

Code

// @filename: register.ts
const r: any[] = [];
export function register(data: any) {
  r.push(data);
}
// @filename: data1.ts
import { register } from "./";
register("ok");
// @filename: index.ts
export * from "./register";
export * from "./data1";

Expected behavior:

// @filename: register.js
var r = [];
function register(data) {
  r.push(data);
}
exports.register = register;
// @filename: data1.js
var data1_1 = require("./");
data1_1.register("ok");
// @filename: index.js
// helpers
__exportStar(require("./register"), exports);
__exportStar(require("./data1"), exports);

Actual behavior:

// @filename: register.js
var r = [];
function register(data) {
  r.push(data);
}
exports.register = register;
// @filename: data1.js
var data1_1 = require("./");
data1_1.register("ok");
// @filename: index.js
// helpers
__exportStar(require("./register"), exports);

The reexport for file data1 is mistakenly dropped from index.js.

Playground Link:

Related Issues:

@weswigham weswigham added Bug A bug in TypeScript Domain: ES Modules The issue relates to import/export style module behavior labels Feb 28, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.9.0 milestone Feb 28, 2020
@DanielRosenwasser DanielRosenwasser added the Breaking Change Would introduce errors in existing code label Apr 8, 2020
@pycraft114
Copy link

pycraft114 commented May 25, 2020

@weswigham just out of curiosity , what are the use-cases of exporting a non-exporting file?
can't you just call 'register("ok");' inside register.ts?

@weswigham
Copy link
Member Author

Preserving hoisting and execution order in the presence of a cycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Domain: ES Modules The issue relates to import/export style module behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants