Skip to content

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

Closed

Description

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";.

Activity

  1. Jessidhia commented on May 10, 2017

    @Jessidhia

    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.

  2. mhegazy commented on May 10, 2017

    @mhegazy
    Contributor

    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.

  3. Jessidhia commented on May 10, 2017

    @Jessidhia

    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.

  4. ghost closed this as completedin #15538on May 11, 2017
  5. Jessidhia commented on May 11, 2017

    @Jessidhia

    Andy (Andrewkraft) (@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.

  6. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeBugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions