Skip to content

--isolatedModules should warn about re-export of type #15231

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

Closed
ghost opened this issue Apr 17, 2017 · 5 comments
Closed

--isolatedModules should warn about re-export of type #15231

ghost opened this issue Apr 17, 2017 · 5 comments
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@ghost
Copy link

ghost commented Apr 17, 2017

TypeScript Version: nightly (Version 2.3.0-dev.20170417)

Code

a.ts

export const A = 0;
export type B = number;

b.ts

export { A, B } from "./a";

Expected behavior:

An error saying that the emit of b.ts depends on the contents of a.ts.

Actual behavior:

b.js is export { A } from "./a";.

@Jessidhia
Copy link

Jessidhia commented May 10, 2017

Hm... what exactly is --isolatedModules supposed to do?

I have been using it as a way of requiring that only files parsed as "module" would be considered valid (i.e. requires at least one "import" or "export" in typescript, forbids (potentially sloppy) scripts), though preventing reexporting of types would break things on my project.

I can turn of --isolatedModules off in 2.4 in that case, but since it seems to do more than what I thought it did, I wonder what would be the side effects.

@mhegazy
Copy link
Contributor

mhegazy commented May 10, 2017

It guarantees that the file can be transpiled in isolation. Hence the isolated part. Things that need cross file information to emit like namespaces spanning multiple files or const enums are not alloewd. This is what you would use if you were using transpileModule API.

@Jessidhia
Copy link

So I assume the absence of --isolatedModules is what causes this behavior? DefinitelyTyped/DefinitelyTyped#16118 (comment)

If that is the case, disabling --isolatedModules could be problematic in my codebase, as I have multiple independent (non-exported) interface Props {} in different files. IIUC, this would cause them to augment each other instead of still being independent.

@ghost
Copy link
Author

ghost commented May 10, 2017

--isolatedModules won't cause "isolated" type-checking behavior, just isolated transpilation. So multiple globally-declared interfaces will still be merged. Not sure which specific issue you're talking about as the link there just takes me to the issue, not to a particular comment.

@mhegazy mhegazy added Breaking Change Would introduce errors in existing code Fixed A PR has been merged for this issue labels May 11, 2017
@ghost ghost closed this as completed in #15538 May 11, 2017
@Jessidhia
Copy link

@Andy-MS ah, that happens sometimes in github. The thing in question was about type / interface in .d.ts being exported regardless of the presence of export, which upon thinking further wouldn't (unintentionally) be further augmentable.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants